packio-simple
view Makefile @ 0:d81c3ae262a0
initial commit
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Sun, 09 Sep 2012 06:05:11 +0300 |
parents | |
children |
line source
1 src = $(wildcard src/*.c)
2 hdr = packio.h
3 obj = $(src:.c=.o)
4 dep = $(obj:.o=.d)
5 name = packio
6 lib_a = lib$(name).a
8 abimaj = 0
9 abimin = 1
11 CFLAGS = -pedantic -Wall $(pic) $(dbg) $(opt)
12 LDFLAGS = $(libs)
14 ifeq ($(shell uname -s), Darwin)
15 lib_so = lib$(name).dylib
16 shared = -dynamiclib
17 else
18 devlink = lib$(name).so
19 soname = $(devlink).$(abimaj)
20 lib_so = $(soname).$(abimin)
21 shared = -shared -Wl,-soname=$(soname)
22 pic = -fPIC
23 endif
26 $(lib_so): $(obj)
27 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
29 -include $(dep)
31 %.d: %.c
32 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
34 .PHONY: clean
35 clean:
36 rm -f $(obj) $(bin) $(lib_so) $(lib_a) $(dep)
38 .PHONY: install
39 install: $(lib_so)
40 mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
41 cp include/$(hdr) $(DESTDIR)$(PREFIX)/include/$(hdr)
42 cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so)
43 [ -n "$(soname)" ] \
44 && cd $(DESTDIR)$(PREFIX)/lib \
45 && rm -f $(soname) $(devlink) \
46 && ln -s $(lib_so) $(soname) \
47 && ln -s $(soname) $(devlink) \
48 || true
50 .PHONY: uninstall
51 uninstall:
52 rm -f $(DESTDIR)$(PREFIX)/include/$(hdr)
53 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so)
54 [ -n "$(soname)" ] \
55 && rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) \
56 && rm -f $(DESTDIR)$(PREFIX)/lib/$(devlink) \
57 || true