gamesnd

diff Makefile @ 0:14e265e1cad8

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