scenefile

view Makefile @ 0:8c6d64af9505

scenefile
author John Tsiombikas <nuclear@mutantstargoat.com>
date Fri, 13 Jan 2012 09:34:16 +0200
parents
children
line source
1 PREFIX = /usr/local
3 src = $(wildcard src/*.c)
4 obj = $(src:.c=.o)
5 dep = $(obj:.o=.d)
7 name = scenefile
8 lib_a = lib$(name).a
10 dbg = -g
11 #opt = -O3
13 ifeq ($(shell uname -s), Darwin)
14 lib_so = $(name).dylib
15 shared = -dynamiclib
16 else
17 abi = 0
18 rev = 0
19 devlink = lib$(name).so
20 soname = $(devlink).$(abi)
21 lib_so = $(soname).$(rev)
22 shared = -shared -Wl,-soname=$(soname)
23 pic = -fPIC
24 endif
26 CFLAGS = -pedantic -Wall $(dbg) $(opt) $(pic)
28 .PHONY: all
29 all: $(lib_so) $(lib_a)
31 $(lib_so): $(obj)
32 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
34 $(lib_a): $(obj)
35 $(AR) rcs $@ $(obj)
37 -include $(dep)
39 %.d: %.c
40 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
42 .PHONY: clean
43 clean:
44 rm -f $(obj) $(lib_so) $(lib_a)
46 .PHONY: install
47 install: $(lib_so) $(lib_a)
48 mkdir -p $(INSTDIR)$(PREFIX)/lib $(INSTDIR)$(PREFIX)/include
49 cp $(lib_a) $(INSTDIR)$(PREFIX)/lib/$(lib_a)
50 cp $(lib_so) $(INSTDIR)$(PREFIX)/lib/$(lib_so)
51 [ -n "$(soname)" ] && cd $(INSTDIR)$(PREFIX)/lib \
52 && ln -s $(lib_so) $(soname) \
53 && ln -s $(soname) $(devlink) \
54 || true
56 .PHONY: uninstall
57 uninstall:
58 rm -f $(INSTDIR)$(PREFIX)/lib/$(lib_a) $(INSTDIR)$(PREFIX)/lib/$(lib_so)
59 [ -n "$(soname)" ] \
60 && rm -f $(INSTDIR)$(PREFIX)/lib/$(soname) \
61 && rm -f $(INSTDIR)$(PREFIX)/lib/$(devlink) \
62 || true