libsysutils
view Makefile @ 1:c1323f9f202d
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 05 May 2015 05:51:56 +0300 |
parents | a8277d8f687a |
children |
line source
1 PREFIX ?= /usr/local
3 src = $(wildcard src/*.c)
4 obj = $(src:.c=.o)
5 name = sysutils
6 lib_a = lib$(name).a
8 so_major = 0
9 so_minor = 1
11 sys = $(shell uname -s | sed 's/MINGW32.*/Win32/')
13 ifeq ($(sys), Darwin)
14 lib_so = lib$(name).dylib
15 shared = -dynamiclib
16 else ifeq ($(sys), Win32)
17 lib_so = $(name).dll
18 # TODO shared = ?
19 else # any other unix
20 ldname = lib$(name).so
21 soname = lib$(name).so.$(so_major)
22 lib_so = lib$(name).so.$(so_major).$(so_minor)
23 shared = -shared -Wl,-soname=$(soname)
24 pic = -fPIC
25 endif
27 inc = -Iinclude -Isrc
29 CFLAGS = -pedantic -Wall -g $(pic) $(inc)
31 .PHONY: all
32 all: $(lib_so) $(lib_a)
34 $(lib_a): $(obj)
35 $(AR) rcs $@ $(obj)
37 $(lib_so): $(obj)
38 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
40 .PHONY: clean
41 clean:
42 rm -f $(obj) $(lib_a) $(lib_so)
44 .PHONY: install
45 install: all
46 mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
47 @echo 'add header files'
48 cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a)
49 cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so)
50 [ -n "$(soname)" ] && \
51 cd $(DESTDIR)$(PREFIX) && \
52 rm -f $(soname) $(ldname) && \
53 ln -s $(lib_so) $(soname) && \
54 ln -s $(soname) $(ldname) || true
56 .PHONY: uninstall
57 uninstall:
58 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a)
59 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so)
60 [ -n "$(soname)" ] && \
61 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
62 rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || \
63 true