dsys2

annotate 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
rev   line source
nuclear@10 1 PREFIX = /usr/local
nuclear@10 2
nuclear@0 3 src = $(wildcard src/*.c)
nuclear@0 4 obj = $(src:.c=.o)
nuclear@0 5 dep = $(obj:.o=.d)
nuclear@0 6
nuclear@13 7 lib_a = libdsys.a
nuclear@13 8 soname = libdsys.so.$(somajor)
nuclear@13 9 lib_so = $(lib_so_$(sys))
nuclear@13 10
nuclear@13 11 somajor = 0
nuclear@13 12 sominor = 0
nuclear@13 13
nuclear@13 14 lib_so_unix = $(soname).$(sominor)
nuclear@13 15 lib_so_mac = libdsys.dylib
nuclear@13 16
nuclear@13 17 sharedopt_unix = -shared -Wl,-soname,$(soname)
nuclear@13 18 sharedopt_mac = -dynamiclib
nuclear@13 19
nuclear@13 20 ifeq ($(shell uname -s), Darwin)
nuclear@13 21 sys = mac
nuclear@13 22 else
nuclear@13 23 sys = unix
nuclear@13 24 endif
nuclear@13 25
nuclear@0 26
nuclear@0 27 CC = gcc
nuclear@0 28 AR = ar
nuclear@13 29 CFLAGS = -pedantic -Wall -g -Isrc -fPIC
nuclear@2 30
nuclear@5 31 ifeq ($(shell uname -s), Darwin)
nuclear@5 32 libgl = -framework OpenGL -framework GLUT
nuclear@5 33 else
nuclear@5 34 libgl = -lGL -lGLU -lglut
nuclear@5 35 endif
nuclear@5 36
nuclear@13 37 test: test.o $(lib_a) $(lib_so)
nuclear@5 38 $(CC) $(CFLAGS) -o $@ test.o $(lib_a) $(libgl) -lm
nuclear@0 39
nuclear@0 40 $(lib_a): $(obj)
nuclear@0 41 $(AR) rcs $@ $(obj)
nuclear@0 42
nuclear@13 43 $(lib_so): $(obj)
nuclear@13 44 $(CC) $(sharedopt_$(sys)) -o $@ $(obj) $(LDFLAGS)
nuclear@13 45
nuclear@0 46 -include $(dep)
nuclear@0 47
nuclear@0 48 %.d: %.c
nuclear@0 49 @$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@
nuclear@0 50
nuclear@0 51 .PHONY: clean
nuclear@0 52 clean:
nuclear@13 53 rm -f $(obj) $(bin) $(lib_a) $(lib_so)
nuclear@0 54
nuclear@0 55 .PHONY: cleandep
nuclear@0 56 cleandep:
nuclear@0 57 rm -f $(dep)
nuclear@10 58
nuclear@10 59 .PHONY: install
nuclear@11 60 install: $(lib_a)
nuclear@10 61 mkdir -p $(PREFIX)/include $(PREFIX)/lib
nuclear@10 62 cp $(lib_a) $(PREFIX)/lib/$(lib_a)
nuclear@13 63 cp $(lib_so) $(PREFIX)/lib/$(lib_so)
nuclear@13 64 cp src/dsys.h $(PREFIX)/include/dsys.h
nuclear@10 65
nuclear@10 66 .PHONY: uninstall
nuclear@10 67 uninstall:
nuclear@13 68 rm -f $(PREFIX)/include/dsys.h $(PREFIX)/lib/$(lib_a) $(PREFIX)/lib/$(lib_so)