libsysutils

view Makefile @ 0:a8277d8f687a

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