9 rm -f config.mak
2>/dev
/null
13 printf "%s\n" "$1" >> config.mak
17 add_config
"CFLAGS += $1"
21 add_config
"LDFLAGS += $1"
24 get_pkgconf_cflags
() {
25 pkg-config
--cflags "$1" 2>/dev
/null
28 get_pkgconf_ldflags
() {
29 pkg-config
--libs "$1" 2>/dev
/null
32 add_pkgconf_cflags
() {
34 flags
=$
(get_pkgconf_cflags
"$1")
35 [ -z "$flags" ] && flags
="$fallback"
39 add_pkgconf_ldflags
() {
41 flags
=$
(get_pkgconf_ldflags
"$1")
42 [ -z "$flags" ] && flags
="$fallback"
47 add_pkgconf_cflags
"$1" "$2"
48 add_pkgconf_ldflags
"$1" "$3"
53 echo "supported arguments"
54 echo "--prefix=/path default: $prefix"
55 echo "--exec_prefix=/path default: $prefix/bin"
56 echo "--bindir=/path default: $prefix/bin"
57 echo "--libdir=/path default: $prefix/lib"
58 echo "--includedir=/path default: $prefix/include"
59 echo "--sysconfdir=/path default: $prefix/etc"
60 echo "--with-ssl=[auto,cyassl,openssl,no] default: auto"
61 echo "--disable-static default: no"
62 echo "--enable-shared default: no"
63 echo "--help : show this text"
70 #alternatives echo "$arg" | cut -d= -f2-
71 # or echo "$arg" | sed 's/[^=]*=//'
75 printf "checking whether linking against %s works... " "$2"
76 echo "int main(){};" > "$tmpc"
77 if $CC "$2" -o /dev
/null
"$tmpc" >/dev
/null
2>&1 ; then
79 eval "$1=\"\${$1} \$2\""
91 --prefix=*) prefix
=`spliteq $1`;;
92 --exec_prefix=*) exec_prefix
=`spliteq $1`;;
93 --bindir=*) bindir
=`spliteq $1`;;
94 --libdir=*) libdir
=`spliteq $1`;;
95 --includedir=*) includedir
=`spliteq $1`;;
96 --sysconfdir=*) sysconfdir
=`spliteq $1`;;
98 --disable-static) disable_static
=1 ;;
99 --disable-static=yes) disable_static
=1 ;;
100 --enable-shared) enable_shared
=1 ;;
101 --enable-shared=yes) enable_shared
=1 ;;
102 --with-ssl=*) ssl_lib
=`spliteq $1`;;
108 -*) parsearg
"$1"; shift;;
113 [ -z "$exec_prefix" ] && exec_prefix
=$prefix
114 [ -z "$libdir" ] && libdir
=$prefix/lib
115 [ -z "$includedir" ] && includedir
=$prefix/include
116 [ -z "$sysconfdir" ] && sysconfdir
=$prefix/etc
117 [ -z "$bindir" ] && bindir
=$exec_prefix/bin
118 [ -z "$CC" ] && CC
=cc
122 add_config
"prefix = $prefix"
123 add_config
"exec_prefix = $exec_prefix"
124 add_config
"bindir = $bindir"
125 add_config
"libdir = $libdir"
126 add_config
"includedir = $includedir"
127 add_config
"sysconfdir = $sysconfdir"
129 add_config
"CC ?= $CC"
130 [ -z "$CPPFLAGS" ] || add_config
"CPPFLAGS ?= $CPPFLAGS"
131 [ -z "$CFLAGS" ] || add_config
"CFLAGS ?= $CFLAGS"
133 for lib
in $libs ; do add_lib
"$lib" ; done
136 # Get a temp filename we can use
140 while : ; do i
=$
(($i+1))
141 tmpc
="./conf$$-$PPID-$i.c"
142 2>|
/dev
/null
> "$tmpc" && break
143 test "$i" -gt 50 && fail
"$0: cannot create temporary file $tmpc"
146 trap 'rm "$tmpc"' EXIT INT QUIT TERM HUP
149 if [ "$ssl_lib" = auto
] ; then
151 if trylink foo
"-lcyassl" ; then ssl_lib
=cyassl
152 elif trylink foo
"-lssl" && trylink foo
"-lcrypto" ; then ssl_lib
=openssl
156 if [ ! "$ssl_lib" = no
] ; then
157 add_config
"CFLAGS += -DUSE_SSL"
158 [ "$ssl_lib" = "openssl" ] && add_lib openssl
"" "-lssl -lcrypto" && add_cflags
"-DUSE_OPENSSL"
159 [ "$ssl_lib" = "cyassl" ] && add_lib cyassl
"" "-lcyassl" && add_cflags
"-DUSE_CYASSL"
161 [ "$disable_static" = 1 ] && add_config
"ALL_LIBS =" && enable_shared
=1
162 [ "$enable_shared" = 1 ] && add_config
"ALL_LIBS += librocksock.so"
165 echo "hint: if you intend to build a static binary with minimal size, try NO_DNS_SUPPORT, NO_STRDUP in CFLAGS"
166 echo "config.mak successfully created. now run make && make install"