sgl

changeset 2:e55e71da991d

converting to configure/makefile.in
author John Tsiombikas <nuclear@siggraph.org>
date Wed, 11 May 2011 05:53:26 +0300
parents 0c13a30be2c1
children 1b6c5dadb460
files Makefile Makefile.in configure
diffstat 3 files changed, 83 insertions(+), 56 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Wed May 11 05:34:37 2011 +0300
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,56 +0,0 @@
     1.4 -src = $(wildcard src/*.c)
     1.5 -obj = $(src:.c=.o)
     1.6 -dep = $(src:.c=.d)
     1.7 -lib_a = libsgl.a
     1.8 -soname = libsgl.so.$(somajor)
     1.9 -lib_so = $(lib_so_$(sys))
    1.10 -
    1.11 -somajor = 0
    1.12 -sominor = 0
    1.13 -
    1.14 -lib_so_unix = $(soname).$(minor)
    1.15 -lib_so_mac = libsgl.dylib
    1.16 -
    1.17 -sharedopt_unix = -shared -Wl,-soname,$(soname)
    1.18 -sharedopt_mac = -dynamiclib
    1.19 -
    1.20 -ifeq ($(shell uname -a), Darwin)
    1.21 -	sys = mac
    1.22 -else
    1.23 -	sys = unix
    1.24 -endif
    1.25 -
    1.26 -AR = ar
    1.27 -CC = gcc
    1.28 -CFLAGS = -pedantic -Wall -g -fPIC -Iinclude -Isrc
    1.29 -
    1.30 -.PHONY: all
    1.31 -all: $(lib_so) $(lib_a)
    1.32 -
    1.33 -$(lib_a): $(obj)
    1.34 -	$(AR) rcs $@ $(obj)
    1.35 -
    1.36 -$(lib_so): $(obj)
    1.37 -	$(CC) $(sharedopt_$(sys)) -o $@ $(obj)
    1.38 -
    1.39 --include $(dep)
    1.40 -
    1.41 -%.d: %.c
    1.42 -	@$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@
    1.43 -
    1.44 -.PHONY: clean
    1.45 -clean:
    1.46 -	rm -f $(obj) $(dep) $(lib_so) $(lib_a)
    1.47 -
    1.48 -.PHONY: install
    1.49 -install:
    1.50 -	mkdir -p $(PREFIX)/include $(PREFIX)/lib
    1.51 -	cp $(lib_a) $(PREFIX)/lib/$(lib_a)
    1.52 -	cp $(lib_so) $(PREFIX)/lib/$(lib_so)
    1.53 -	cp include/sgl.h $(PREFIX)/include/sgl.h
    1.54 -
    1.55 -.PHONY: uninstall
    1.56 -uninstall:
    1.57 -	rm -f $(PREFIX)/lib/$(lib_a)
    1.58 -	rm -f $(PREFIX)/lib/$(lib_so)
    1.59 -	rm -f $(PREFIX)/include/sgl.h
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/Makefile.in	Wed May 11 05:53:26 2011 +0300
     2.3 @@ -0,0 +1,56 @@
     2.4 +src = $(wildcard src/*.c)
     2.5 +obj = $(src:.c=.o)
     2.6 +dep = $(src:.c=.d)
     2.7 +lib_a = libsgl.a
     2.8 +soname = libsgl.so.$(somajor)
     2.9 +lib_so = $(lib_so_$(sys))
    2.10 +
    2.11 +somajor = 0
    2.12 +sominor = 0
    2.13 +
    2.14 +lib_so_unix = $(soname).$(minor)
    2.15 +lib_so_mac = libsgl.dylib
    2.16 +
    2.17 +sharedopt_unix = -shared -Wl,-soname,$(soname)
    2.18 +sharedopt_mac = -dynamiclib
    2.19 +
    2.20 +ifeq ($(shell uname -a), Darwin)
    2.21 +	sys = mac
    2.22 +else
    2.23 +	sys = unix
    2.24 +endif
    2.25 +
    2.26 +AR = ar
    2.27 +CC = gcc
    2.28 +CFLAGS = -pedantic -Wall -g -fPIC -Iinclude -Isrc
    2.29 +
    2.30 +.PHONY: all
    2.31 +all: $(lib_so) $(lib_a)
    2.32 +
    2.33 +$(lib_a): $(obj)
    2.34 +	$(AR) rcs $@ $(obj)
    2.35 +
    2.36 +$(lib_so): $(obj)
    2.37 +	$(CC) $(sharedopt_$(sys)) -o $@ $(obj)
    2.38 +
    2.39 +-include $(dep)
    2.40 +
    2.41 +%.d: %.c
    2.42 +	@$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@
    2.43 +
    2.44 +.PHONY: clean
    2.45 +clean:
    2.46 +	rm -f $(obj) $(dep) $(lib_so) $(lib_a)
    2.47 +
    2.48 +.PHONY: install
    2.49 +install:
    2.50 +	mkdir -p $(PREFIX)/include $(PREFIX)/lib
    2.51 +	cp $(lib_a) $(PREFIX)/lib/$(lib_a)
    2.52 +	cp $(lib_so) $(PREFIX)/lib/$(lib_so)
    2.53 +	cp include/sgl.h $(PREFIX)/include/sgl.h
    2.54 +
    2.55 +.PHONY: uninstall
    2.56 +uninstall:
    2.57 +	rm -f $(PREFIX)/lib/$(lib_a)
    2.58 +	rm -f $(PREFIX)/lib/$(lib_so)
    2.59 +	rm -f $(PREFIX)/include/sgl.h
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/configure	Wed May 11 05:53:26 2011 +0300
     3.3 @@ -0,0 +1,27 @@
     3.4 +#!/bin/sh
     3.5 +
     3.6 +gen_module_init()
     3.7 +{
     3.8 +	# collect all src/wsys_whatever.c files
     3.9 +	modules=`ls src/wsys_*.c 2>/dev/null | sort | sed 's/src\/wsys_//' | sed 's/\.c//'`
    3.10 +
    3.11 +	echo "/* this file is generated by $0, do not edit */"
    3.12 +	for m in $modules; do
    3.13 +		echo "int sgl_register_$m();"
    3.14 +	done
    3.15 +
    3.16 +	echo
    3.17 +	echo 'void sgl_modules_init(void)'
    3.18 +	echo '{'
    3.19 +
    3.20 +	for m in $modules; do
    3.21 +		echo "	sgl_register_$m();"
    3.22 +	done
    3.23 +
    3.24 +	echo '}'
    3.25 +}
    3.26 +
    3.27 +gen_module_init >src/modules.c
    3.28 +
    3.29 +echo 'PREFIX = /usr/local' >Makefile
    3.30 +cat Makefile.in >>Makefile