-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure
executable file
·80 lines (69 loc) · 2.17 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
#!/bin/sh
rm -f config.mk
# TODO: detect mitshm
pkg-config --exists --print-errors x11 xext xt xpm
# libxp is required if motif was built with print support.
# mac and Arx linux appear to need it.
# Debian doesn't do printing, and in fact doesn't even have xp as a package.
# Linking order (LDLIBS) must be exact, otherwise you might get this error:
# "X Error of failed request: BadWindow (invalid Window parameter)
# Major opcode of failed request: 19 (X_DeleteProperty)"
cat >> config.mk <<-EOF
CFLAGS += -std=c99 $(pkg-config --cflags x11 xext xt xpm) $(pkg-config --silence-errors --cflags xp)
LDFLAGS += $(pkg-config --libs-only-other --libs-only-L x11 xext xt xpm) $(pkg-config --silence-errors --libs-only-other --libs-only-L xp)
LDLIBS += -lm $(pkg-config --libs-only-l x11 xext) -lXm $(pkg-config --libs-only-l xt xpm) $(pkg-config --silence-errors --libs-only-L xp)
EOF
# Unfortuantly motif (xm) does not have a .pc file.
# so we have to find it.
case "$(uname -s)" in
Darwin)
if command -v brew > /dev/null
then
echo "using homebrew"
cat >> config.mk <<-EOF
CFLAGS += -I$(brew --prefix openmotif)/include -I/opt/X11/include
LDFLAGS += -L$(brew --prefix openmotif)/lib
EOF
fi ;;
NetBSD)
if command -v pkgin > /dev/null
then
echo "using pkgsrc"
cat >> config.mk <<-EOF
CFLAGS += -I/usr/pkg/include
LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
EOF
fi ;;
OpenBSD)
cat >> config.mk <<-EOF
CFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib
EOF
;;
Linux) ;;
esac
X11_PATH_PREFIX=$(pkg-config --variable prefix x11)
echo "CFLAGS += -D_POSIX_C_SOURCE=200809L -D X11_PATH_PREFIX=\\\"${X11_PATH_PREFIX}\\\"" >> config.mk
DEBUG=false
SHM=true
for var in "$@"
do
if [ "$var" = "--debug" ]
then
DEBUG=true
elif [ "$var" = "--no-shm" ]
then
SHM=false
fi
done
if [ "$DEBUG" = "true" ]
then
echo "CFLAGS += -D DEBUG_LOG=1 -g" >> config.mk
else
#-fno-strict-aliasing is specifically a requirement of stb_image_write
echo "CFLAGS += -D DEBUG_LOG=0 -O3 -fno-strict-aliasing" >> config.mk
fi
if [ "$SHM" = "true" ]
then
echo "CFLAGS += -D FEATURE_SHM" >> config.mk
fi