smflite

view 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
line source
1 PREFIX = /usr/local
3 src = $(wildcard src/*.c)
4 obj = $(src:.c=.o)
5 dep = $(obj:.o=.d)
7 name = smflite
8 lib_a = lib$(name).a
10 ifeq ($(shell uname -s), Darwin)
11 lib_so = $(name).dylib
12 shared = -dynamiclib
13 else
14 abi = 0
15 rev = 0
16 devlink = lib$(name).so
17 soname = $(devlink).$(abi)
18 lib_so = $(soname).$(rev)
19 shared = -shared -Wl,-soname=$(soname)
20 pic = -fPIC
21 endif
23 CFLAGS = -pedantic -Wall -g $(pic)
25 .PHONY: all
26 all: $(lib_a) $(lib_so)
28 $(lib_so): $(obj)
29 $(CC) $(shared) -o $@ $(obj) $(LDFLAGS)
31 $(lib_a): $(obj)
32 $(AR) rcs $@ $(obj)
34 -include $(dep)
36 %.d: %.c
37 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
39 .PHONY: clean
40 clean:
41 rm -f $(obj) $(lib_so) $(lib_a)
43 .PHONY: install
44 install: $(lib_so) $(lib_a)
45 mkdir -p $(INSTDIR)$(PREFIX)/include $(INSTDIR)$(PREFIX)/lib
46 cp src/smf.h $(INSTDIR)$(PREFIX)/include/smf.h
47 cp $(lib_a) $(INSTDIR)$(PREFIX)/lib/$(lib_a)
48 cp $(lib_so) $(INSTDIR)$(PREFIX)/lib/$(lib_so)
49 [ -n "$(soname)" ] && \
50 cd $(INSTDIR)$(PREFIX)/lib && \
51 ln -s $(lib_so) $(soname) && \
52 ln -s $(soname) $(devlink) || true
54 .PHONY: uninstall
55 uninstall:
56 rm -f $(INSTDIR)$(PREFIX)/include/smf.h
57 rm -f $(INSTDIR)$(PREFIX)/lib/$(lib_a)
58 rm -f $(INSTDIR)$(PREFIX)/lib/$(lib_so)
59 [ -n "$(soname)" ] && \
60 rm -f $(INSTDIR)$(PREFIX)/lib/$(soname) && \
61 rm -f $(INSTDIR)$(PREFIX)/lib/$(devlink) || true