Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

executable file 242 lines (194 sloc) 8.36 kb
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
#!/bin/sh
#
# $Id: configure,v 1.97 2009/10/27 16:14:43 tat Exp $

export makl_conf_h=klone_conf.h
export MAKL_DIR=`pwd`/makl

if [ -z "${MAKE}" ]; then
    MAKE=make
fi

# will fail using something different then GNU make
( cd build/makecheck && "${MAKE}" >/dev/null ) || exit 1

# before running configure the toolchain must be present
if [ ! -r "${MAKL_DIR}"/etc/toolchain.cf ]; then
    "${MAKE}" -C "${MAKL_DIR}" toolchain
fi

# MaKL preamble
. "${MAKL_DIR}"/cf/makl.init
. build/makl_checkfork
. build/makl_va_list_by_value
. build/makl_checkstackp

# Preprocess arguments
makl_args_init "$@"

# Custom arguments ...
makl_args_def "enable_debug" "" "" "enables debugging of KLone app"
makl_args_def "enable_libu_debug" "" "" "enables debugging of LibU"
makl_args_def "enable_profile" "" "" "enables profiling"
makl_args_def "enable_sup_fs" "" "" "enables filesystem web access"
makl_args_def "enable_fs" "" "" "--enable_sup_fs alias"
makl_args_def "enable_sup_cgi" "" "" "enables external CGIs"
makl_args_def "enable_cgi" "" "" "--enable_sup_cgi alias"
makl_args_def "enable_sup_kilt" "" "" "enables kilt module"
makl_args_def "enable_kilt" "" "" "--enable_sup_kilt alias"
makl_args_def "enable_warns" "" "" "set CFLAGS for extra warnings"
makl_args_def "disable_cxx" "" "" "disable C++ support"
makl_args_def "install_daemon_only" "" "" "install just Klone daemon file"
makl_args_def "daemon_name" "=NAME" "" "set the name of Klone daemon"
makl_args_def "enable_hooks" "" "" "call user-provided hooks_setup() to register hooks"
makl_args_def "disable_stack_protector" "" "" "disable stack smashing protection (gcc 4.x)"
makl_args_def "enable_cyassl" "" "" "enables CyaSSL library"


# ... and their handlers
__makl_enable_debug () { makl_set_var_mk "KLONE_DEBUG" ;
                              makl_append_var_mk "CFLAGS" "-g -DDEBUG" ; }
__makl_enable_libu_debug () { makl_set_var_mk "LIBU_DEBUG" ; }
__makl_enable_profile () { makl_append_var_mk "CFLAGS" "-pg -a" ; }

__makl_enable_sup_fs () { makl_set_var "ENABLE_SUP_FS" ; }
__makl_enable_fs () { __makl_enable_sup_fs ; }

__makl_enable_sup_kilt () { makl_set_var "ENABLE_SUP_KILT" ; }
__makl_enable_kilt () { __makl_enable_sup_kilt ; }

__makl_enable_sup_cgi () { makl_set_var "ENABLE_SUP_CGI" ; }
__makl_enable_cgi () { __makl_enable_sup_cgi; }

__makl_disable_cxx () { makl_unset_var "USE_CXX" ; }
__makl_install_daemon_only ()
                            { makl_set_var "INSTALL_DAEMON_ONLY" ; }
__makl_daemon_name () { makl_set_var_mk "DAEMON_NAME" $1 ; }
__makl_enable_hooks() { makl_set_var "ENABLE_HOOKS" ; }
__makl_enable_warns ()
{
    makl_append_var_mk "CFLAGS" \
        "-W -Wall -Wstrict-prototypes -Wmissing-prototypes" \
        "-Wpointer-arith -Wno-uninitialized -Wreturn-type" \
        "-Wwrite-strings -Wswitch -Wshadow -Wwrite-strings" \
        "-Wunreachable-code -Wunused -Wcast-qual"
        #"-pedantic -std=c99"
}
__makl_disable_stack_protector() {
    makl_set_var_mk "DISABLE_STACK_PROTECTOR" "1";
}
__makl_enable_cyassl() {
    makl_set_var_mk "ENABLE_CYASSL"
}

# General settings
makl_pkg_name "klone"
makl_pkg_version

# Source directory
makl_set_var_mk "SRCDIR" "`pwd`"

# Add local 3rd party flags
makl_append_var_mk "CFLAGS" "-I`pwd`/libu/include"

case `makl_target_name` in

    *mingw*)
        makl_set_var "OS_WIN"
        makl_append_var_mk "POST_LDADD" "-lwsock32 -L/c/WINDOWS"
        ;;

    *cygwin*)
        makl_set_var "OS_UNIX"
        makl_append_var_mk "CFLAGS" "-D__addr_t_defined"
        ;;

    *qnx*)
        makl_set_var "OS_UNIX"
        makl_append_var_mk "POST_LDADD" "-lsocket"
        ;;

    *darwin*)
        makl_set_var "OS_UNIX"
        # workaround to avoid circular dependency errors on Mac OS X
        makl_set_var "PRE_LDADD" "-ldl"
        makl_append_var_mk "POST_LDADD" "-lc"
        ;;

    sunos*)
        makl_set_var "OS_UNIX"
        makl_add_var_mk "LDFLAGS" "-lsocket -lnsl"
        ;;

    minix*)
        makl_set_var "OS_UNIX"
        makl_append_var_mk "CFLAGS" "-D_POSIX_SOURCE"
        ;;

    *)
        makl_set_var "OS_UNIX"
        ;;
