libresman

annotate Makefile @ 22:174ddb6bf92a

separated platform-specific filewatch code
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 12 Feb 2014 22:32:30 +0200
parents 61d7ff6da54b
children
rev   line source
nuclear@0 1 # change this if you want to install elsewhere
nuclear@0 2 PREFIX = /usr/local
nuclear@0 3
nuclear@0 4 src = $(wildcard src/*.c)
nuclear@0 5 obj = $(src:.c=.o)
nuclear@0 6 dep = $(obj:.o=.d)
nuclear@0 7
nuclear@0 8 name = resman
nuclear@0 9 lib_a = lib$(name).a
nuclear@0 10
nuclear@0 11 api_major = 0
nuclear@0 12 api_minor = 1
nuclear@0 13
nuclear@5 14 dbg = -g
nuclear@5 15
nuclear@5 16 CFLAGS = -pedantic -Wall $(dbg) $(opt) $(pic)
nuclear@0 17
nuclear@0 18 ifeq ($(shell uname -s), Darwin)
nuclear@0 19 lib_so = lib$(name).dylib
nuclear@0 20 shared = -dynamiclib
nuclear@0 21 else
nuclear@0 22 devlink = lib$(name).so
nuclear@0 23 soname = lib$(name).so.$(api_major)
nuclear@0 24 lib_so = lib$(name).so.$(api_major).$(api_minor)
nuclear@0 25 shared = -shared -Wl,-soname,$(soname)
nuclear@0 26 pic = -fPIC
nuclear@0 27 endif
nuclear@0 28
nuclear@0 29 .PHONY: all
nuclear@0 30 all: $(lib_so) $(lib_a)
nuclear@0 31
nuclear@0 32 $(lib_so): $(obj)
nuclear@0 33 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
nuclear@0 34
nuclear@0 35 $(lib_a): $(obj)
nuclear@0 36 $(AR) rcs $@ $(obj)
nuclear@0 37
nuclear@0 38 -include $(dep)
nuclear@0 39
nuclear@0 40 %.d: %.c
nuclear@0 41 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
nuclear@0 42
nuclear@0 43 .PHONY: clean
nuclear@0 44 clean:
nuclear@0 45 rm -f $(obj) $(lib_so) $(lib_a)
nuclear@0 46
nuclear@0 47 .PHONY: install
nuclear@0 48 install: $(lib_a) $(lib_so)
nuclear@0 49 mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include
nuclear@0 50 cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a)
nuclear@0 51 cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so)
nuclear@0 52 [ -n "$(devlink)" ] \
nuclear@0 53 && cd $(DESTDIR)$(PREFIX)/lib \
nuclear@0 54 && rm -f $(soname) $(devlink) \
nuclear@0 55 && ln -s $(lib_so) $(soname) \
nuclear@0 56 && ln -s $(soname) $(devlink) \
nuclear@0 57 || true
nuclear@0 58 cp src/resman.h $(DESTDIR)$(PREFIX)/include/resman.h
nuclear@0 59
nuclear@0 60 .PHONY: uninstall
nuclear@0 61 uninstall:
nuclear@0 62 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a)
nuclear@0 63 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so)
nuclear@0 64 rm -f $(DESTDIR)$(PREFIX)/include/resman.h