BlinkenArea - GitList
Repositories
Blog
Wiki
libetherpix
Code
Commits
Branches
Tags
Search
Tree:
e2a21a2
Branches
Tags
master
libetherpix
Makefile
v1.0.6
Stefan Schuermans
commited
e2a21a2
at 2011-09-11 17:17:58
Makefile
Blame
History
Raw
# FlexiPix library # !version: 1.0.6! !date: 2010-12-30! # # 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_MAJ := 1 VER_MIN := 0 VER_REV := 6 SRCS := $(wildcard src/*.c) EX_SRCS := $(wildcard examples/src/*.c) VERSION := $(VER_MAJ).$(VER_MIN).$(VER_REV) DATE := $(shell date +%Y-%m-%d) PACKNAME := $(LIBTARGET)-$(VERSION)_$(DATE) PACKDATA := ChangeLog COPYING COPYING.LESSER Makefile \ examples include README src CFLAGS := -W -Wall -O3 DEFINES := -DFLP_VER_MAJ=$(VER_MAJ) -DFLP_VER_MIN=$(VER_MIN) \ -DFLP_VER_REV=$(VER_REV) INCLUDES := -Iinclude SH_LDFLAGS := SH_LIBS := EX_LDFLAGS := -Llib EX_LIBS := -lm -lflexipix STOW_DIR := /usr/local/stow DEF_PREFIX := /usr/local OS_RAW := $(shell uname -s) ifeq ($(OS_RAW),Linux) OS := linux CC := gcc AR := ar RANLIB := ranlib LEXT := so LEXTSUF := .$(VERSION) BSUF := INSTALL := install CFLAGS += -fPIC SH_LDFLAGS += -shared -Wl,-soname,$(LIBTARGET).so.$(VER_MAJ) EX_LDFLAGS += -Wl,-rpath,\$$ORIGIN/../../lib EX_LIBS += -lpthread endif ifeq ($(OS_RAW),Darwin) OS := darwin CC := gcc AR := ar RANLIB := ranlib LEXT := dylib LEXTSUF := BSUF := INSTALL := install CFLAGS += -fPIC SH_LDFLAGS += -dynamiclib EX_LIBS += -lpthread endif ifeq ($(patsubst MINGW32%,MINGW32,$(OS_RAW)),MINGW32) OS := mingw32 CC := gcc AR := ar RANLIB := ranlib LEXT := dll LEXTSUF := BSUF := .exe INSTALL := install DEFINES += -DWINDOWS SH_LDFLAGS += -shared SH_LIBS += -lwsock32 EX_LIBS += -lwsock32 endif ifeq ($(OS),) $(error unsupported operating system $(OS_RAW)) endif 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 := $(addsuffix $(BSUF),$(EX_SRCS_BASE)) TARGET := lib/$(LIBTARGET).a SH_TARGET := lib/$(LIBTARGET).$(LEXT)$(LEXTSUF) 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 install uninstall ver pack .SECONDARY: .SUFFIXES: all: deps $(TARGET) $(SH_TARGET) $(EX_TARGETS) ifneq ($(MAKECMDGOALS),clean) include deps endif deps: $(DEPS) $(EX_DEPS) cat /dev/null $+ >$@ %.d: %.c $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -M -o $@ $< sed 's!^$(basename $(notdir $<))!$(dir $<)&!' <$@ >$@.tmp mv $@.tmp $@ %.o: %.c $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c -o $@ $< %$(BSUF): %.o $(LTA) $(LTSO) $(CC) $(EX_LDFLAGS) -o $@ $< $(EX_LIBS) lib: mkdir -p lib $(TARGET): $(OBJS) | lib $(AR) cr $@ $(filter-out lib,$+) $(RANLIB) $@ $(SH_TARGET): $(OBJS) | lib $(CC) $(SH_LDFLAGS) -o $@ $+ $(SH_LIBS) ifeq ($(OS),linux) cd $(dir $@); \ ln -s $(notdir $@) \ $(patsubst %.$(VER_REV),%,$(notdir $@)) cd $(dir $@); \ ln -s $(patsubst %.$(VER_REV),%,$(notdir $@)) \ $(patsubst %.$(VER_MIN).$(VER_REV),%,$(notdir $@)) cd $(dir $@); \ ln -s $(patsubst %.$(VER_MIN).(VER_REV),%,$(notdir $@)) \ $(patsubst %.$(VER_MAJ).$(VER_MIN).$(VER_REV),%,$(notdir $@)) endif clean: rm -rf deps $(DEPS) $(OBJS) lib \ $(EX_DEPS) $(EX_OBJS) $(EX_TARGETS) 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 $(TARGET) $(SH_TARGET) ifeq ($(OS),linux) ln -s $(LIBTARGET).$(LEXT).$(VER_MAJ).$(VER_MIN).$(VER_REV) \ $(PREFIX)/lib/$(LIBTARGET).$(LEXT).$(VER_MAJ).$(VER_MIN) ln -s $(LIBTARGET).$(LEXT).$(VER_MAJ).$(VER_MIN) \ $(PREFIX)/lib/$(LIBTARGET).$(LEXT).$(VER_MAJ) endif uninstall: rm -f $(PREFIX)/lib/$(notdir $(SH_TARGET)) rm -f $(PREFIX)/lib/$(notdir $(TARGET)) rm -rf $(PREFIX)/include/flexipix ver: $(MAKE) clean for FILE in $$(find $(PACKDATA) -type f); \ do \ <$$FILE sed 's/!version: [0-9.]*!/!version: $(VERSION)!/g' \ | sed 's/!date: [0-9-]*!/!date: $(DATE)!/g' >$$FILE.tmp; \ mv $$FILE.tmp $$FILE; \ done pack: $(MAKE) clean $(MAKE) ver $(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