esac

makl_append_var_mk "CFLAGS" "-I`pwd` -DHAVE_CONF_H"

# these enable .klx pages
makl_set_var_mk "USE_CXX" "1"
makl_append_var_mk "CXXFLAGS" "\${CFLAGS}"

# check for stdint header
makl_checkheader 0 "stdint" "<stdint.h>"
makl_checkheader 0 "getopt" "<getopt.h>"
makl_checkheader 0 "unistd" "<unistd.h>"
makl_checkheader 0 "sys_select" "<sys/select.h>"
makl_checkheader 0 "sys_wait" "<sys/wait.h>"
makl_checkheader 0 "sys_dir" "<sys/dir.h>"

makl_checkheader 0 "sys_socket" "<sys/socket.h>"
 
makl_checksymbol 0 "LOG_PERROR" "<syslog.h>"
makl_checksymbol 0 "SA_RESTART" "<signal.h>"
makl_checksymbol 0 "TCP_NODELAY" "<sys/types.h>" \
                                            "<netinet/tcp.h>"

# Library dependencies
makl_optional 1 "lib" "openssl" "" "-lssl -lcrypto"
makl_optional 1 "lib" "openssl_psk" "" "-lssl -lcrypto"
makl_optional 1 "lib" "z"
makl_optional 1 "lib" "cyassl" "-DNO_FILESYSTEM" "-lcyassl"

# Function dependencies
makl_checktype 0 "pid_t" "<sys/types.h>"

makl_checkstructelem 0 "struct tm" "tm_gmtoff" "<time.h>"

# working fork()?
makl_checkfork 0

# -fstack-protector-all
makl_checkstackp 0

# check va_list behaviour
makl_va_list_by_value

makl_checkfunc 0 "syslog" "" ""
makl_checkfunc 0 "mkstemp" "" ""
makl_checkfunc 0 "localtime_r" "" ""

makl_checkinline 0
if [ $? -ne 0 ]; then
    makl_append_var_mk "CFLAGS" "-Dinline="
fi

# Binary dependencies
makl_optional 1 "featx" "doxygen"

# Handle command-line arguments
makl_args_handle "$@"

# Add include dirs into top-level CFLAGS
# makl_add_var_mk "CFLAGS" "\$(LIBOPENSSL_CFLAGS)"
makl_add_var_mk "CFLAGS" "\$(LIBZ_CFLAGS)"

# if debug is not enabled add optimization flags
if [ -z "`makl_get_var_mk "KLONE_DEBUG"`" ]; then
    makl_append_var_mk "CFLAGS" "-O2"
fi

# adds -fstack-protector-all to the CFLAGS when supported by the compiler
if [ -z "`makl_get_var_mk "DISABLE_STACK_PROTECTOR"`" ]; then
    if [ "`makl_get_var_mk "HAVE_STACK_PROTECTOR"`" ]; then
        makl_append_var_mk "CFLAGS" "-fstack-protector-all"
    fi
fi

if [ "`makl_get_var_mk "ENABLE_SUP_CGI"`" -a "`makl_get_var_mk "OS_WIN"`" ];
then
    echo ; echo " ### Error: CGI is not supported on Windows ###"; echo;
    exit 1;
fi


if [ "`makl_get_var_mk "HAVE_LIBCYASSL"`" -a "`makl_get_var_mk "ENABLE_CYASSL"`" ];
then
    makl_set_var "SSL_ON"
    makl_set_var "SSL_CYASSL"
    makl_set_var_mk "SSL_CFLAGS" "\$(LIBCYASSL_CFLAGS)"
    makl_set_var_mk "SSL_LDFLAGS" "\$(LIBCYASSL_LDFLAGS)"
    makl_set_var_mk "SSL_LDADD" "\$(LIBCYASSL_LDADD)"
else
    if [ "`makl_get_var_mk "HAVE_LIBOPENSSL"`" ];
    then
        makl_set_var "SSL_ON"
        makl_set_var "SSL_OPENSSL"
        makl_set_var_mk "SSL_CFLAGS" "\$(LIBOPENSSL_CFLAGS)"
        makl_set_var_mk "SSL_LDFLAGS" "\$(LIBOPENSSL_LDFLAGS)"
        makl_set_var_mk "SSL_LDADD" "\$(LIBOPENSSL_LDADD)"
    fi
    if [ "`makl_get_var_mk "HAVE_LIBOPENSSL_PSK"`" ];
    then
        makl_set_var "SSL_OPENSSL_PSK"
    fi
fi

# apply substitutions
makl_file_sub "skin/default/Makefile" \
              "doc/doxy/kl1.doxy"

# check if --libs were supplied: in case forward its value to libu build
__libs=`makl_get "__libs__"`
[ "${__libs}" ] && makl_set_var_mk "LIBU_LIBS" "${__libs}"

. "${MAKL_DIR}"/cf/makl.term
Something went wrong with that request. Please try again.