goat3dgfx

view configure @ 17:f2da87b02fcd

fixes mostly visual studio stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 01 Dec 2013 02:25:29 +0200
parents 1868c5975f31
children 0ac499409edd
line source
1 #!/bin/sh
3 prefix=/usr/local
4 opt=false
5 dbg=true
6 vr=true
8 for arg; do
9 case "$arg" in
10 --prefix=*)
11 value=`echo $arg | sed 's/--prefix=//'`
12 prefix=${value:-$prefix}
13 ;;
15 --enable-opt)
16 opt=true;;
17 --disable-opt)
18 opt=false;;
20 --enable-debug)
21 dbg=true;;
22 --disable-debug)
23 dbg=false;;
25 --enable-vr)
26 vr=true;;
27 --disable-vr)
28 vr=false;;
30 --help)
31 echo 'usage: ./configure [options]'
32 echo 'options:'
33 echo ' --prefix=<path>: installation path (default: /usr/local)'
34 echo ' --enable-<foo>/--disable-<foo>: enable/disable features where foo is:'
35 echo ' opt: speed optimizations'
36 echo ' dbg: debugging symbols'
37 echo ' vr: support for virtual reality'
38 echo 'all invalid options are silently ignored'
39 exit 0
40 ;;
41 esac
42 done
44 begin_emit()
45 {
46 emit_file=$1
47 cat /dev/null >$1
48 }
50 emit()
51 {
52 echo $* >>$emit_file
53 }
56 tmpfile_prefix=/tmp/goat3dgfx_configure-
57 build_log=/tmp/goat3dgfx_configure.log
59 check_ovr()
60 {
61 tmpfile_bin=${tmpfile_prefix}check_ovr
62 tmpfile_src=${tmpfile_bin}.cc
64 begin_emit $tmpfile_src
65 emit '#include <OVR.h>'
66 emit 'int main() {}'
68 echo -n 'checking for LibOVR ... '
70 if ! c++ $CFLAGS -o $tmpfile_bin $tmpfile_src -lovr >$build_log 2>&1; then
71 echo not found!
72 exit 1
73 else
74 echo ok
75 fi
77 LDFLAGS="$LDFLAGS -lovr -ludev -lXinerama"
78 rm -f $tmpfile_bin $tmpfile_src
79 }
81 check_glew()
82 {
83 tmpfile_bin=${tmpfile_prefix}check_glew
84 tmpfile_src=${tmpfile_bin}.c
86 begin_emit $tmpfile_src
87 emit '#include <GL/glew.h>'
88 emit 'int main() { return 0; }'
90 echo -n 'checking for GLEW ... '
92 if ! cc $CFLAGS -o $tmpfile_bin $tmpfile_src -lGLEW >$build_log 2>&1; then
93 echo not found!
94 exit 1
95 else
96 echo ok
97 fi
99 LDFLAGS="$LDFLAGS -lGLEW"
100 rm -f $tmpfile_bin $tmpfile_src
101 }
103 check_opengl()
104 {
105 tmpfile_bin=${tmpfile_prefix}check_gl
106 tmpfile_src=${tmpfile_bin}.c
108 echo -n 'checking for OpenGL ... '
110 begin_emit $tmpfile_src
111 if [ "`uname -s`" = Darwin ]; then
112 emit '#include <OpenGL/gl.h>'
114 libgl='-framework OpenGL'
115 else
116 emit '#include <GL/gl.h>'
118 if uname -s | grep MINGW; then
119 libgl='-lopengl32 -lglu32'
120 else
121 libgl='-lGL -lGLU'
122 fi
123 fi
124 emit 'int main() { return 0; }'
126 if ! cc $CFLAGS -o $tmpfile_bin $tmpfile_src $libgl >$build_log 2>&1; then
127 echo not found!
128 exit 1
129 else
130 echo ok
131 fi
133 LDFLAGS="$LDFLAGS $libgl"
134 rm -f $tmpfile_bin $tmpfile_src
135 }
137 check_glut()
138 {
139 tmpfile_bin=${tmpfile_prefix}check_glut
140 tmpfile_src=${tmpfile_bin}.c
142 echo -n 'checking for GLUT ... '
144 begin_emit $tmpfile_src
145 if [ "`uname -s`" = Darwin ]; then
146 emit '#include <GLUT/glut.h>'
148 libglut='-framework GLUT'
149 else
150 emit '#include <GL/glut.h>'
152 if uname -s | grep MINGW; then
153 libglut='-lglut32'
154 else
155 libglut='-lglut'
156 fi
157 fi
158 emit 'int main() { return 0; }'
160 if ! cc $CFLAGS -o $tmpfile_bin $tmpfile_src $libglut >$build_log 2>&1; then
161 echo not found!
162 exit 1
163 else
164 echo ok
165 fi
167 LDFLAGS="$LDFLAGS $libglut"
168 rm -f $tmpfile_bin $tmpfile_src
169 }
171 gen_config()
172 {
173 echo "generating: src/config.h ..."
174 begin_emit src/config.h
176 emit '#ifndef GOAT3DGFX_CONFIG_H_'
177 emit '#define GOAT3DGFX_CONFIG_H_'
179 if $vr; then
180 emit '#define USE_VR'
181 emit '#define USE_LIBOVR'
182 else
183 emit '#undef USE_VR'
184 fi
186 emit '#endif // GOAT3DGFX_CONFIG_H_'
187 }
190 gen_makefile()
191 {
192 echo "generating: Makefile ..."
193 begin_emit Makefile
195 emit '# this makefile is automatically generated. do not edit!'
196 emit "PREFIX = $prefix"
197 if $opt; then emit 'opt = -O3'; fi
198 if $dbg; then emit 'dbg = -g'; fi
199 emit "cfg_cflags = $CFLAGS"
200 emit "cfg_ldflags = $LDFLAGS"
202 if $vr; then emit 'use_vr = true'; fi
204 cat Makefile.in >>Makefile
205 }
207 check_opengl
208 check_glut
209 check_glew
210 if $vr; then check_ovr; fi
212 gen_makefile
213 gen_config