smflite

annotate Makefile @ 2:d9e0d0500a78

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