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