goat3dgfx

annotate configure @ 34:3eb6c8f89fe1

merge
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Mar 2014 17:41:10 +0200
parents 0ac499409edd
children
rev   line source
nuclear@10 1 #!/bin/sh
nuclear@10 2
nuclear@10 3 prefix=/usr/local
nuclear@10 4 opt=false
nuclear@10 5 dbg=true
nuclear@10 6 vr=true
nuclear@10 7
nuclear@23 8 for arg in $#; do
nuclear@10 9 case "$arg" in
nuclear@10 10 --prefix=*)
nuclear@10 11 value=`echo $arg | sed 's/--prefix=//'`
nuclear@10 12 prefix=${value:-$prefix}
nuclear@10 13 ;;
nuclear@10 14
nuclear@10 15 --enable-opt)
nuclear@10 16 opt=true;;
nuclear@10 17 --disable-opt)
nuclear@10 18 opt=false;;
nuclear@10 19
nuclear@10 20 --enable-debug)
nuclear@10 21 dbg=true;;
nuclear@10 22 --disable-debug)
nuclear@10 23 dbg=false;;
nuclear@10 24
nuclear@10 25 --enable-vr)
nuclear@10 26 vr=true;;
nuclear@10 27 --disable-vr)
nuclear@10 28 vr=false;;
nuclear@10 29
nuclear@10 30 --help)
nuclear@10 31 echo 'usage: ./configure [options]'
nuclear@10 32 echo 'options:'
nuclear@10 33 echo ' --prefix=<path>: installation path (default: /usr/local)'
nuclear@10 34 echo ' --enable-<foo>/--disable-<foo>: enable/disable features where foo is:'
nuclear@10 35 echo ' opt: speed optimizations'
nuclear@10 36 echo ' dbg: debugging symbols'
nuclear@10 37 echo ' vr: support for virtual reality'
nuclear@10 38 echo 'all invalid options are silently ignored'
nuclear@10 39 exit 0
nuclear@10 40 ;;
nuclear@10 41 esac
nuclear@10 42 done
nuclear@10 43
nuclear@10 44 begin_emit()
nuclear@10 45 {
nuclear@10 46 emit_file=$1
nuclear@10 47 cat /dev/null >$1
nuclear@10 48 }
nuclear@10 49
nuclear@10 50 emit()
nuclear@10 51 {
nuclear@10 52 echo $* >>$emit_file
nuclear@10 53 }
nuclear@10 54
nuclear@10 55
nuclear@10 56 tmpfile_prefix=/tmp/goat3dgfx_configure-
nuclear@10 57 build_log=/tmp/goat3dgfx_configure.log
nuclear@10 58
nuclear@10 59 check_ovr()
nuclear@10 60 {
nuclear@10 61 tmpfile_bin=${tmpfile_prefix}check_ovr
nuclear@10 62 tmpfile_src=${tmpfile_bin}.cc
nuclear@10 63
nuclear@10 64 begin_emit $tmpfile_src
nuclear@10 65 emit '#include <OVR.h>'
nuclear@10 66 emit 'int main() {}'
nuclear@10 67
nuclear@10 68 echo -n 'checking for LibOVR ... '
nuclear@10 69
nuclear@10 70 if ! c++ $CFLAGS -o $tmpfile_bin $tmpfile_src -lovr >$build_log 2>&1; then
nuclear@10 71 echo not found!
nuclear@10 72 exit 1
nuclear@10 73 else
nuclear@10 74 echo ok
nuclear@10 75 fi
nuclear@10 76
nuclear@15 77 LDFLAGS="$LDFLAGS -lovr -ludev -lXinerama"
nuclear@10 78 rm -f $tmpfile_bin $tmpfile_src
nuclear@10 79 }
nuclear@10 80
nuclear@10 81 check_glew()
nuclear@10 82 {
nuclear@10 83 tmpfile_bin=${tmpfile_prefix}check_glew
nuclear@10 84 tmpfile_src=${tmpfile_bin}.c
nuclear@10 85
nuclear@10 86 begin_emit $tmpfile_src
nuclear@10 87 emit '#include <GL/glew.h>'
nuclear@10 88 emit 'int main() { return 0; }'
nuclear@10 89
nuclear@10 90 echo -n 'checking for GLEW ... '
nuclear@10 91
nuclear@10 92 if ! cc $CFLAGS -o $tmpfile_bin $tmpfile_src -lGLEW >$build_log 2>&1; then
nuclear@10 93 echo not found!
nuclear@10 94 exit 1
nuclear@10 95 else
nuclear@10 96 echo ok
nuclear@10 97 fi
nuclear@10 98
nuclear@10 99 LDFLAGS="$LDFLAGS -lGLEW"
nuclear@10 100 rm -f $tmpfile_bin $tmpfile_src
nuclear@10 101 }
nuclear@10 102
nuclear@10 103 check_opengl()
nuclear@10 104 {
nuclear@10 105 tmpfile_bin=${tmpfile_prefix}check_gl
nuclear@10 106 tmpfile_src=${tmpfile_bin}.c
nuclear@10 107
nuclear@10 108 echo -n 'checking for OpenGL ... '
nuclear@10 109
nuclear@10 110 begin_emit $tmpfile_src
nuclear@10 111 if [ "`uname -s`" = Darwin ]; then
nuclear@10 112 emit '#include <OpenGL/gl.h>'
nuclear@10 113
nuclear@10 114 libgl='-framework OpenGL'
nuclear@10 115 else
nuclear@10 116 if uname -s | grep MINGW; then
nuclear@10 117 libgl='-lopengl32 -lglu32'
nuclear@32 118 emit '#include <windows.h>'
nuclear@10 119 else
nuclear@10 120 libgl='-lGL -lGLU'
nuclear@10 121 fi
nuclear@32 122
nuclear@32 123 emit '#include <GL/gl.h>'
nuclear@10 124 fi
nuclear@10 125 emit 'int main() { return 0; }'
nuclear@10 126
nuclear@10 127 if ! cc $CFLAGS -o $tmpfile_bin $tmpfile_src $libgl >$build_log 2>&1; then
nuclear@10 128 echo not found!
nuclear@10 129 exit 1
nuclear@10 130 else
nuclear@10 131 echo ok
nuclear@10 132 fi
nuclear@10 133
nuclear@10 134 LDFLAGS="$LDFLAGS $libgl"
nuclear@10 135 rm -f $tmpfile_bin $tmpfile_src
nuclear@10 136 }
nuclear@10 137
nuclear@10 138 check_glut()
nuclear@10 139 {
nuclear@10 140 tmpfile_bin=${tmpfile_prefix}check_glut
nuclear@10 141 tmpfile_src=${tmpfile_bin}.c
nuclear@10 142
nuclear@10 143 echo -n 'checking for GLUT ... '
nuclear@10 144
nuclear@10 145 begin_emit $tmpfile_src
nuclear@10 146 if [ "`uname -s`" = Darwin ]; then
nuclear@10 147 emit '#include <GLUT/glut.h>'
nuclear@10 148
nuclear@10 149 libglut='-framework GLUT'
nuclear@10 150 else
nuclear@10 151 emit '#include <GL/glut.h>'
nuclear@10 152
nuclear@10 153 if uname -s | grep MINGW; then
nuclear@10 154 libglut='-lglut32'
nuclear@10 155 else
nuclear@10 156 libglut='-lglut'
nuclear@10 157 fi
nuclear@10 158 fi
nuclear@10 159 emit 'int main() { return 0; }'
nuclear@10 160
nuclear@10 161 if ! cc $CFLAGS -o $tmpfile_bin $tmpfile_src $libglut >$build_log 2>&1; then
nuclear@10 162 echo not found!
nuclear@10 163 exit 1
nuclear@10 164 else
nuclear@10 165 echo ok
nuclear@10 166 fi
nuclear@10 167
nuclear@10 168 LDFLAGS="$LDFLAGS $libglut"
nuclear@10 169 rm -f $tmpfile_bin $tmpfile_src
nuclear@10 170 }
nuclear@10 171
nuclear@32 172 check_lib()
nuclear@32 173 {
nuclear@32 174 libname=$1
nuclear@32 175 hdr=$2
nuclear@32 176 lib=-l$libname
nuclear@32 177 tmpfile_bin=${tmpfile_prefix}check_$libname
nuclear@32 178 tmpfile_src=${tmpfile_bin}.cc
nuclear@32 179
nuclear@32 180 echo -n "checking for $libname ... "
nuclear@32 181
nuclear@32 182 begin_emit $tmpfile_src
nuclear@32 183 emit "#include <${hdr}>"
nuclear@32 184 emit 'int main() {}'
nuclear@32 185
nuclear@32 186 if ! c++ -o $tmpfile_bin $tmpfile_src $lib -lpthread >$build_log 2>&1; then
nuclear@32 187 echo not found!
nuclear@32 188 exit 1
nuclear@32 189 else
nuclear@32 190 echo ok
nuclear@32 191 fi
nuclear@32 192
nuclear@32 193 LDFLAGS="$LDFLAGS $lib"
nuclear@32 194 rm -f $tmpfile_bin $tmpfile_src
nuclear@32 195 }
nuclear@32 196
nuclear@10 197 gen_config()
nuclear@10 198 {
nuclear@10 199 echo "generating: src/config.h ..."
nuclear@10 200 begin_emit src/config.h
nuclear@10 201
nuclear@10 202 emit '#ifndef GOAT3DGFX_CONFIG_H_'
nuclear@10 203 emit '#define GOAT3DGFX_CONFIG_H_'
nuclear@10 204
nuclear@10 205 if $vr; then
nuclear@10 206 emit '#define USE_VR'
nuclear@10 207 emit '#define USE_LIBOVR'
nuclear@10 208 else
nuclear@10 209 emit '#undef USE_VR'
nuclear@10 210 fi
nuclear@10 211
nuclear@12 212 emit '#endif // GOAT3DGFX_CONFIG_H_'
nuclear@10 213 }
nuclear@10 214
nuclear@10 215
nuclear@10 216 gen_makefile()
nuclear@10 217 {
nuclear@10 218 echo "generating: Makefile ..."
nuclear@10 219 begin_emit Makefile
nuclear@10 220
nuclear@10 221 emit '# this makefile is automatically generated. do not edit!'
nuclear@10 222 emit "PREFIX = $prefix"
nuclear@10 223 if $opt; then emit 'opt = -O3'; fi
nuclear@10 224 if $dbg; then emit 'dbg = -g'; fi
nuclear@10 225 emit "cfg_cflags = $CFLAGS"
nuclear@10 226 emit "cfg_ldflags = $LDFLAGS"
nuclear@10 227
nuclear@11 228 if $vr; then emit 'use_vr = true'; fi
nuclear@11 229
nuclear@10 230 cat Makefile.in >>Makefile
nuclear@10 231 }
nuclear@10 232
nuclear@23 233 gen_pkgconfig()
nuclear@23 234 {
nuclear@23 235 pcfile=goat3dgfx.pc
nuclear@23 236 echo "generating: $pcfile ..."
nuclear@23 237 begin_emit $pcfile
nuclear@23 238
nuclear@23 239 emit "prefix=$prefix"
nuclear@23 240 emit "ver=0.1"
nuclear@23 241
nuclear@23 242 if [ `uname -s` = Darwin ]; then
nuclear@23 243 emit 'libgl=-framework OpenGL -framework GLUT -lGLEW'
nuclear@23 244 else
nuclear@23 245 emit 'libgl=-lGL -lGLU -lglut -lGLEW'
nuclear@23 246 fi
nuclear@23 247 emit 'libovr='
nuclear@23 248
nuclear@23 249 cat ${pcfile}.in >>$pcfile
nuclear@23 250 }
nuclear@23 251
nuclear@10 252 check_opengl
nuclear@10 253 check_glut
nuclear@10 254 check_glew
nuclear@10 255 if $vr; then check_ovr; fi
nuclear@32 256 check_lib vmath vmath/vmath.h
nuclear@32 257 check_lib imago imago2.h
nuclear@32 258 check_lib anim anim/anim.h
nuclear@32 259 check_lib psys psys/psys.h
nuclear@32 260 check_lib resman resman.h
nuclear@32 261 check_lib goat3d goat3d.h
nuclear@10 262
nuclear@10 263 gen_makefile
nuclear@10 264 gen_config
nuclear@23 265 gen_pkgconfig