1#!/bin/sh 2 3# this is GNU-style autoconf script 4 5if [ "X$PREFIX" = "X" ]; then 6 PREFIX='/usr/local' 7fi 8CFLAGS="-I/usr/local/include $CFLAGS" 9LIBS="-L/usr/local/lib $LIBS $LDFLAGS $LFLAGS" 10 11show_help=0 12while [ "X$1" != "X" ]; do 13 case $1 in 14 *-help*) 15 show_help=1 16 ;; 17 *-prefix) 18 shift 19 PREFIX=$1 20 ;; 21 *-prefix=*) 22 PREFIX=`echo $1 | sed -e 's/^.*-prefix=//'` 23 ;; 24 CC=*) 25 CC=`echo $1 | sed -e 's/^CC=//'` 26 ;; 27 CFLAGS=*) 28 CFLAGS="$CFLAGS "`echo $1 | sed -e 's/^CFLAGS=//'` 29 ;; 30 LIBS=*) 31 LIBS="$LIBS "`echo $1 | sed -e 's/^LIBS=//'` 32 ;; 33 LDFLAGS=*) 34 LIBS="$LIBS "`echo $1 | sed -e 's/^LDFLAGS=//'` 35 ;; 36 LFLAGS=*) 37 LIBS="$LIBS "`echo $1 | sed -e 's/^LFLAGS=//'` 38 ;; 39 *) 40 show_help=2 41 ;; 42 esac 43 shift 44done 45 46if [ "X$show_help" != "X0" ]; then 47 echo "Usage: configure [options]" 48 echo " --help print this message" 49 echo " --prefix=foo specify install prefix" 50 if [ "X$show_help" = "X2" ]; then 51 exit 1 52 fi 53 exit 0 54fi 55 56 57echo "Configuring LDAPDNS" 58 59# detect compiler 60if [ "X$CC" = "X" ]; then 61 CC=cc 62fi 63 64echo -n "Testing C compiler: " 65cat > test_1.c <<__test_1_eof 66main(int argc, char *argv[]) {return 0; } 67__test_1_eof 68 69if $CC -c test_1.c -o test_1.o >/dev/null 2>&1; then 70 if $CC -o test_1 test_1.o >/dev/null 2>&1; then 71 rm -f test_1 test_1.o test_1.c 72 if $CC -v 2>&1 | grep gcc >/dev/null 2>&1; then 73 if ! $CC -pthread 2>&1 | grep 'unrecognized option' >/dev/null 2>&1; then 74 echo "gcc-pthread ($CC)" 75 CFLAGS="$CFLAGS -pthread" 76 elif ! $CC -pthread 2>&1 | grep 'unrecognized option' >/dev/null 2>&1; then 77 echo "gcc-pthread ($CC)" 78 CFLAGS="$CFLAGS -pthread" 79 else 80 echo "gcc ($CC)" 81 fi 82 else 83 echo "$CC" 84 fi 85 else 86 echo "failed!" 87 rm -f test_1.o test_1.c 88 echo Cannot cannot create executables";" check your linker or \$CC 89 exit 1 90 fi 91else 92 echo "failed!" 93 rm -f test_1.c 94 echo Cannot launch C compiler, or it cannot create objects";" check \$CC 95 exit 1 96fi 97 98echo -n "Checking for syslog support: " 99cat > test_1.c <<__test_1_eof 100#include <syslog.h> 101int main(int argc, char *argv[]) { openlog("test", 0, 0); return 0; } 102__test_1_eof 103if $CC -o test_1 -c test_1.c >/dev/null 2>&1; then 104 echo "ok" 105 rm -f test_1 test_1.c 106 CFLAGS="$CFLAGS -DHAVE_SYSLOG" 107else 108 echo "disabled" 109 rm -f test_1.c 110fi 111 112echo -n "Checking for memzero: " 113cat > test_1.c <<__test_1_eof 114#include <string.h> 115#include <stdlib.h> 116int main(int argc, char *argv[]) { memzero(0,0); return 0; } 117__test_1_eof 118if $CC -o test_1 test_1.c >/dev/null 2>&1; then 119 echo "ok" 120 rm -f test_1 test_1.c 121 CFLAGS="$CFLAGS -DHAVE_MEMZERO" 122else 123 rm -f test_1.c 124 cat > test_1.c <<__test_1_eof 125#include <string.h> 126#include <stdlib.h> 127int main(int argc, char *argv[]) { bzero(0,0); return 0; } 128__test_1_eof 129 if $CC -o test_1 test_1.c >/dev/null 2>&1; then 130 echo "bzero" 131 rm -f test_1 test_1.c 132 CFLAGS="$CFLAGS -DHAVE_BZERO" 133 else 134 rm -f test_1.c 135 cat > test_1.c <<__test_1_eof 136#include <string.h> 137#include <stdlib.h> 138int main(int argc, char *argv[]) { memset(0,0,0); return 0; } 139__test_1_eof 140 if $CC -o test_1 test_1.c >/dev/null 2>&1; then 141 echo "memset" 142 rm -f test_1 test_1.c 143 CFLAGS="$CFLAGS -DHAVE_MEMSET" 144 else 145 rm -f test_1.c 146 echo "emulated" 147 fi 148 fi 149fi 150 151echo -n "Checking for memcpy: " 152cat > test_1.c <<__test_1_eof 153#include <string.h> 154#include <stdlib.h> 155int main(int argc, char *argv[]) { memcpy(0,0,0); return 0; } 156__test_1_eof 157if $CC -o test_1 test_1.c >/dev/null 2>&1; then 158 echo "ok" 159 rm -f test_1 test_1.c 160 CFLAGS="$CFLAGS -DHAVE_MEMCPY" 161else 162 rm -f test_1.c 163 cat > test_1.c <<__test_1_eof 164#include <string.h> 165#include <stdlib.h> 166int main(int argc, char *argv[]) { bcopy(0,0,0); return 0; } 167__test_1_eof 168 if $CC -o test_1 test_1.c >/dev/null 2>&1; then 169 echo "bcopy" 170 rm -f test_1 test_1.c 171 CFLAGS="$CFLAGS -DHAVE_BCOPY" 172 else 173 rm -f test_1.c 174 echo "emulated" 175 fi 176fi 177 178echo -n "Checking for IPV6 support: " 179cat > test_1.c <<__test_1_eof 180#include <sys/types.h> 181#include <netinet/in.h> 182int main(int argc, char *argv[]) { struct in6_addr foo; return 0; } 183__test_1_eof 184if $CC -o test_1 -c test_1.c >/dev/null 2>&1; then 185 echo "ok" 186 rm -f test_1 test_1.c 187 CFLAGS="$CFLAGS -DHAVE_IPV6" 188else 189 echo "none" 190 rm -f test_1.c 191fi 192 193echo -n "Checking for setsid() support: " 194cat > test_1.c <<__test_1_eof 195#include <unistd.h> 196int main(int argc, char *argv[]) { setsid(); return 0; } 197__test_1_eof 198if $CC -o test_1 test_1.c >/dev/null 2>&1; then 199 echo "ok" 200 rm -f test_1 test_1.c 201 CFLAGS="$CFLAGS -DHAVE_SETSID" 202else 203 echo "disabled" 204 rm -f test_1.c 205fi 206 207echo -n "Checking for poll() support: " 208cat > test_1.c <<__test_1_eof 209#include <sys/poll.h> 210int main(int argc, char *argv[]) { struct pollfd p; poll(&p, 0, 0); return 0; } 211__test_1_eof 212if $CC -o test_1 test_1.c >/dev/null 2>&1; then 213 echo "ok" 214 rm -f test_1 test_1.c 215 CFLAGS="$CFLAGS -DHAVE_POLL" 216else 217 echo "using select()" 218 rm -f test_1.c 219fi 220 221echo -n "Checking for waitpid() support: " 222cat > test_1.c <<__test_1_eof 223#include <sys/types.h> 224#include <sys/wait.h> 225int main(int argc, char *argv[]) { waitpid(0,0,0); return 0; } 226__test_1_eof 227if $CC -o test_1 test_1.c >/dev/null 2>&1; then 228 echo "ok" 229 rm -f test_1 test_1.c 230 CFLAGS="$CFLAGS -DHAVE_WAITPID" 231else 232 echo "failed" 233 rm -f test_1.c 234 235 echo -n "Checking for wait4() support: " 236 cat > test_1.c <<__test_1_eof 237#include <sys/types.h> 238#include <sys/time.h> 239#include <sys/resource.h> 240int main(int argc, char *argv[]) { wait4(0,0,0,0); return 0; } 241__test_1_eof 242 if $CC -o test_1 -c test_1.c >/dev/null 2>&1; then 243 rm -f test_1 test_1.c 244 CFLAGS="$CFLAGS -DHAVE_WAIT4" 245 else 246 rm -f test_1.c 247 fi 248fi 249 250echo -n "Checking for POSIX threads: " 251cat > test_1.c <<__test_1_eof 252#include <pthread.h> 253int main(int argc, char *argv[]) { pthread_create(0,0,0,0); return 0; } 254__test_1_eof 255if $CC $LIBS $CFLAGS -o test_1 test_1.c >/dev/null 2>&1; then 256 echo "ok" 257elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lc_r >/dev/null 2>&1; then 258 echo "-lc_r" 259 LIBS="$LIBS -lc_r" 260elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lpthread >/dev/null 2>&1; then 261 echo "-lpthread" 262 LIBS="$LIBS -lpthread" 263else 264 echo "no idea" 265 exit 1 266fi 267 268echo -n "Checking for non-portable pthreads extensions: " 269cat > test_1.c <<__test_1_eof 270#include <pthread.h> 271int main(int argc, char *argv[]) { pthread_kill_other_threads_np(); return 0; } 272__test_1_eof 273if $CC $LIBS $CFLAGS -o test_1 test_1.c >/dev/null 2>&1; then 274 echo "pthread_kill_other_threads_np" 275 CFLAGS="$CFLAGS -DHAVE_pthread_kill_other_threads_np" 276else 277 echo "none" 278fi 279 280 281LIBS="$LIBS -lldap -llber" 282echo -n "Checking OpenLDAP dependencies: " 283cat > test_1.c <<__test_1_eof 284#include <ldap.h> 285#include <lber.h> 286int main(int argc, char *argv[]) { LDAP *x = ldap_open(0,0); bind(0,0,0); connect(0,0,0); return 0; } 287__test_1_eof 288if $CC $LIBS $CFLAGS -o test_1 test_1.c >/dev/null 2>&1; then 289 echo "ok" 290elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket >/dev/null 2>&1; then 291 echo "-lsocket" 292 LIBS="$LIBS -lsocket" 293elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lnsl -lssl >/dev/null 2>&1; then 294 echo "-lsocket -lnsl" 295 LIBS="$LIBS -lsocket -lnsl" 296elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lnsl >/dev/null 2>&1; then 297 echo "-lsocket -lnsl" 298 LIBS="$LIBS -lsocket -lnsl" 299elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lresolv >/dev/null 2>&1; then 300 echo "-lresolv" 301 LIBS="$LIBS -lresolv" 302elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lrt -lresolv >/dev/null 2>&1; then 303 echo "-lrt -lresolv" 304 LIBS="$LIBS -lrt -lresolv" 305elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lrt -lresolv -lssl >/dev/null 2>&1; then 306 echo "-lrt -lresolv" 307 LIBS="$LIBS -lrt -lresolv" 308elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lresolv >/dev/null 2>&1; then 309 echo "-lsocket -lresolv" 310 LIBS="$LIBS -lsocket -resolv" 311elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lnsl -lresolv >/dev/null 2>&1; then 312 echo "-lsocket -lnsl -lresolv" 313 LIBS="$LIBS -lsocket -lnsl -resolv" 314elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lnsl -lresolv -lssl >/dev/null 2>&1; then 315 echo "-lsocket -lnsl -lresolv" 316 LIBS="$LIBS -lsocket -lnsl -resolv" 317elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lcrypto -lssl -lrt -lresolv -lsocket -lnsl >/dev/null 2>&1; then 318 echo "-lcrypto -lssl -lrt -lresolv -lsocket -lnsl" 319 LIBS="$LIBS -lcrypto -lssl -lrt -lresolv -lsocket -lnsl" 320else 321 echo "no idea" 322 exit 1 323fi 324rm -f test_1.c test_1 325 326echo -n "Checking for OpenLDAP < 2.1.8: " 327cat > test_1.c <<__test_1_eof 328#include <ldap.h> 329#include <lber.h> 330int main(int argc, char *argv[]) { ldap_enable_cache(0, 1, 0); } 331__test_1_eof 332if $CC $LIBS $CFLAGS -o test_1 test_1.c >/dev/null 2>&1; then 333 echo "yes" 334 CFLAGS="$CFLAGS -DACCELERATE_CACHE" 335else 336 echo "no" 337fi 338 339 340echo -n "Writing Makefile.config: " 341echo '# this file is automatically generated: do not edit' > Makefile.config 342echo CC=$CC >> Makefile.config 343echo CFLAGS="$CFLAGS" >> Makefile.config 344echo LFLAGS="$LIBS" >> Makefile.config 345echo "done" 346echo "" 347 348# adjust timestamps 349touch *.c *.h 350 351exit 0 352