dungeon_crawler
changeset 28:f5fb04fe12cd
moved compiler detection to the configure script
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 25 Aug 2012 20:20:56 +0300 |
parents | cbf86e5198a9 |
children | 2fc004802739 |
files | prototype/Makefile prototype/Makefile.in prototype/configure |
diffstat | 3 files changed, 93 insertions(+), 40 deletions(-) [+] |
line diff
1.1 --- a/prototype/Makefile Sat Aug 25 14:37:51 2012 +0300 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,40 +0,0 @@ 1.4 -csrc = $(wildcard src/*.c) $(wildcard vmath/*.c) $(wildcard drawtext/*.c) 1.5 -ccsrc = $(wildcard src/*.cc) $(wildcard vmath/*.cc) 1.6 -obj = $(csrc:.c=.o) $(ccsrc:.cc=.o) 1.7 -dep = $(obj:.o=.d) 1.8 -bin = proto 1.9 - 1.10 -#opt = -O3 1.11 -dbg = -g 1.12 -warn = -Wall -Wno-format-extra-args -Wno-char-subscripts 1.13 - 1.14 -inc = -Ivmath -Idrawtext `pkg-config --cflags freetype2` 1.15 - 1.16 -CFLAGS = -pedantic $(warn) $(dbg) $(opt) $(inc) 1.17 -CXXFLAGS = $(CFLAGS) -std=c++11 $(add_cxxflags) 1.18 -LDFLAGS = $(add_ldflags) $(libgl) -lm -lassimp -limago `pkg-config --libs freetype2` 1.19 - 1.20 -ifeq ($(shell uname -s), Darwin) 1.21 - add_cxxflags = -stdlib=libc++ 1.22 - add_ldflags = -stdlib=libc++ 1.23 - libgl = -framework OpenGL -framework GLUT -lglew 1.24 -else 1.25 - libgl = -lGL -lGLU -lglut -lGLEW 1.26 -endif 1.27 - 1.28 -$(bin): $(obj) Makefile 1.29 - $(CXX) -o $@ $(obj) $(LDFLAGS) 1.30 - 1.31 --include $(dep) 1.32 - 1.33 -%.d: %.c 1.34 - @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ 1.35 - 1.36 -%.d: %.cc 1.37 - @$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@ 1.38 - 1.39 -.PHONY: clean 1.40 -clean: 1.41 - rm -f $(obj) $(bin) $(dep) 1.42 - 1.43 -include build/macapp.mk
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/prototype/Makefile.in Sat Aug 25 20:20:56 2012 +0300 2.3 @@ -0,0 +1,36 @@ 2.4 +csrc = $(wildcard src/*.c) $(wildcard vmath/*.c) $(wildcard drawtext/*.c) 2.5 +ccsrc = $(wildcard src/*.cc) $(wildcard vmath/*.cc) 2.6 +obj = $(csrc:.c=.o) $(ccsrc:.cc=.o) 2.7 +dep = $(obj:.o=.d) 2.8 +bin = proto 2.9 + 2.10 +warn = -Wall -Wno-format-extra-args -Wno-char-subscripts 2.11 + 2.12 +inc = -I. -Ivmath -Idrawtext `pkg-config --cflags freetype2` 2.13 + 2.14 +CFLAGS = -pedantic $(warn) $(dbg) $(opt) $(inc) 2.15 +CXXFLAGS = $(CFLAGS) $(cxx11_cflags) 2.16 +LDFLAGS = $(cxx11_ldflags) $(libgl) -lm -lassimp -limago `pkg-config --libs freetype2` 2.17 + 2.18 +ifeq ($(shell uname -s), Darwin) 2.19 + libgl = -framework OpenGL -framework GLUT -lglew 2.20 +else 2.21 + libgl = -lGL -lGLU -lglut -lGLEW 2.22 +endif 2.23 + 2.24 +$(bin): $(obj) Makefile 2.25 + $(CXX) -o $@ $(obj) $(LDFLAGS) 2.26 + 2.27 +-include $(dep) 2.28 + 2.29 +%.d: %.c 2.30 + @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ 2.31 + 2.32 +%.d: %.cc 2.33 + @$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@ 2.34 + 2.35 +.PHONY: clean 2.36 +clean: 2.37 + rm -f $(obj) $(bin) $(dep) 2.38 + 2.39 +include build/macapp.mk
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/prototype/configure Sat Aug 25 20:20:56 2012 +0300 3.3 @@ -0,0 +1,57 @@ 3.4 +#!/bin/sh 3.5 + 3.6 +opt=false 3.7 +dbg=true 3.8 + 3.9 +while [ $# -gt 0 ]; do 3.10 + case $1 in 3.11 + --prefix=*) 3.12 + PREFIX=`echo $1 | sed 's/--prefix=//'` 3.13 + ;; 3.14 + --enable-*) 3.15 + `echo $1 | sed 's/--enable-//'`=true 3.16 + ;; 3.17 + --disable-*) 3.18 + `echo $1 | sed 's/--disable-//'`=false 3.19 + ;; 3.20 + esac 3.21 + shift 3.22 +done 3.23 + 3.24 +echo '# Generated makefile, do not edit' >Makefile 3.25 +echo "PREFIX = $PREFIX" >>Makefile 3.26 +if $opt; then 3.27 + echo 'opt = -O3 -ffast-math' >>Makefile 3.28 +fi 3.29 +if $dbg; then 3.30 + echo 'dbg = -g' >>Makefile 3.31 +fi 3.32 + 3.33 +# determine the C++11 flags we need to pass to the C++ compiler 3.34 +if [ -z "$CXX" ]; then 3.35 + CXX=c++ 3.36 +fi 3.37 + 3.38 +verstr=`$CXX --version` 3.39 +if echo "$verstr" | grep LLVM; then 3.40 + if echo | $CXX -c -x c++ -std=c++11 - >/dev/null 2>&1; then 3.41 + cxxflags11='-std=c++11 -stdlib=libc++' 3.42 + ldflags11='-stdlib=libc++' 3.43 + fi 3.44 +else 3.45 + if echo | $CXX -c -x c++ -std=c++11 - >/dev/null 2>&1; then 3.46 + cxxflags11='-std=c++11' 3.47 + elif echo | $CXX -c -x c++ -std=c++0x - >/dev/null 2>&1; then 3.48 + cxxflags11='-std=c++0x' 3.49 + fi 3.50 +fi 3.51 +if [ -z "$cxxflags11" ]; then 3.52 + echo 'Failed to find C++11 capable compiler.' 3.53 +fi 3.54 + 3.55 +echo "cxx11_cflags = $cxxflags11" >>Makefile 3.56 +if [ -n "$ldflags11" ]; then 3.57 + echo "cxx11_ldflags = $ldflags11" >>Makefile 3.58 +fi 3.59 + 3.60 +cat Makefile.in >>Makefile