scenefile

diff Makefile @ 0:8c6d64af9505

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