libresman

view Makefile @ 1:469ce01809bc

rudimentary imgthumbs "example program". doesn't use libresman yet
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 31 Jan 2014 03:17:24 +0200
parents
children bd9b4ff19c93
line source
1 # change this if you want to install elsewhere
2 PREFIX = /usr/local
4 src = $(wildcard src/*.c)
5 obj = $(src:.c=.o)
6 dep = $(obj:.o=.d)
8 name = resman
9 lib_a = lib$(name).a
11 api_major = 0
12 api_minor = 1
14 CFLAGS = -pedantic -Wall -g
16 ifeq ($(shell uname -s), Darwin)
17 lib_so = lib$(name).dylib
18 shared = -dynamiclib
19 else
20 devlink = lib$(name).so
21 soname = lib$(name).so.$(api_major)
22 lib_so = lib$(name).so.$(api_major).$(api_minor)
23 shared = -shared -Wl,-soname,$(soname)
24 pic = -fPIC
25 endif
27 .PHONY: all
28 all: $(lib_so) $(lib_a)
30 $(lib_so): $(obj)
31 $(CC) -o $@ $(shared) $(obj) $(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_so) $(lib_a)
45 .PHONY: install
46 install: $(lib_a) $(lib_so)
47 mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include
48 cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a)
49 cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so)
50 [ -n "$(devlink)" ] \
51 && cd $(DESTDIR)$(PREFIX)/lib \
52 && rm -f $(soname) $(devlink) \
53 && ln -s $(lib_so) $(soname) \
54 && ln -s $(soname) $(devlink) \
55 || true
56 cp src/resman.h $(DESTDIR)$(PREFIX)/include/resman.h
58 .PHONY: uninstall
59 uninstall:
60 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a)
61 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so)
62 rm -f $(DESTDIR)$(PREFIX)/include/resman.h