liboptcfg
annotate 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 |
rev | line source |
---|---|
nuclear@1 | 1 # installation prefix, change it to install elsewhere |
nuclear@1 | 2 PREFIX = /usr/local |
nuclear@1 | 3 # ----------------------------- |
nuclear@1 | 4 |
nuclear@0 | 5 src = $(wildcard src/*.c) |
nuclear@0 | 6 obj = $(src:.c=.o) |
nuclear@0 | 7 name = optcfg |
nuclear@0 | 8 |
nuclear@0 | 9 so_major = 0 |
nuclear@0 | 10 so_minor = 1 |
nuclear@0 | 11 |
nuclear@0 | 12 alib = lib$(name).a |
nuclear@0 | 13 |
nuclear@0 | 14 CFLAGS = -pedantic -Wall -g |
nuclear@0 | 15 |
nuclear@0 | 16 sys := $(shell uname -s) |
nuclear@0 | 17 ifeq ($(sys), Darwin) |
nuclear@0 | 18 solib = lib$(name).dylib |
nuclear@0 | 19 shared = -dynamiclib |
nuclear@0 | 20 else |
nuclear@0 | 21 ldname = lib$(name).so |
nuclear@0 | 22 soname = lib$(name).so.$(so_major) |
nuclear@0 | 23 solib = lib$(name).so.$(so_major).$(so_minor) |
nuclear@0 | 24 shared = -shared -Wl,-soname=$(soname) |
nuclear@0 | 25 CFLAGS += -fPIC |
nuclear@0 | 26 endif |
nuclear@0 | 27 |
nuclear@0 | 28 .PHONY: all |
nuclear@0 | 29 all: $(solib) $(alib) |
nuclear@0 | 30 |
nuclear@0 | 31 $(solib): $(obj) |
nuclear@0 | 32 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS) |
nuclear@0 | 33 |
nuclear@0 | 34 $(alib): $(obj) |
nuclear@0 | 35 $(AR) rcs $@ $(obj) |
nuclear@0 | 36 |
nuclear@0 | 37 .PHONY: clean |
nuclear@0 | 38 clean: |
nuclear@0 | 39 rm -f $(obj) $(alib) $(solib) |
nuclear@0 | 40 |
nuclear@0 | 41 .PHONY: install |
nuclear@0 | 42 install: |
nuclear@0 | 43 mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib |
nuclear@0 | 44 cp src/optcfg.h $(DESTDIR)$(PREFIX)/include/optcfg.h |
nuclear@0 | 45 cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib) |
nuclear@0 | 46 cp $(solib) $(DESTDIR)$(PREFIX)/lib/$(solib) |
nuclear@0 | 47 [ -n "$(soname)" ] && cd $(DESTDIR)$(PREFIX)/lib && \ |
nuclear@1 | 48 rm -f $(soname) $(ldname) && \ |
nuclear@0 | 49 ln -s $(solib) $(soname) && \ |
nuclear@0 | 50 ln -s $(soname) $(ldname) || true |
nuclear@0 | 51 |
nuclear@0 | 52 .PHONY: uninstall |
nuclear@0 | 53 uninstall: |
nuclear@0 | 54 rm -f $(DESTDIR)$(PREFIX)/include/optcfg.h |
nuclear@0 | 55 rm -f $(DESTDIR)$(PREFIX)/lib/$(alib) |
nuclear@0 | 56 rm -f $(DESTDIR)$(PREFIX)/lib/$(solib) |
nuclear@0 | 57 [ -n "$(soname)" ] && \ |
nuclear@0 | 58 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \ |
nuclear@0 | 59 rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || true |