summaryrefslogtreecommitdiffstats
path: root/configure.in
blob: bd7e8e50e670ea1181989b0269a64945e24fcde6 (plain)
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
# Required initializer
AC_INIT

# Automake initialization
AM_INIT_AUTOMAKE(mod_nss, 1.0)

# Add a test for a compiler.
AC_PROG_CC
AM_PROG_LIBTOOL

# Check for header files
AC_HEADER_STDC
AC_CHECK_HEADERS( \
unistd.h
)

# Check for typedefs, structures, and compiler characteristics.
AC_C_CONST

# Find lex and yacc (or flex and bison)
AC_PROG_YACC
AC_PROG_LEX
AC_DECL_YYTEXT

AC_CHECKING(for apr-config)
# check for --with-apr-config
AC_MSG_CHECKING(for --with-apr-config)
AC_ARG_WITH(apr-config, [--with-apr-config 	Use apr-config to determine the APR directory],
[
  AC_PATH_PROG(APR_CONFIG, apr-config)
  if test -n "$APR_CONFIG"; then
    apr_inc=`$APR_CONFIG --includes`
  else
    AC_MSG_ERROR([apr-config not found])
  fi
],
AC_MSG_RESULT(no))

AC_CHECKING(for apxs)

# check for --with-apxs
AC_MSG_CHECKING(for --with-apxs)
AC_ARG_WITH(apxs, [--with-apxs=PATH 	Path to apxs],
[
  if test -x "$withval"
  then
    AC_MSG_RESULT([using $withval])
    APXS=$withval
  else
    echo
    AC_MSG_ERROR([$withval not found or not executable])
  fi
],
AC_MSG_RESULT(no))

# if no apxs found yet, check /usr/local/apache/sbin
# since it's the default Apache location
if test -z "$APXS"; then
  AC_MSG_CHECKING(for apxs in /usr/local/apache/sbin)
  if test -x /usr/local/apache/sbin/apxs; then
    APXS=/usr/local/apache/sbin/apxs
    AC_MSG_RESULT([found $APXS. Use --with-apxs to specify another.])
  else
    AC_MSG_RESULT(no)
  fi
fi

# last resort
if test -z "$APXS"; then
  AC_MSG_CHECKING(for apxs in your PATH)
  AC_PATH_PROG(APXS, apxs)
  if test -n "$APXS"; then
    AC_MSG_RESULT([found $APXS. Use --with-apxs to specify another.])
  fi
fi 

# and finally
if test -z "$APXS"; then
  AC_MSG_ERROR([apxs was not found. use --with-apxs to specifiy it.])
fi

# Get some variables we need for Makefile.in
apache_inc=`$APXS -q INCLUDEDIR`
apache_conf=`$APXS -q SYSCONFDIR`
apache_prefix=`$APXS -q PREFIX`
apache_bin=`$APXS -q SBINDIR`

if ! test -f "$apache_inc/apr.h"; then
  if test -z "$apr_inc"; then
    AC_MSG_ERROR([apr.h is not in your Apache include dir as reported by apxs. Use --with-apr-config to have apr-config tell us where to find it.])
  fi
fi

AC_CHECKING(for NSPR)

# check for --with-nspr
AC_MSG_CHECKING(for --with-nspr)
AC_ARG_WITH(nspr, [--with-nspr=PATH 	Netscape Portable Runtime (NSPR) directory],
[
  if test -e "$withval"/include/nspr.h
  then
    AC_MSG_RESULT([using $withval])
    NSPRDIR=$withval
    nspr_inc="-I$NSPRDIR/include"
    nspr_lib="-L$NSPRDIR/lib"
  else
    echo
    AC_MSG_ERROR([$withval not found])
  fi
],
AC_MSG_RESULT(no))

# if NSPR is not found yet, try pkg-config

# last resort
if test -z "$NSPRDIR"; then
  AC_MSG_CHECKING(for nspr with pkg-config)
  AC_PATH_PROG(PKG_CONFIG, pkg-config)
  if test -n "$PKG_CONFIG"; then
    if $PKG_CONFIG --exists mozilla-nspr; then
      nspr_inc=`$PKG_CONFIG --cflags-only-I mozilla-nspr`
      nspr_lib=`$PKG_CONFIG --libs-only-L mozilla-nspr`
    else
      AC_MSG_ERROR([NSPR not found, specify with --with-nspr.])
    fi
  fi
fi 

AC_CHECKING(for NSS)

# check for --with-nss
AC_MSG_CHECKING(for --with-nss)
AC_ARG_WITH(nss, [--with-nss=PATH 	Network Security Services (NSS) directory],
[
  if test -e "$withval"/include/nss.h
  then
    AC_MSG_RESULT([using $withval])
    NSSDIR=$withval
    nss_inc="-I$NSSDIR/include"
    nss_lib="-L$NSSDIR/lib"
  else
    echo
    AC_MSG_ERROR([$withval not found])
  fi
],
AC_MSG_RESULT(no))

# if NSS is not found yet, try pkg-config

# last resort
if test -z "$NSSDIR"; then
  AC_MSG_CHECKING(for nss with pkg-config)
  AC_PATH_PROG(PKG_CONFIG, pkg-config)
  if test -n "$PKG_CONFIG"; then
    if $PKG_CONFIG --exists mozilla-nss; then
      nss_inc=`$PKG_CONFIG --cflags-only-I mozilla-nss`
      nss_lib=`$PKG_CONFIG --libs-only-L mozilla-nss`
    else
      AC_MSG_ERROR([NSS not found, specify with --with-nss.])
    fi
  fi
fi

nspr_dir=`echo "$nspr_lib" | sed 's/\/lib[[/]]*$//' | sed 's/-L//'`
nss_dir=`echo "$nss_lib" | sed 's/\/lib[[/]]*$//' | sed 's/-L//'`

# Substitute values 
AC_SUBST(APXS)
AC_SUBST(apr_inc)
AC_SUBST(apache_inc)
AC_SUBST(apache_conf)
AC_SUBST(apache_prefix)
AC_SUBST(apache_bin)
AC_SUBST(nspr_inc)
AC_SUBST(nspr_lib)
AC_SUBST(nss_inc)
AC_SUBST(nss_lib)
AC_SUBST(nspr_dir)
AC_SUBST(nss_dir)

# Write config.status and the Makefile
AC_OUTPUT(Makefile nss.conf gencert)

chmod +x gencert