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