-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·128 lines (108 loc) · 3.66 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
#!/bin/sh
CONF_VERSION="`git describe`"
CONF_BUILD_NAME="gojira $CONF_VERSION"
CONF_TARGETS="out/gojira lib"
CONF_PREFIX=/usr/local
CONF_SYSROOT=
CONF_GOJIRA_LIBDIR=
CONF_ENABLE_SOCKETS=1
CONF_ENABLE_FILES=1
CONF_DEBUG=0
CONF_CFLAGS=""
CONF_PUBLIC_MODE=0
CONF_DEV_BUILD=0
# Parse the given options
for arg in $@; do
OPT_KEY="`echo $arg | cut -d= -f1`"
OPT_VAL="`echo $arg | cut -d= -f2`"
case "$OPT_KEY" in
--prefix)
CONF_PREFIX="$OPT_VAL"
;;
--sysroot)
CONF_SYSROOT="$OPT_VAL"
;;
--help|-h)
cat <<- END_OF_HELP
This script sets configuration values for Gojira v0.0.1.
Options:
-h, --help Display this help message and exit.
--prefix=[path] Set the installation root to the given path.
--sysroot=[path] Set the path for the system root. This is prepended
to the PREFIX variable when copying files, and is
useful for cross-compiling, chroot installs, etc.
-d, --debug Specify that this is a debug build. This option
toggles some debugging messages.
-ds, --disable-sockets Disable the built-in networking functions.
-df, --disable-files Disable the built-in file functions.
-da, --disable-all Disable everything extra, and just build the core
interpreter.
-lo, --lib-only Output only a shared object (.so)
-lo, --interp-only Output only the interpreter executable
-s, --static Output a static executable.
-p, --public Specify that this will have input from untrusted sources,
and should not perform/output possibly sensitive operations.
-D, --dev Specify that this is a development build. This changes the
build name accordingly.
END_OF_HELP
exit 0
;;
--debug|-d)
CONF_DEBUG=1
;;
--disable-sockets|-ds)
CONF_ENABLE_SOCKETS=0
;;
--disable-files|-df)
CONF_ENABLE_FILES=0
;;
--disable-all|-da)
CONF_ENABLE_SOCKETS=0
CONF_ENABLE_FILES=0
;;
--lib-only|-lo)
CONF_TARGETS="lib"
;;
--interp-only|-io)
CONF_TARGETS="out/gojira"
;;
--static|-s)
CONF_CFLAGS="$CONF_FLAGS -static"
;;
--public-mode|-p)
CONF_PUBLIC_MODE=1
;;
--dev|-D)
BRANCHNAME="`git rev-parse --abbrev-ref HEAD`"
CONF_BUILD_NAME="gojira dev build $BRANCHNAME@$CONF_VERSION"
CONF_DEV_BUILD=1
;;
*)
echo "configure: error: Unknown option \"$OPT_KEY\""
exit 1
esac
done;
echo "BUILD_NAME = $CONF_BUILD_NAME"
echo "TARGETS = $CONF_TARGETS"
echo "PREFIX = $CONF_PREFIX"
echo "SYSROOT = $CONF_SYSROOT"
echo "DEV_BUILD = $CONF_DEV_BUILD"
echo "Full install path: $CONF_SYSROOT$CONF_PREFIX"
# Write the options to the makefile
echo "Generating makefile..."
echo "PREFIX=$CONF_PREFIX" > Makefile
echo "SYSROOT=$CONF_SYSROOT" >> Makefile
echo "CONF_TARGETS=$CONF_TARGETS" >> Makefile
echo "CONF_CFLAGS=$CONF_CFLAGS" >> Makefile
cat Makefile.conf >> Makefile
# Set flags in config.h
echo "Generating config.h..."
sed "s#SOME_PREFIX_HERE#$CONF_PREFIX/share/gojira#" < include/gojira/config.h.tmp > include/gojira/config.h
echo "#define GOJIRA_ENABLE_SOCKETS $CONF_ENABLE_SOCKETS" >> include/gojira/config.h
echo "#define GOJIRA_ENABLE_FILES $CONF_ENABLE_FILES" >> include/gojira/config.h
echo "#define GOJIRA_DEBUG $CONF_DEBUG" >> include/gojira/config.h
echo "#define GOJIRA_PUBLIC_MODE $CONF_PUBLIC_MODE" >> include/gojira/config.h
echo "#define GOJIRA_BUILD_NAME \"$CONF_BUILD_NAME\"" >> include/gojira/config.h
echo "#endif" >> include/gojira/config.h
# And we're finished
echo "Done"