summaryrefslogtreecommitdiffstats
path: root/usr.sbin/httpd/src/helpers/find-dbm-lib
blob: 21a837c37f883b1f2b07ade6dd5550391b17cd91 (plain) (blame)
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
# Our config tool sucks... if this script decides to modify the
# LIBS variable it won't be used by any of the other TestCompiles.
# So unless we protect ourselves with the found_dbm variable
# we'd end up having to do the work twice... and we'd end up putting
# two -ldbm -ldbm into the LIBS variable.

if [ "x$found_dbm" = "x" ]; then
    if sh helpers/TestCompile func dbm_open; then
	found_dbm=1
    else
	found_dbm=0
	case "$PLAT" in
  	    *-linux*)
  		# many systems don't have -ldbm
  		DBM_LIB=""
		if ./helpers/TestCompile lib ndbm dbm_open; then
  		    DBM_LIB="-lndbm"
		    if ./helpers/TestCompile lib db1 dbm_open; then
			# Red Hat needs this; ndbm.h lives in db1
			CFLAGS="$CFLAGS -I/usr/include/db1"
		    fi
		elif ./helpers/TestCompile lib db1 dbm_open; then
		    # For Red Hat 7, if not handled by the ndbm case above
  		    DBM_LIB="-ldb1"
  		    CFLAGS="$CFLAGS -I/usr/include/db1"
                elif ./helpers/TestCompile lib gdbm dbm_open; then
                    DBM_LIB="-lgdbm"
                    CFLAGS="$CFLAGS -I/usr/include/gdbm"
		elif ./helpers/TestCompile lib dbm dbm_open; then
		    DBM_LIB="-ldbm"
		fi
  		if [ "x$DBM_LIB" != "x" ]; then
  		    LIBS="$LIBS $DBM_LIB"
  		    found_dbm=1
  		fi
  		;;
        *-cygwin*)
        # we use the shared DLL version of gdbm if available
        DBM_LIB=""
        if ./helpers/TestCompile lib gdbm dbm_open; then
            DBM_LIB="-lgdbm"
            LIBS="$LIBS $DBM_LIB"
            found_dbm=1
        fi
        ;;
	    *)
		if [ "x$DBM_LIB" != "x" ]; then
		    oldLIBS="$LIBS"
		    LIBS="$LIBS $DBM_LIB"
		    if sh helpers/TestCompile func dbm_open; then
			found_dbm=1
		    else
			found_dbm=0
			LIBS="$oldLIBS"
		    fi
		else
		    for dblib in dbm ndbm db
		    do
			DBM_LIB=""
			if sh helpers/TestCompile lib $dblib dbm_open; then
			    DBM_LIB="-l${dblib}"
			    LIBS="$LIBS $DBM_LIB"
			    found_dbm=1
			    break
			fi
		    done
		fi
		;;
	esac
	if [ "x$found_dbm" = "x1" ]; then
	    echo " + using $DBM_LIB for DBM support"
	fi
    fi
fi