1# Required initializer
2AC_INIT
3
4AM_INIT_AUTOMAKE(nss_compat_ossl, 1.0)
5
6# Find the compiler
7
8# We want these before the checks, so the checks can modify their values.
9test -z "$CFLAGS"  && CFLAGS= auto_cflags=1
10test -z "$CC" && cc_specified=yes
11
12AC_PROG_CC
13AC_PROG_LIBTOOL
14
15# Check for typedefs, structures, and compiler characteristics.
16AC_C_CONST
17
18# Check for header files
19AC_HEADER_STDC
20AC_CHECK_HEADERS( \
21unistd.h
22)
23
24AC_CHECKING(for NSPR)
25
26# check for --with-nspr
27AC_MSG_CHECKING(for --with-nspr)
28AC_ARG_WITH(nspr, [  --with-nspr=PATH        Netscape Portable Runtime (NSPR) directory],
29[
30  if test -e "$withval"/include/nspr.h -a -d "$withval"/lib
31  then
32    AC_MSG_RESULT([using $withval])
33    NSPRDIR=$withval
34    nspr_inc="-I$NSPRDIR/include"
35    nspr_lib="-L$NSPRDIR/lib"
36  else
37    echo
38    AC_MSG_ERROR([$withval not found])
39  fi
40],
41AC_MSG_RESULT(no))
42
43# check for --with-nspr-inc
44AC_MSG_CHECKING(for --with-nspr-inc)
45AC_ARG_WITH(nspr-inc, [  --with-nspr-inc=PATH    Netscape Portable Runtime (NSPR) include file directory],
46[
47  if test -e "$withval"/nspr.h
48  then
49    AC_MSG_RESULT([using $withval])
50    nspr_inc="-I$withval"
51  else
52    echo
53    AC_MSG_ERROR([$withval not found])
54  fi
55],
56AC_MSG_RESULT(no))
57
58# check for --with-nspr-lib
59AC_MSG_CHECKING(for --with-nspr-lib)
60AC_ARG_WITH(nspr-lib, [  --with-nspr-lib=PATH    Netscape Portable Runtime (NSPR) library directory],
61[
62  if test -d "$withval"
63  then
64    AC_MSG_RESULT([using $withval])
65    nspr_lib="-L$withval"
66  else
67    echo
68    AC_MSG_ERROR([$withval not found])
69  fi
70],
71AC_MSG_RESULT(no))
72
73# if NSPR is not found yet, try pkg-config
74
75# last resort
76if test -z "$nspr_inc" -o -z "$nspr_lib"; then
77  AC_MSG_CHECKING(for nspr with pkg-config)
78  AC_PATH_PROG(PKG_CONFIG, pkg-config)
79  if test -n "$PKG_CONFIG"; then
80    if $PKG_CONFIG --exists nspr; then
81      nspr_inc=`$PKG_CONFIG --cflags-only-I nspr`
82      nspr_libdir=`$PKG_CONFIG --libs-only-L nspr`
83      nspr_libs=`$PKG_CONFIG --libs nspr`
84      nspr_lib="${nspr_libdir} ${nspr_libs}"
85    else
86      AC_MSG_ERROR([NSPR not found, specify with --with-nspr.])
87    fi
88  fi
89fi
90
91AC_CHECKING(for NSS)
92
93# check for --with-nss
94AC_MSG_CHECKING(for --with-nss)
95AC_ARG_WITH(nss, [  --with-nss=PATH         Network Security Services (NSS) directory],
96[
97  if test -e "$withval"/include/nss.h -a -d "$withval"/lib
98  then
99    AC_MSG_RESULT([using $withval])
100    NSSDIR=$withval
101    nss_inc="-I$NSSDIR/include"
102    nss_lib="-L$NSSDIR/lib"
103  else
104    echo
105    AC_MSG_ERROR([$withval not found])
106  fi
107],
108AC_MSG_RESULT(no))
109
110# check for --with-nss-inc
111AC_ARG_WITH(nss-inc, [  --with-nss-inc=PATH     Network Security Services (NSS) include directory],
112[
113  if test -e "$withval"/nss.h
114  then
115    AC_MSG_RESULT([using $withval])
116    nss_inc="-I$withval"
117  else
118    echo
119    AC_MSG_ERROR([$withval not found])
120  fi
121],
122AC_MSG_RESULT(no))
123
124# check for --with-nss-lib
125AC_MSG_CHECKING(for --with-nss-lib)
126AC_ARG_WITH(nss-lib, [  --with-nss-lib=PATH     Network Security Services (NSS) library directory],
127[
128  if test -d "$withval"
129  then
130    AC_MSG_RESULT([using $withval])
131    nss_lib="-L$withval"
132  else
133    echo
134    AC_MSG_ERROR([$withval not found])
135  fi
136],
137AC_MSG_RESULT(no))
138
139# if NSS is not found yet, try pkg-config
140
141# last resort
142if test -z "$nss_inc" -o -z "$nss_lib"; then
143  AC_MSG_CHECKING(for nss with pkg-config)
144  AC_PATH_PROG(PKG_CONFIG, pkg-config)
145  if test -n "$PKG_CONFIG"; then
146    if $PKG_CONFIG --exists nss; then
147      nss_inc=`$PKG_CONFIG --cflags-only-I nss`
148      nss_libdir=`$PKG_CONFIG --libs-only-L nss`
149      nss_libs=`$PKG_CONFIG --libs nss`
150      nss_lib="${nss_libdir} ${nss_libs}"
151    else
152      AC_MSG_ERROR([NSS not found, specify with --with-nss.])
153    fi
154  fi
155fi
156
157# Substitute values
158AC_SUBST(nspr_inc)
159AC_SUBST(nspr_lib)
160AC_SUBST(nss_inc)
161AC_SUBST(nss_lib)
162
163# Write config.status and the Makefile
164AC_OUTPUT(Makefile src/Makefile)
165