libsysutils
annotate Makefile @ 0:a8277d8f687a
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 19 Feb 2015 01:33:54 +0200 |
parents | |
children | c1323f9f202d |
rev | line source |
---|---|
nuclear@0 | 1 src = $(wildcard src/*.c) |
nuclear@0 | 2 obj = $(src:.c=.o) |
nuclear@0 | 3 name = sysutils |
nuclear@0 | 4 lib_a = lib$(name).a |
nuclear@0 | 5 |
nuclear@0 | 6 so_major = 0 |
nuclear@0 | 7 so_minor = 1 |
nuclear@0 | 8 |
nuclear@0 | 9 sys = $(shell uname -s | sed 's/MINGW32.*/Win32/') |
nuclear@0 | 10 |
nuclear@0 | 11 ifeq ($(sys), Darwin) |
nuclear@0 | 12 lib_so = lib$(name).dylib |
nuclear@0 | 13 shared = -dynamiclib |
nuclear@0 | 14 else ($(sys), Win32) |
nuclear@0 | 15 lib_so = $(name).dll |
nuclear@0 | 16 # TODO shared = ? |
nuclear@0 | 17 else # any other unix |
nuclear@0 | 18 ldname = lib$(name).so |
nuclear@0 | 19 soname = lib$(name).so.$(so_major) |
nuclear@0 | 20 lib_so = lib$(name).so.$(so_major).$(so_minor) |
nuclear@0 | 21 shared = -shared -Wl,-soname=$(soname) |
nuclear@0 | 22 pic = -fPIC |
nuclear@0 | 23 endif |
nuclear@0 | 24 |
nuclear@0 | 25 .PHONY: all |
nuclear@0 | 26 all: $(lib_so) $(lib_a) |
nuclear@0 | 27 |
nuclear@0 | 28 $(lib_a): $(obj) |
nuclear@0 | 29 $(AR) rcs $@ $(obj) |
nuclear@0 | 30 |
nuclear@0 | 31 $(lib_so): $(obj) |
nuclear@0 | 32 $(CC) -o $@ $(obj) $(LDFLAGS) |
nuclear@0 | 33 |
nuclear@0 | 34 .PHONY: clean |
nuclear@0 | 35 clean: |
nuclear@0 | 36 rm -f $(obj) $(lib_a) $(lib_so) |
nuclear@0 | 37 |
nuclear@0 | 38 .PHONY: install |
nuclear@0 | 39 install: all |
nuclear@0 | 40 mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib |
nuclear@0 | 41 @echo 'add header files' |
nuclear@0 | 42 cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a) |
nuclear@0 | 43 cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so) |
nuclear@0 | 44 [ -n "$(soname)" ] && \ |
nuclear@0 | 45 cd $(DESTDIR)$(PREFIX) && \ |
nuclear@0 | 46 rm -f $(soname) $(ldname) && \ |
nuclear@0 | 47 ln -s $(lib_so) $(soname) && \ |
nuclear@0 | 48 ln -s $(soname) $(ldname) || true |
nuclear@0 | 49 |
nuclear@0 | 50 .PHONY: uninstall |
nuclear@0 | 51 uninstall: |
nuclear@0 | 52 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a) |
nuclear@0 | 53 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so) |
nuclear@0 | 54 [ -n "$(soname)" ] && \ |
nuclear@0 | 55 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \ |
nuclear@0 | 56 rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || \ |
nuclear@0 | 57 true |