gamesnd

annotate Makefile @ 0:14e265e1cad8

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