goat3dgfx

view Makefile @ 8:98f87a1dbb2f

added COPYING and README
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 18 Nov 2013 03:35:20 +0200
parents 1873dfd13f2d
children 25b911c7c35c
line source
1 PREFIX = /usr/local
3 csrc = $(wildcard src/*.c)
4 ccsrc = $(wildcard src/*.cc)
5 obj = $(csrc:.c=.o) $(ccsrc:.cc=.o)
6 dep = $(obj:.o=.d)
7 name = goat3dgfx
8 lib_a = lib$(name).a
10 so_major = 0
11 so_minor = 1
13 ifeq ($(shell uname -r), Darwin)
14 libgl = -framework OpenGL -framework GLUT -lGLEW
16 lib_so = lib$(name).dylib
17 shared = -dynamiclib
18 else
19 libgl = -lGL -lGLU -lglut -lGLEW
21 lib_so = lib$(name).so.$(so_major).$(so_minor)
22 soname = lib$(name).so.$(so_major)
23 devlink = lib$(name).so
24 shared = -shared -Wl,-soname=$(soname)
25 pic = -fPIC
26 endif
28 dbg = -g
29 warn = -Wall
31 CFLAGS = -pedantic $(warn) $(dbg) $(pic) $(opt) $(inc) $(libs_cflags)
32 CXXFLAGS = $(CFLAGS)
33 LDFLAGS = $(libgl) $(libs_ldflags)
35 .PHONY: all
36 all: $(lib_so) $(lib_a)
38 $(lib_a): $(obj)
39 $(AR) rcs $@ $(obj)
41 $(lib_so): $(obj)
42 $(CXX) $(shared) -o $@ $(obj) $(LDFLAGS)
44 -include $(dep)
46 %.d: %.c
47 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
49 %.d: %.cc
50 @$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@
52 .PHONY: clean
53 clean:
54 rm -f $(obj) $(lib_a) $(lib_so)
56 .PHONY: cleandep
57 cleandep:
58 rm -f $(dep)
60 .PHONY: install
61 install: $(lib_so) $(lib_a)
62 mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include/goat3dgfx
63 cp src/*.h src/*.inl $(DESTDIR)$(PREFIX)/include/goat3dgfx/
64 cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a)
65 cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so)
66 [ -n "$(devlink)" ] && \
67 cd $(DESTDIR)$(PREFIX)/lib && \
68 rm -f $(soname) $(devlink) && \
69 ln -s $(lib_so) $(soname) && \
70 ln -s $(soname) $(devlink) || \
71 true
73 .PHONY: uninstall
74 uninstall:
75 rm -f $(DESTDIR)$(PREFIX)/include/goat3dgfx/*
76 rmdir $(DESTDIR)$(PREFIX)/include/goat3dgfx
77 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so)
78 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a)
79 [ -n "$(devlink)" ] && \
80 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
81 rm -f $(DESTDIR)$(PREFIX)/lib/$(devlink) || \
82 true