-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure
executable file
·182 lines (160 loc) · 4.24 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/sh
prefix=/usr/local
opt=true
dbg=true
build_examples=true
sys=`uname -s | sed 's/MINGW.*/mingw/'`
if [ "$sys" = mingw ]; then
mod_oculus=true
mod_oculus_old=false
mod_sball=false
else
mod_oculus=false
mod_oculus_old=true
mod_sball=true
fi
mod_openvr=true
mod_openhmd=true
for arg; do
case $arg in
--prefix=*)
prefix=`echo $arg | sed 's/--prefix=//'`
;;
--enable-opt)
opt=true
;;
--disable-opt)
opt=false
;;
--enable-dbg)
dbg=true
;;
--disable-dbg)
dbg=false
;;
--enable-module-*)
eval mod_`echo $arg | sed 's/--enable-module-//'`=true
;;
--disable-module-*)
eval mod_`echo $arg | sed 's/--disable-module-//'`=false
;;
--enable-examples)
build_examples=true
;;
--disable-examples)
build_examples=false
;;
--help)
echo 'Usage: ./configure [options]'
echo 'Options:'
echo ' --prefix=<prefix> installation prefix (default: /usr/local)'
echo ' --enable-opt enable code optimizations (default)'
echo ' --disable-opt disable code optimizations'
echo ' --enable-dbg enable debugging (default)'
echo ' --disable-dbg disable debugging'
echo ' --enable-module-<name> enable a VR module (see module list below)'
echo ' --disable-module-<name> disable a VR module (see module list below)'
echo ' --enable-examples build example programs (default)'
echo " --disable-examples don't build examples programs"
echo ' --help print usage and exit'
echo
echo 'You may set CFLAGS and/or LDFLAGS when running configure, to pass extra'
echo 'flags to the compiler and/or linker.'
echo
echo "List of optional VR modules:"
echo ' oculus Oculus SDK >= 1.x'
echo ' oculus_old Oculus SDK v0.5 (last version for GNU/Linux, DK1/DK2 only)'
echo ' openvr Valve OpenVR SDK'
echo ' openhmd OpenHMD library'
echo ' sball Spaceball (6dof) input module'
echo
exit 0
;;
esac
done
echo $0 $* >config.status
chmod +x config.status
echo 'Generating Makefile ...'
echo '# generated by configure, do not edit. Edit Makefile.in instead' >Makefile
echo "PREFIX = $prefix" >>Makefile
[ -n "$CFLAGS" ] && echo "CFLAGS_cfg = $CFLAGS" >>Makefile
[ -n "$LDFLAGS" ] && echo "LDFLAGS_cfg = $LDFLAGS" >>Makefile
$opt && echo 'opt = -O3 -ffast-math' >>Makefile
$dbg && echo 'dbg = -g' >>Makefile
echo "sys = $sys" >>Makefile
printmod()
{
if $2; then
echo " [*] $1"
else
echo " [ ] $1"
fi
}
echo 'Optional modules:'
printmod oculus $mod_oculus
if $mod_oculus; then
mod_def="$mod_def -DUSE_MOD_OCULUS"
mod_libs="$mod_libs -lovr"
fi
printmod oculus_old $mod_oculus_old
if $mod_oculus_old; then
mod_def="$mod_def -DUSE_MOD_OCULUS_OLD"
mod_libs="$mod_libs -lOVR -ldl"
fi
printmod openvr $mod_openvr
if $mod_openvr; then
# detect if we have the old version with vr->ResetSeatedZeroPose or a newer version
# with vrchap->ResetZeroPose(...)
cc -x c++ -o /dev/null $CFLAGS -c - 2>/dev/null <<EOF
#include <openvr/openvr.h>
void foo() { vr::VRChaperone()->ResetZeroPose(vr::TrackingUniverseSeated); }
EOF
if [ $? != 0 ]; then
mod_def="$mod_def -DMOD_OPENVR_OLDRECENTER"
fi
mod_def="$mod_def -DUSE_MOD_OPENVR"
mod_libs="$mod_libs -lopenvr_api"
fi
printmod openhmd $mod_openhmd
if $mod_openhmd; then
mod_def="$mod_def -DUSE_MOD_OPENHMD"
mod_libs="$mod_libs -lopenhmd"
fi
printmod sball $mod_sball
if $mod_sball; then
mod_def="$mod_def -DUSE_MOD_SBALL"
mod_libs="$mod_libs -lspnav"
fi
echo "CFLAGS_mod = $mod_def" >>Makefile
echo "LDFLAGS_mod = $mod_libs" >>Makefile
echo >>Makefile
# output default rule
echo '.PHONY: all' >>Makefile
if $build_examples; then
echo 'all: shared static examples' >>Makefile
else
echo 'all: shared static' >>Makefile
fi
echo '# -------------' >>Makefile
echo >>Makefile
cat Makefile.in >>Makefile
# -------------------------------------
echo 'Generating reg_modules.cc ...'
out=reg_modules.cc
echo '// generated file, do not edit!' >$out
echo 'namespace goatvr {' >>$out
echo >>$out
for i in src/mod_*.cc; do
name=`basename $i .cc`
echo "void register_$name();" >>$out
done
echo >>$out
echo 'void register_modules()' >>$out
echo '{' >>$out
for i in src/mod_*.cc; do
name=`basename $i .cc`
echo " register_$name();" >>$out
done
echo '}' >>$out
echo >>$out
echo '} // namespace goat' >>$out