dsys2

view Makefile @ 13:6bab2c0b0e4b

- added a shared library rule - changed all the names from dsys2 to dsys
author John Tsiombikas <nuclear@mutantstargoat.com>
date Mon, 05 Sep 2011 04:08:40 +0300
parents 65da828bc218
children
line source
1 PREFIX = /usr/local
3 src = $(wildcard src/*.c)
4 obj = $(src:.c=.o)
5 dep = $(obj:.o=.d)
7 lib_a = libdsys.a
8 soname = libdsys.so.$(somajor)
9 lib_so = $(lib_so_$(sys))
11 somajor = 0
12 sominor = 0
14 lib_so_unix = $(soname).$(sominor)
15 lib_so_mac = libdsys.dylib
17 sharedopt_unix = -shared -Wl,-soname,$(soname)
18 sharedopt_mac = -dynamiclib
20 ifeq ($(shell uname -s), Darwin)
21 sys = mac
22 else
23 sys = unix
24 endif
27 CC = gcc
28 AR = ar
29 CFLAGS = -pedantic -Wall -g -Isrc -fPIC
31 ifeq ($(shell uname -s), Darwin)
32 libgl = -framework OpenGL -framework GLUT
33 else
34 libgl = -lGL -lGLU -lglut
35 endif
37 test: test.o $(lib_a) $(lib_so)
38 $(CC) $(CFLAGS) -o $@ test.o $(lib_a) $(libgl) -lm
40 $(lib_a): $(obj)
41 $(AR) rcs $@ $(obj)
43 $(lib_so): $(obj)
44 $(CC) $(sharedopt_$(sys)) -o $@ $(obj) $(LDFLAGS)
46 -include $(dep)
48 %.d: %.c
49 @$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@
51 .PHONY: clean
52 clean:
53 rm -f $(obj) $(bin) $(lib_a) $(lib_so)
55 .PHONY: cleandep
56 cleandep:
57 rm -f $(dep)
59 .PHONY: install
60 install: $(lib_a)
61 mkdir -p $(PREFIX)/include $(PREFIX)/lib
62 cp $(lib_a) $(PREFIX)/lib/$(lib_a)
63 cp $(lib_so) $(PREFIX)/lib/$(lib_so)
64 cp src/dsys.h $(PREFIX)/include/dsys.h
66 .PHONY: uninstall
67 uninstall:
68 rm -f $(PREFIX)/include/dsys.h $(PREFIX)/lib/$(lib_a) $(PREFIX)/lib/$(lib_so)