3 # stolen from ffmpeg configure like a pig
4 # this is brutal and stupid... then easy and explicit
6 # Prevent locale nonsense from breaking basic text processing.
10 #-------------------------------------------------------------------------------
11 #uppercase S tells gcc assembler to run the pre-preprocessor
12 #lowercase s tells gcc assembler _NOT_ to run the pre-preprocessor
14 ulinux_target_arch_asm_srcs
='
16 ulinux/arch/utils/endian.S
21 ulinux/utils/ascii/string/vsprintf.c
23 #-------------------------------------------------------------------------------
26 #-------------------------------------------------------------------------------
27 lnanohttp_bin_ulinux_objs
='
36 #-------------------------------------------------------------------------------
41 $lnanohttp_bin_ulinux_objs
44 for src_file
in $lnanohttp_bin_srcs
57 ################################################################################
63 src_path
=$
(cd $
(dirname "$0"); pwd)
64 echo "$src_path" |
grep -q '[[:blank:]]' &&
65 die
"Out of tree builds are impossible with whitespace in source path."
66 test -e "$src_path/config.h" &&
67 die
"Out of tree builds are impossible with config.h in source dir."
74 [ $var = $value ] && return 0
82 eval "$var=\"\$$var $*\""
91 echo "Unknown option \"$1\"."
92 echo "See $0 --help for available options."
98 eval : \
${$opt:=\$${opt}_default}
109 #command line, set defaults
110 arch_default
=$
(uname
-m |
sed -e s
/i
.86/x86
/ -e s
/parisc64
/parisc
/ -e s
/sun4u
/sparc64
/ -e s
/arm.
*/arm
/ -e s
/sa110
/arm
/ -e s
/sh.
*/sh
/)
112 cc_default
='gcc -Wall -Wextra -Wno-missing-field-initializers -c -fpic -O0'
113 bin_ccld_tmpl_default
="ld -Bstatic -nostdlib \$objects $(gcc -print-libgcc-file-name)"
115 #(tinycc + binutils) toolchain
117 ##cc_default='/home/sylvain/local/tinycc/bin/tcc -c'
118 ##bin_ccld_tmpl_default="ld \$objects"
120 set_default
$CMDLINE_SET
124 Usage: make [options] [operations]
126 Operations: [default is to build the http server binary]:
127 clean clean build products
130 Options: [defaults in brackets after descriptions]
133 --help print this message
135 Advanced options (experts only):
136 --arch=ARCH use ulinux target ARCH [$arch_default]
137 --asm=ASM use target arch assembler command line ASM [$asm_default]
138 --cc=CC use target arch C compiler command line CC [$cc_default]
139 --bin-ccld-tmpl=BIN_CCLD_TMPL use linker command line template BIN_CCLD_TMPL for target arch binary [$bin_ccld_tmpl_default]
153 optname
="${optname#--}"
154 optname
=$
(echo "$optname" |
sed 's/-/_/g')
155 if is_in
$optname $CMDLINE_SET; then
156 eval $optname='$optval'
157 elif is_in
$optname $CMDLINE_APPEND; then
158 append
$optname "$optval"
167 #-------------------------------------------------------------------------------
168 #configure our ultra-thin linux user API abstraction layer
171 ln -f -s $src_path/ulinux
/archs
/$arch ulinux
/arch
172 #-------------------------------------------------------------------------------
175 #-------------------------------------------------------------------------------
177 target_arch_asm_srcs
="
178 $ulinux_target_arch_asm_srcs
181 for src_file
in $target_arch_asm_srcs
186 $asm -o $
(basename $obj) $src_file
188 #-------------------------------------------------------------------------------
191 #-------------------------------------------------------------------------------
197 for src_file
in $c_srcs
202 $cc -o $
(basename $obj) -I.
/ -I$src_path $src_path/$src_file
203 c_objs
="$obj $c_objs"
205 #-------------------------------------------------------------------------------
208 #-------------------------------------------------------------------------------
209 #link the lnanohttp binary
210 for src_file
in $lnanohttp_bin_srcs
214 lnanohttp_bin_objs
="$obj $lnanohttp_bin_objs"
216 lnanohttp_bin_objs
="$lnanohttp_bin_objs $lnanohttp_bin_ulinux_objs"
218 echo BIN_CCLD lnanohttp
219 #resolve the template
220 objects
=$lnanohttp_bin_objs
221 eval bin_ccld
=\"$bin_ccld_tmpl\"
222 $bin_ccld -o lnanohttp
223 #-------------------------------------------------------------------------------