goat3dgfx

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