packio-simple
diff Makefile @ 0:d81c3ae262a0
initial commit
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Sun, 09 Sep 2012 06:05:11 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Makefile Sun Sep 09 06:05:11 2012 +0300 1.3 @@ -0,0 +1,57 @@ 1.4 +src = $(wildcard src/*.c) 1.5 +hdr = packio.h 1.6 +obj = $(src:.c=.o) 1.7 +dep = $(obj:.o=.d) 1.8 +name = packio 1.9 +lib_a = lib$(name).a 1.10 + 1.11 +abimaj = 0 1.12 +abimin = 1 1.13 + 1.14 +CFLAGS = -pedantic -Wall $(pic) $(dbg) $(opt) 1.15 +LDFLAGS = $(libs) 1.16 + 1.17 +ifeq ($(shell uname -s), Darwin) 1.18 + lib_so = lib$(name).dylib 1.19 + shared = -dynamiclib 1.20 +else 1.21 + devlink = lib$(name).so 1.22 + soname = $(devlink).$(abimaj) 1.23 + lib_so = $(soname).$(abimin) 1.24 + shared = -shared -Wl,-soname=$(soname) 1.25 + pic = -fPIC 1.26 +endif 1.27 + 1.28 + 1.29 +$(lib_so): $(obj) 1.30 + $(CC) -o $@ $(shared) $(obj) $(LDFLAGS) 1.31 + 1.32 +-include $(dep) 1.33 + 1.34 +%.d: %.c 1.35 + @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ 1.36 + 1.37 +.PHONY: clean 1.38 +clean: 1.39 + rm -f $(obj) $(bin) $(lib_so) $(lib_a) $(dep) 1.40 + 1.41 +.PHONY: install 1.42 +install: $(lib_so) 1.43 + mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib 1.44 + cp include/$(hdr) $(DESTDIR)$(PREFIX)/include/$(hdr) 1.45 + cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so) 1.46 + [ -n "$(soname)" ] \ 1.47 + && cd $(DESTDIR)$(PREFIX)/lib \ 1.48 + && rm -f $(soname) $(devlink) \ 1.49 + && ln -s $(lib_so) $(soname) \ 1.50 + && ln -s $(soname) $(devlink) \ 1.51 + || true 1.52 + 1.53 +.PHONY: uninstall 1.54 +uninstall: 1.55 + rm -f $(DESTDIR)$(PREFIX)/include/$(hdr) 1.56 + rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so) 1.57 + [ -n "$(soname)" ] \ 1.58 + && rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) \ 1.59 + && rm -f $(DESTDIR)$(PREFIX)/lib/$(devlink) \ 1.60 + || true