liboptcfg

view Makefile @ 0:10b89befcaa9

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 13 Nov 2015 23:48:31 +0200
parents
children 8fd2858c6a29
line source
1 src = $(wildcard src/*.c)
2 obj = $(src:.c=.o)
3 name = optcfg
5 so_major = 0
6 so_minor = 1
8 alib = lib$(name).a
10 CFLAGS = -pedantic -Wall -g
12 sys := $(shell uname -s)
13 ifeq ($(sys), Darwin)
14 solib = lib$(name).dylib
15 shared = -dynamiclib
16 else
17 ldname = lib$(name).so
18 soname = lib$(name).so.$(so_major)
19 solib = lib$(name).so.$(so_major).$(so_minor)
20 shared = -shared -Wl,-soname=$(soname)
21 CFLAGS += -fPIC
22 endif
24 .PHONY: all
25 all: $(solib) $(alib)
27 $(solib): $(obj)
28 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
30 $(alib): $(obj)
31 $(AR) rcs $@ $(obj)
33 .PHONY: clean
34 clean:
35 rm -f $(obj) $(alib) $(solib)
37 .PHONY: install
38 install:
39 mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
40 cp src/optcfg.h $(DESTDIR)$(PREFIX)/include/optcfg.h
41 cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib)
42 cp $(solib) $(DESTDIR)$(PREFIX)/lib/$(solib)
43 [ -n "$(soname)" ] && cd $(DESTDIR)$(PREFIX)/lib && \
44 ln -s $(solib) $(soname) && \
45 ln -s $(soname) $(ldname) || true
47 .PHONY: uninstall
48 uninstall:
49 rm -f $(DESTDIR)$(PREFIX)/include/optcfg.h
50 rm -f $(DESTDIR)$(PREFIX)/lib/$(alib)
51 rm -f $(DESTDIR)$(PREFIX)/lib/$(solib)
52 [ -n "$(soname)" ] && \
53 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
54 rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || true