metasurf
view Makefile.in @ 4:2c575855f707
added simple example
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 25 Oct 2011 23:21:32 +0300 |
parents | 7aa4627e492b |
children | dedd153d2ceb |
line source
1 src = $(wildcard src/*.c)
2 obj = $(src:.c=.o)
3 dep = $(obj:.o=.d)
5 hdr = metasurf.h
7 name = metasurf
8 lib_a = lib$(name).a
9 somajor = 0
10 sominor = 1
12 ifeq ($(shell uname -s), Darwin)
13 lib_so = $(name).dylib
14 shared = -dynamiclib
15 else
16 devlink = lib$(name).so
17 soname = $(devlink).$(somajor)
18 lib_so = $(soname).$(sominor)
19 shared = -shared -Wl,-soname=$(soname)
20 pic = -fPIC
21 endif
23 CC = gcc
24 AR = ar
25 CFLAGS = -pedantic -Wall $(dbg) $(opt) $(pic)
27 .PHONY: all
28 all: $(lib_so) $(lib_a)
30 $(lib_so): $(obj)
31 $(CC) -o $@ $(shared) $(LDFLAGS)
33 $(lib_a): $(obj)
34 $(AR) rcs $@ $(obj)
36 -include $(dep)
38 %.d: %.c
39 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
41 .PHONY: clean
42 clean:
43 rm -f $(obj) $(lib_a) $(lib_so) $(dep)
45 .PHONY: cleandep
46 cleandep:
47 rm -f $(dep)
49 .PHONY: install
50 install:
51 mkdir -p $(PREFIX)/include $(PREFIX)/lib
52 cp src/$(hdr) $(PREFIX)/include/$(hdr)
53 cp $(lib_so) $(PREFIX)/lib/$(lib_so)
54 [ -n "$(soname)" ] \
55 && rm -f $(PREFIX)/lib/$(soname) $(PREFIX)/lib/$(devlink) \
56 && ln -s $(PREFIX)/lib/$(lib_so) $(PREFIX)/lib/$(soname) \
57 && ln -s $(PREFIX)/lib/$(soname) $(PREFIX)/lib/$(devlink) \
58 || true
60 .PHONY: uninstall
61 uninstall:
62 rm -f $(PREFIX)/include/$(hdr)
63 rm -f $(PREFIX)/lib/$(lib_so)
64 [ -n "$(soname)" ] \
65 && rm -f $(PREFIX)/lib/$(soname) $(PREFIX)/lib/$(devlink) \
66 || true