dsys2

diff 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 diff
     1.1 --- a/Makefile	Mon Sep 05 03:05:24 2011 +0300
     1.2 +++ b/Makefile	Mon Sep 05 04:08:40 2011 +0300
     1.3 @@ -4,11 +4,29 @@
     1.4  obj = $(src:.c=.o)
     1.5  dep = $(obj:.o=.d)
     1.6  
     1.7 -lib_a = libdsys2.a
     1.8 +lib_a = libdsys.a
     1.9 +soname = libdsys.so.$(somajor)
    1.10 +lib_so = $(lib_so_$(sys))
    1.11 +
    1.12 +somajor = 0
    1.13 +sominor = 0
    1.14 +
    1.15 +lib_so_unix = $(soname).$(sominor)
    1.16 +lib_so_mac = libdsys.dylib
    1.17 +
    1.18 +sharedopt_unix = -shared -Wl,-soname,$(soname)
    1.19 +sharedopt_mac = -dynamiclib
    1.20 +
    1.21 +ifeq ($(shell uname -s), Darwin)
    1.22 +	sys = mac
    1.23 +else
    1.24 +	sys = unix
    1.25 +endif
    1.26 +
    1.27  
    1.28  CC = gcc
    1.29  AR = ar
    1.30 -CFLAGS = -pedantic -Wall -g -Isrc
    1.31 +CFLAGS = -pedantic -Wall -g -Isrc -fPIC
    1.32  
    1.33  ifeq ($(shell uname -s), Darwin)
    1.34  	libgl = -framework OpenGL -framework GLUT
    1.35 @@ -16,12 +34,15 @@
    1.36  	libgl = -lGL -lGLU -lglut
    1.37  endif
    1.38  
    1.39 -test: test.o $(lib_a)
    1.40 +test: test.o $(lib_a) $(lib_so)
    1.41  	$(CC) $(CFLAGS) -o $@ test.o $(lib_a) $(libgl) -lm
    1.42  
    1.43  $(lib_a): $(obj)
    1.44  	$(AR) rcs $@ $(obj)
    1.45  
    1.46 +$(lib_so): $(obj)
    1.47 +	$(CC) $(sharedopt_$(sys)) -o $@ $(obj) $(LDFLAGS)
    1.48 +
    1.49  -include $(dep)
    1.50  
    1.51  %.d: %.c
    1.52 @@ -29,7 +50,7 @@
    1.53  
    1.54  .PHONY: clean
    1.55  clean:
    1.56 -	rm -f $(obj) $(bin)
    1.57 +	rm -f $(obj) $(bin) $(lib_a) $(lib_so)
    1.58  
    1.59  .PHONY: cleandep
    1.60  cleandep:
    1.61 @@ -39,8 +60,9 @@
    1.62  install: $(lib_a)
    1.63  	mkdir -p $(PREFIX)/include $(PREFIX)/lib
    1.64  	cp $(lib_a) $(PREFIX)/lib/$(lib_a)
    1.65 -	cp src/dsys2.h $(PREFIX)/include/dsys2.h
    1.66 +	cp $(lib_so) $(PREFIX)/lib/$(lib_so)
    1.67 +	cp src/dsys.h $(PREFIX)/include/dsys.h
    1.68  
    1.69  .PHONY: uninstall
    1.70  uninstall:
    1.71 -	rm -f $(PREFIX)/include/dsys2.h $(PREFIX)/lib/$(lib_a)
    1.72 +	rm -f $(PREFIX)/include/dsys.h $(PREFIX)/lib/$(lib_a) $(PREFIX)/lib/$(lib_so)