liboptcfg
view Makefile @ 1:8fd2858c6a29
example (test) program
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 14 Nov 2015 14:12:30 +0200 |
parents | 10b89befcaa9 |
children | aca7267dfee0 |
line source
1 # installation prefix, change it to install elsewhere
2 PREFIX = /usr/local
3 # -----------------------------
5 src = $(wildcard src/*.c)
6 obj = $(src:.c=.o)
7 name = optcfg
9 so_major = 0
10 so_minor = 1
12 alib = lib$(name).a
14 CFLAGS = -pedantic -Wall -g
16 sys := $(shell uname -s)
17 ifeq ($(sys), Darwin)
18 solib = lib$(name).dylib
19 shared = -dynamiclib
20 else
21 ldname = lib$(name).so
22 soname = lib$(name).so.$(so_major)
23 solib = lib$(name).so.$(so_major).$(so_minor)
24 shared = -shared -Wl,-soname=$(soname)
25 CFLAGS += -fPIC
26 endif
28 .PHONY: all
29 all: $(solib) $(alib)
31 $(solib): $(obj)
32 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
34 $(alib): $(obj)
35 $(AR) rcs $@ $(obj)
37 .PHONY: clean
38 clean:
39 rm -f $(obj) $(alib) $(solib)
41 .PHONY: install
42 install:
43 mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
44 cp src/optcfg.h $(DESTDIR)$(PREFIX)/include/optcfg.h
45 cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib)
46 cp $(solib) $(DESTDIR)$(PREFIX)/lib/$(solib)
47 [ -n "$(soname)" ] && cd $(DESTDIR)$(PREFIX)/lib && \
48 rm -f $(soname) $(ldname) && \
49 ln -s $(solib) $(soname) && \
50 ln -s $(soname) $(ldname) || true
52 .PHONY: uninstall
53 uninstall:
54 rm -f $(DESTDIR)$(PREFIX)/include/optcfg.h
55 rm -f $(DESTDIR)$(PREFIX)/lib/$(alib)
56 rm -f $(DESTDIR)$(PREFIX)/lib/$(solib)
57 [ -n "$(soname)" ] && \
58 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
59 rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || true