gamesnd

view Makefile @ 0:14e265e1cad8

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