BlinkenArea - GitList
Repositories
Blog
Wiki
libetherpix
Code
Commits
Branches
Tags
Search
Tree:
fb91a00
Branches
Tags
master
libetherpix
Makefile
v1.0.5
Stefan Schuermans
commited
fb91a00
at 2011-09-11 17:17:19
Makefile
Blame
History
Raw
# FlexiPix library # !version: 1.0.5! !date: 2010-12-22! # # Copyright 2010 Stefan Schuermans <stefan schuermans info> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. LIBTARGET=libflexipix VER=1 VERMIN=0 VERREV=5 OS:=$(shell uname -s) ifeq ($(OS),Linux) SED_I=sed -i CC=gcc AR=ar SHLIBFLAGS=-shared -Wl,-soname,$(LIBTARGET).so.$(VER) SHLIBEXT=so RANLIB=ranlib INSTALL=install STOW_DIR=/usr/local/stow DEF_PREFIX=/usr/local else ifeq ($(OS),Darwin) SED_I=sed -i "" CC=gcc AR=ar SHLIBFLAGS=-dynamiclib SHLIBEXT=dylib RANLIB=ranlib INSTALL=install STOW_DIR=/usr/local/stow DEF_PREFIX=/usr/local else $(error unsupported OS) endif endif SRCS=$(wildcard src/*.c) EX_SRCS=$(wildcard examples/src/*.c) CFLAGS=-W -Wall -fPIC -O3 DEFINES=-DFLP_VER_MAJ=$(VER) -DFLP_VER_MIN=$(VERMIN) -DFLP_VER_REV=$(VERREV) INCLUDES=-Iinclude LDFLAGS=-Llib LIBS=-lm -lpthread -lflexipix SRCS_BASE=$(patsubst %.c,%,$(SRCS)) DEPS=$(addsuffix .d,$(SRCS_BASE)) OBJS=$(addsuffix .o,$(SRCS_BASE)) EX_SRCS_BASE=$(patsubst %.c,%,$(EX_SRCS)) EX_DEPS=$(addsuffix .d,$(EX_SRCS_BASE)) EX_OBJS=$(addsuffix .o,$(EX_SRCS_BASE)) EX_TARGETS=$(EX_SRCS_BASE) LIBTGA = lib/$(LIBTARGET).a LIBTGSO = lib/$(LIBTARGET).$(SHLIBEXT).$(VER) LIBTGSOM = $(LIBTGSO).$(VERMIN) LIBTGSOR = $(LIBTGSOM).$(VERREV) VERSION = $(VER).$(VERMIN).$(VERREV) DATE := $(shell date +%Y-%m-%d) PACKNAME = $(LIBTARGET)-$(VERSION)_$(DATE) PACKDATA = ChangeLog COPYING COPYING.LESSER Makefile \ examples include README src ENV_PREFIX=$(shell echo $$PREFIX) STOW_PREFIX=$(STOW_DIR)/libflexipix-$(VERSION) ifneq ($(ENV_PREFIX),) PREFIX=$(ENV_PREFIX) else ifeq ($(shell if [ -d $(STOW_DIR) ]; then echo stow; fi),stow) PREFIX=$(STOW_PREFIX) else PREFIX=$(DEF_PREFIX) endif endif .PHONY: all clean pack install uninstall .SECONDARY: .SUFFIXES: all: deps $(LIBTGA) $(LIBTGSO) $(EX_TARGETS) ifneq ($(MAKECMDGOALS),clean) include deps endif deps: $(DEPS) $(EX_DEPS) cat /dev/null $+ >$@ %.d: %.c $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -M -o $@ $< $(SED_I) 's!^$(basename $(notdir $<))!$(dir $<)&!' $@ %.o: %.c $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c -o $@ $< %: %.o $(LIBTGA) $(LIBTGSO) $(CC) $(LDFLAGS) -o $@ $< $(LIBS) lib: mkdir -p lib $(LIBTGA): $(OBJS) lib $(AR) cr $@ $(filter-out lib,$+) $(RANLIB) $@ $(LIBTGSOR): $(OBJS) $(CC) $(SHLIBFLAGS) $(LDFLAGS) -o $@ $+ $(LIBTGSOM): $(LIBTGSOR) rm -f $@ ln -s $(notdir $<) $@ $(LIBTGSO): $(LIBTGSOM) rm -f $@ ln -s $(notdir $<) $@ clean: rm -rf deps $(DEPS) $(OBJS) lib \ $(EX_DEPS) $(EX_OBJS) $(EX_TARGETS) pack: $(MAKE) clean $(SED_I) 's/!version: [0-9.]*!/!version: $(VERSION)!/g' $$(find $(PACKDATA) -type f) $(SED_I) 's/!date: [0-9-]*!/!date: $(DATE)!/g' $$(find $(PACKDATA) -type f) $(MAKE) $(MAKE) clean mkdir -p pack/$(PACKNAME) cp -r $(PACKDATA) pack/$(PACKNAME) cd pack; tar jcf $(PACKNAME).tar.bz2 $(PACKNAME) rm -rf pack/$(PACKNAME) $(MAKE) clean install: all $(INSTALL) -d $(PREFIX)/include/flexipix $(INSTALL) -m 644 -t $(PREFIX)/include/flexipix $(wildcard include/flexipix/*.h) $(INSTALL) -d $(PREFIX)/lib $(INSTALL) -m 644 -t $(PREFIX)/lib $(LIBTGA) $(LIBTGSO) ln -sf $(notdir $(LIBTGSO)) $(PREFIX)/lib/$(notdir $(LIBTGSOM)) ln -sf $(notdir $(LIBTGSOM)) $(PREFIX)/lib/$(notdir $(LIBTGSOR)) uninstall: rm -f $(PREFIX)/lib/$(notdir $(LIBTGA)) rm -f $(PREFIX)/lib/$(notdir $(LIBTGSOR)) rm -f $(PREFIX)/lib/$(notdir $(LIBTGSOM)) rm -f $(PREFIX)/lib/$(notdir $(LIBTGSO)) rm -rf $(PREFIX)/include/flexipix