-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·179 lines (148 loc) · 3.98 KB
/
configure
File metadata and controls
executable file
·179 lines (148 loc) · 3.98 KB
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
#!/bin/sh
if [ -z "$CC" ]; then
CC=cc
fi
cfgtest_src=.cfgtest.c
run_test() {
$CC -o .cfgtest $cfgtest_src >cfgtest.log 2>&1
if [ $? != 0 ]; then
echo "failed to compile test program, see cfgtest.log" >&2
exit 1
fi
./.cfgtest && cfgtest_result=0 || cfgtest_result=1
rm -f .cfgtest $cfgtest_src cfgtest.log
return $cfgtest_result
}
PREFIX=/usr/local
OPT=yes
DBG=yes
X11=yes
VER=`git describe --tags 2>/dev/null`
if [ -z "$VER" ]; then
VER=`git rev-parse --short HEAD 2>/dev/null`
if [ -z "$VER" ]; then
VER=v`pwd | grep 'libspnav-[0-9]\+\.' | sed 's/.*libspnav-\(\([0-9]\+\.\)\+[0-9]\+\).*$/\1/'`
if [ $VER = v ]; then
VER='<unknown version>'
fi
fi
fi
echo "configuring libspnav - $VER"
srcdir="`dirname "$0"`"
libdir=lib
#if [ "`uname -m`" = 'x86_64' ]; then
# libdir=lib64
#fi
for arg in $*; do
case "$arg" in
--prefix=*)
value=`echo $arg | sed 's/--prefix=//'`
PREFIX=${value:-$prefix}
;;
--enable-opt)
OPT=yes;;
--disable-opt)
OPT=no;;
--enable-debug)
DBG=yes;;
--disable-debug)
DBG=no;;
--enable-x11)
X11=yes;;
--disable-x11)
X11=no;;
--help)
echo 'usage: ./configure [options]'
echo 'options:'
echo ' --prefix=<path>: installation path (default: /usr/local)'
echo ' --enable-x11: enable X11 communication mode (default)'
echo ' --disable-x11: disable X11 communication mode'
echo ' --enable-opt: enable speed optimizations (default)'
echo ' --disable-opt: disable speed optimizations'
echo ' --enable-debug: include debugging symbols (default)'
echo ' --disable-debug: do not include debugging symbols'
echo 'all invalid options are silently ignored'
exit 0
;;
esac
done
sys=`uname -s | sed 's/MINGW.*/mingw/'`
# check if CC is gcc
echo 'int main(void) {' >$cfgtest_src
echo '#ifdef __GNUC__' >>$cfgtest_src
echo ' return 0;' >>$cfgtest_src
echo '#endif' >>$cfgtest_src
echo ' return 1; }' >>$cfgtest_src
run_test && cc_is_gcc=true || cc_is_gcc=false
# check if CC is MIPSpro
$CC -version 2>&1 | grep MIPSpro >/dev/null && cc_is_mipspro=true || cc_is_mipspro=false
echo " prefix: $PREFIX"
echo " optimize for speed: $OPT"
echo " include debugging symbols: $DBG"
echo " x11 communication method: $X11"
if [ -n "$CFLAGS" ]; then
echo " cflags: $CFLAGS"
fi
if [ -n "$LDFLAGS" ]; then
echo " ldflags: $LDFLAGS"
fi
echo ""
if [ "$X11" = "no" ]; then
echo "WARNING: you have disabled the X11 interface, the resulting library won't be compatible with the proprietary 3Dconnexion daemon (3dxserv)!"
echo ""
fi
# create Makefile
echo 'creating Makefile ...'
echo "PREFIX = $PREFIX" >Makefile
echo "srcdir = $srcdir" >>Makefile
echo "libdir = $libdir" >>Makefile
if [ -n "$CFLAGS" ]; then
echo "user_cflags = $CFLAGS" >>Makefile
fi
if [ -n "$LDFLAGS" ]; then
echo "user_ldflags = $LDFLAGS" >>Makefile
fi
if [ "$DBG" = 'yes' ]; then
echo 'dbg = -g3' >>Makefile
fi
if [ "$OPT" = 'yes' ]; then
if $cc_is_gcc; then
echo 'opt = -O2 -fno-strict-aliasing' >>Makefile
else
echo 'opt = -O2' >>Makefile
fi
fi
if [ "$X11" = 'yes' ]; then
echo 'magellan_obj = src/spnav_magellan.o' >>Makefile
echo 'xlib = -lX11' >>Makefile
fi
if $cc_is_gcc; then
echo 'cc_cflags = -std=c89 -pedantic -Wall -MMD' >>Makefile
fi
if [ "$sys" != mingw -a "$sys" != Darwin ]; then
if $cc_is_mipspro; then
echo 'pic = -KPIC' >>Makefile
else
echo 'pic = -fPIC' >>Makefile
fi
fi
cat "$srcdir/Makefile.in" >>Makefile
# create spnav_config.h
echo 'creating spnav_config.h ...'
echo '#ifndef SPNAV_CONFIG_H_' >src/spnav_config.h
echo '#define SPNAV_CONFIG_H_' >>src/spnav_config.h
echo '' >>src/spnav_config.h
if [ "$X11" = 'yes' ]; then
echo '#define SPNAV_USE_X11' >>src/spnav_config.h
echo '' >>src/spnav_config.h
fi
echo '#endif /* SPNAV_CONFIG_H_ */' >>src/spnav_config.h
# create pkgconfig file
echo 'creating spnav.pc ...'
pcver=`echo $VER | sed 's/^v//'`
echo "PREFIX=$PREFIX" >spnav.pc
cat "$srcdir/spnav.pc.in" | sed "s/@VERSION@/$pcver/; s/@LIBDIR@/$libdir/" >>spnav.pc
#done
echo ''
echo 'Done. You can now type make (or gmake) to compile libspnav.'
echo ''