libresman
annotate Makefile @ 4:eadf99551730
ok *now* I really fixed the aspect issue
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 31 Jan 2014 16:32:02 +0200 |
parents | |
children | bd9b4ff19c93 |
rev | line source |
---|---|
nuclear@0 | 1 # change this if you want to install elsewhere |
nuclear@0 | 2 PREFIX = /usr/local |
nuclear@0 | 3 |
nuclear@0 | 4 src = $(wildcard src/*.c) |
nuclear@0 | 5 obj = $(src:.c=.o) |
nuclear@0 | 6 dep = $(obj:.o=.d) |
nuclear@0 | 7 |
nuclear@0 | 8 name = resman |
nuclear@0 | 9 lib_a = lib$(name).a |
nuclear@0 | 10 |
nuclear@0 | 11 api_major = 0 |
nuclear@0 | 12 api_minor = 1 |
nuclear@0 | 13 |
nuclear@0 | 14 CFLAGS = -pedantic -Wall -g |
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 = lib$(name).so.$(api_major) |
nuclear@0 | 22 lib_so = lib$(name).so.$(api_major).$(api_minor) |
nuclear@0 | 23 shared = -shared -Wl,-soname,$(soname) |
nuclear@0 | 24 pic = -fPIC |
nuclear@0 | 25 endif |
nuclear@0 | 26 |
nuclear@0 | 27 .PHONY: all |
nuclear@0 | 28 all: $(lib_so) $(lib_a) |
nuclear@0 | 29 |
nuclear@0 | 30 $(lib_so): $(obj) |
nuclear@0 | 31 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS) |
nuclear@0 | 32 |
nuclear@0 | 33 $(lib_a): $(obj) |
nuclear@0 | 34 $(AR) rcs $@ $(obj) |
nuclear@0 | 35 |
nuclear@0 | 36 -include $(dep) |
nuclear@0 | 37 |
nuclear@0 | 38 %.d: %.c |
nuclear@0 | 39 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ |
nuclear@0 | 40 |
nuclear@0 | 41 .PHONY: clean |
nuclear@0 | 42 clean: |
nuclear@0 | 43 rm -f $(obj) $(lib_so) $(lib_a) |
nuclear@0 | 44 |
nuclear@0 | 45 .PHONY: install |
nuclear@0 | 46 install: $(lib_a) $(lib_so) |
nuclear@0 | 47 mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include |
nuclear@0 | 48 cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a) |
nuclear@0 | 49 cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so) |
nuclear@0 | 50 [ -n "$(devlink)" ] \ |
nuclear@0 | 51 && cd $(DESTDIR)$(PREFIX)/lib \ |
nuclear@0 | 52 && rm -f $(soname) $(devlink) \ |
nuclear@0 | 53 && ln -s $(lib_so) $(soname) \ |
nuclear@0 | 54 && ln -s $(soname) $(devlink) \ |
nuclear@0 | 55 || true |
nuclear@0 | 56 cp src/resman.h $(DESTDIR)$(PREFIX)/include/resman.h |
nuclear@0 | 57 |
nuclear@0 | 58 .PHONY: uninstall |
nuclear@0 | 59 uninstall: |
nuclear@0 | 60 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a) |
nuclear@0 | 61 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so) |
nuclear@0 | 62 rm -f $(DESTDIR)$(PREFIX)/include/resman.h |