-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_conf.sh
executable file
·63 lines (53 loc) · 1.12 KB
/
build_conf.sh
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
#!/bin/bash
test_header() {
gcc -x c - -o /dev/null 2>/dev/null << EOF
#include <$1>
int main() { return 0; }
EOF
}
CONF=$1
VAR=$2
if test -z "$CONF" | test -z "$VAR"; then
echo "Usage: $0 <config file> <var file>"
echo "eg:"
echo " $0 config.h var"
exit 1
fi
# remove old records
rm -rf $CONF
touch $CONF
rm -rf $VAR
touch $VAR
if test -z "$CC"; then
CC=gcc
fi
echo "#ifndef __JC_CONFIG_H__" >> $CONF
echo "#define __JC_CONFIG_H__" >> $CONF
echo "" >> $CONF
$(test_header malloc.h)
if [ "$?" == 0 ]; then
echo "#define HAVE_MALLOC_H" >> $CONF
fi
$(test_header stdlib.h)
if [ "$?" == 0 ]; then
echo "#define HAVE_STDLIB_H" >> $CONF
fi
$(test_header sys/types.h)
if [ "$?" == 0 ]; then
echo "#define HAVE_SYS_TYPES_H" >> $CONF
fi
echo "" >> $CONF
echo "#endif" >> $CONF
os=$(uname -s)
if [ $os == "Darwin" ]; then
# mac os
#echo "DYNAMIC_LIB=libjson4c.dylib" >> $VAR
echo "DYLIB_SUFFIX=.dylib" >> $VAR
elif [ $os == "Linux" ]; then
# linux
#echo "DYNAMIC_LIB=libjson4c.so" >> $VAR
echo "DYLIB_SUFFIX=.so" >> $VAR
else
echo "Unknown OS: " $os
exit 1
fi