1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(htmlpty.l)
3AC_CONFIG_HEADER(config.h:config.hin)
4
5PACKAGE=htmlpty
6AC_SUBST(PACKAGE)
7AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
8
9VERSION=1.01
10AC_SUBST(VERSION)
11AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
12
13AC_PROG_MAKE_SET
14
15AC_ARG_PROGRAM
16
17dnl Checks for programs.
18AC_PROG_CC
19dnl OMIT (prevents builds on systems without a C++ compiler): AC_PROG_CXX
20AC_PROG_INSTALL
21AC_PROG_LN_S
22AC_CHECK_PROGS(AWK,gawk nawk mawk awk)
23AC_CHECK_PROGS(CAT,cat)
24AC_CHECK_PROGS(CHECKSUM,checksum cat)
25AC_CHECK_PROGS(CHMOD,chmod)
26AC_CHECK_PROG(COL,col,col -x -b)
27AC_CHECK_PROG(COL,cat)
28
29AC_CHECK_PROG(CP,scp,scp -p)
30AC_CHECK_PROG(CP,rcp,rcp -p)
31AC_CHECK_PROG(CP,cp,cp)
32
33AC_CHECK_PROGS(DEROFF,deroff cat)
34AC_CHECK_PROGS(DIFF,diff)
35AC_CHECK_PROGS(DISTILL,distill true)
36AC_CHECK_PROGS(DW,dw true)
37AC_CHECK_PROGS(EXPAND,expand cat)
38AC_CHECK_PROGS(FIND,find)
39AC_CHECK_PROGS(GREP,grep)
40AC_CHECK_PROGS(GROFF,groff true)
41AC_CHECK_PROGS(GZIP,gzip)
42AC_CHECK_PROGS(HTMLCHECK,html-ncheck html-check true)
43AC_CHECK_PROGS(ISPELL,ispell true)
44AC_CHECK_PROGS(LEX,flex lex)
45AC_CHECK_PROGS(LN,ln)
46AC_CHECK_PROGS(LS,ls)
47AC_CHECK_PROG(MKDIR,mkdir,mkdir -p)
48AC_CHECK_PROGS(MPACK,mpack)
49AC_CHECK_PROGS(MV,mv)
50AC_CHECK_PROG(NROFF,groff,groff -Tascii)
51AC_CHECK_PROG(NROFF,nroff,nroff)
52AC_CHECK_PROGS(SED,sed)
53AC_CHECK_PROGS(SHAR,shar)
54AC_CHECK_PROGS(SORT,sort)
55AC_CHECK_PROGS(SPELL,spell)
56AC_CHECK_PROGS(TAR,gnutar gtar tar)
57AC_CHECK_PROGS(TEE,tee)
58AC_CHECK_PROGS(TOUCH,touch)
59AC_CHECK_PROGS(TR,tr)
60AC_CHECK_PROGS(TRUE,true)
61AC_CHECK_PROGS(UNZIP,unzip)
62AC_CHECK_PROGS(UUENCODE,uue uuencode)
63AC_CHECK_PROGS(ZIP,zip)
64AC_CHECK_PROGS(ZOO,zoo)
65
66dnl Checks for libraries.
67dnl These tests for -ll and -l are borrowed from bibparse-1.04:
68
69LEX="$ac_cv_prog_LEX"
70dnl GNU/Linux has a unique /usr/bin/yacc, distinct from
71dnl /usr/bin/bison, but its /usr/bin/lex is just a symlink to
72dnl /usr/bin/flex.  Unfortunately, on older such systems, they forgot
73dnl that /usr/lib/libl.a should then be a symlink to /usr/lib/libfl.a,
74dnl so -ll doesn't exist.  We therefore have to try both -ll and -lfl,
75dnl sigh...
76if test "xx$LEX" = "xxlex"
77then
78    if test "xx$cc_lang" = "xxC++"
79    then
80	AC_MSG_CHECKING(for lex/flex library)
81	SAVELIBS="$LIBS"
82	LIBS="$SAVELIBS -ll"
83	AC_TRY_LINK(,,LL=-ll,
84		[LIBS="$SAVELIBS -lfl"
85		AC_TRY_LINK(,,LL=-lfl,LL=)])
86	LIBS="$SAVELIBS $LL"
87	AC_MSG_RESULT($LL)
88    else
89	AC_CHECK_LIB(l,yywrap,,AC_CHECK_LIB(fl,yywrap))
90    fi
91else
92    LDFLAGS="-L/usr/local/lib $LDFLAGS"
93    if test "xx$cc_lang" = "xxC++"
94    then
95	AC_MSG_CHECKING(for flex library)
96	SAVELIBS="$LIBS"
97	LIBS="$SAVELIBS -lfl"
98	AC_TRY_LINK(,,LL=-lfl,LL=)
99	LIBS="$SAVELIBS $LL"
100	AC_MSG_RESULT($LL)
101    else
102	AC_CHECK_LIB(fl,yywrap)
103    fi
104fi
105
106dnl If flex is used, we MUST have the -l (lex compatibility) flag set,
107dnl and if lex is really flex, we still need it.
108dnl
109dnl The construction of this test is tricky: originally, I just used
110dnl	echo %% >conftest.l
111dnl     if lex -l conftest.l 2>/dev/null 1>&2
112dnl	...
113dnl to create a minimal lex file and run lex on it.
114dnl
115dnl However, on SGI IRIX 5.x and 6.x systems, instead of causing an
116dnl error, the undocumented -l switch causes lex to hang in an input
117dnl wait indefinitely.  The solution adopted below is to pipe the
118dnl input to lex, which avoids the hang.
119dnl
120dnl On HP HP-UX 10.01 systems, lex will complain about an unrecognized
121dnl -l argument, but that is just a warning, and otherwise causes no
122dnl problems.
123dnl
124dnl Unfortunately, that test breaks on IBM AIX 4.2 systems, whose lex
125dnl writes an error message "0: Warning: 1285-300 The l flag is not
126dnl valid."  onto stdout, instead of stderr, preventing compilation!
127dnl Argh....  Thus, we need another test for that system first,
128dnl sigh...
129dnl
130dnl All of this grief happens because the GNU/Linux people botched
131dnl their job in the first place!  Compatible programs should be
132dnl compatible!
133
134if test "xx$LEX" = "xxflex"
135then
136    LEX="flex -l"
137elif test "xx$LEX" = "xxlex"
138then
139    if test "xx`uname -s`" = "xxAIX"
140    then
141	true
142    elif echo %% | lex -l 2>/dev/null 1>&2
143    then
144	LEX="lex -l"
145    fi
146    rm -f lex.yy.c 2>/dev/null
147fi
148
149dnl Checks for Standard C/C++ function declarations.
150AC_MSG_CHECKING(for Standard C/C++ function declarations)
151AC_TRY_COMPILE([void foo(void){}
152int bar(int x, float y, char z){return 1;}], ,
153  [AC_MSG_RESULT(yes)
154    AC_DEFINE(STDC)],
155    AC_MSG_RESULT(no))
156
157dnl Checks for void* pointer support
158AC_MSG_CHECKING(for void* pointer support)
159AC_TRY_COMPILE(,[char *p = (char*)(void*)"x";],
160  [AC_MSG_RESULT(yes)
161    AC_DEFINE(HAVE_VOIDP)],
162    [AC_MSG_RESULT(no)])
163
164dnl Checks for header files.
165AC_HEADER_STDC
166
167dnl Checks for Standard C/C++ prototype support
168AC_MSG_CHECKING(for Standard C/C++ prototype support)
169AC_TRY_COMPILE(,
170	[ extern int foo(int a, float b, char *c, double d); ],
171	[AC_MSG_RESULT(yes)
172	    AC_DEFINE(HAVE_STDC_PROTOTYPES)],
173	[AC_MSG_RESULT(no)])
174
175dnl Checks for typedefs, structures, and compiler characteristics.
176AC_C_CONST
177AC_TYPE_SIZE_T
178
179dnl Checks for header files
180AC_CHECK_HEADERS(ctype.h fcntl.h io.h jsys.h libc.h  \
181		limits.h pwd.h stdio.h stdlib.h string.h \
182		sys/types.h sys/utsname.h time.h unistd.h)
183
184dnl Checks for library functions.
185AC_CHECK_FUNCS(strtok)
186AC_PROG_GCC_TRADITIONAL
187dnl Remove -g from CFLAGS if we are compiling with lcc because it
188dnl produces bad debug symbol tables on Sun Solaris 2.x.
189if test "$CC" = "lcc"
190then
191    CFLAGS="`echo $CFLAGS | sed -e 's/-g //g' -e 's/ -g$//g' -e 's/^-g$//'`"
192fi
193
194dnl Checks for ctime() argument type
195AC_MSG_CHECKING(for argument type of ctime())
196AC_TRY_COMPILE([#include <time.h>],
197	[ char *p; p = ctime((const time_t *)0);],
198	[AC_MSG_RESULT(const time_t *)
199	    AC_DEFINE(CTIME_ARG_IS_TIME_T_POINTER)],
200	[AC_MSG_RESULT(long *)])
201
202dnl Checks for gethostname() declaration
203AC_MSG_CHECKING(for gethostname() declaration)
204AC_EGREP_CPP(gethostname,[#include <unistd.h>],
205  [AC_MSG_RESULT(yes)
206    AC_DEFINE(HAVE_GETHOSTNAME)
207    AC_DEFINE(HAVE_GETHOSTNAME_DECL)],
208    AC_MSG_RESULT(no))
209
210dnl Checks for gethostname() language: C or C++
211AC_MSG_CHECKING(for gethostname() language: C or C++)
212AC_TRY_LINK([int gethostname(char *,int);],
213  [(void)gethostname((char*)0,0);],
214  [AC_MSG_RESULT(C++)
215    AC_DEFINE(HAVE_GETHOSTNAME)
216    AC_DEFINE(HAVE_GETHOSTNAME_IN_CPLUSPLUS)],
217    AC_MSG_RESULT(C))
218
219dnl Checks for gethostname() language: C or C++
220AC_MSG_CHECKING(for gethostname() language: C or C++)
221AC_TRY_LINK([#include <unistd.h>],
222  [(void)gethostname((char*)0,0);],
223  [AC_MSG_RESULT(C++)
224    AC_DEFINE(HAVE_GETHOSTNAME)
225    AC_DEFINE(HAVE_GETHOSTNAME_IN_CPLUSPLUS)],
226    AC_MSG_RESULT(C))
227
228dnl Checks for getlogin() declaration (e.g. NeXT has it only in POSIX environment)
229AC_MSG_CHECKING(for getlogin() declaration)
230AC_EGREP_CPP(getlogin,[#include <unistd.h>],
231  [AC_MSG_RESULT(yes)
232    AC_DEFINE(HAVE_GETLOGIN)
233    AC_DEFINE(HAVE_GETLOGIN_DECL)],
234    AC_MSG_RESULT(no))
235
236dnl Checks for getlogin() language: C or C++
237AC_MSG_CHECKING(for getlogin() language: C or C++)
238AC_TRY_LINK([char *getlogin(void);],
239  [(void)getlogin();],
240  [AC_MSG_RESULT(C++)
241    AC_DEFINE(HAVE_GETLOGIN)
242    AC_DEFINE(HAVE_GETLOGIN_IN_CPLUSPLUS)],
243    AC_MSG_RESULT(C))
244
245dnl Checks for getpwnam() declaration
246AC_MSG_CHECKING(for getpwnam() declaration)
247AC_EGREP_CPP(getpwnam,[#include <pwd.h>],
248  [AC_MSG_RESULT(yes)
249    AC_DEFINE(HAVE_GETPWNAM)
250    AC_DEFINE(HAVE_GETPWNAM_DECL)],
251    AC_MSG_RESULT(no))
252
253dnl Checks for getpwnam() language: C or C++
254AC_MSG_CHECKING(for getpwnam() language: C or C++)
255AC_TRY_LINK([#include <pwd.h>
256struct passwd *getpwnam(const char*);],
257  [(void)getpwnam((void*)0);],
258  [AC_MSG_RESULT(C++)
259    AC_DEFINE(HAVE_GETPWNAM)
260    AC_DEFINE(HAVE_GETPWNAM_IN_CPLUSPLUS)],
261    AC_MSG_RESULT(C))
262
263dnl Checks for getpwnam() language: C or C++
264AC_MSG_CHECKING(for getpwnam() language: C or C++)
265AC_TRY_LINK([#include <pwd.h>],
266  [(void)getpwnam((void*)0);],
267  [AC_MSG_RESULT(C++)
268    AC_DEFINE(HAVE_GETPWNAM)],
269    AC_MSG_RESULT(C))
270
271dnl Checks for getpwuid() declaration
272AC_MSG_CHECKING(for getpwuid() declaration)
273AC_EGREP_CPP(getpwuid,[#include <pwd.h>],
274  [AC_MSG_RESULT(yes)
275    AC_DEFINE(HAVE_GETPWUID)
276    AC_DEFINE(HAVE_GETPWUID_DECL)],
277    AC_MSG_RESULT(no))
278
279dnl Checks for getpwuid() language: C or C++
280AC_MSG_CHECKING(for getpwuid() language: C or C++)
281AC_TRY_LINK([#include <pwd.h>
282struct passwd *getpwuid(uid_t);],
283  [(void)getpwuid(0);],
284  [AC_MSG_RESULT(C++)
285    AC_DEFINE(HAVE_GETPWUID)
286    AC_DEFINE(HAVE_GETPWUID_IN_CPLUSPLUS)],
287    AC_MSG_RESULT(C))
288
289dnl Checks for getpwuid() language: C or C++
290AC_MSG_CHECKING(for getpwuid() language: C or C++)
291AC_TRY_LINK([#include <pwd.h>],
292  [(void)getpwuid(0);],
293  [AC_MSG_RESULT(C++)
294    AC_DEFINE(HAVE_GETPWUID)],
295    AC_MSG_RESULT(C))
296
297dnl Checks for getuid() declaration
298AC_MSG_CHECKING(for getuid() declaration)
299AC_EGREP_CPP(getuid,[#include <unistd.h>],
300  [AC_MSG_RESULT(yes)
301    AC_DEFINE(HAVE_GETUID)
302    AC_DEFINE(HAVE_GETUID_DECL)],
303    AC_MSG_RESULT(no))
304
305dnl Checks for getuid() language: C or C++
306AC_MSG_CHECKING(for getuid() language: C or C++)
307AC_TRY_LINK([char *getuid(void);],
308  [(void)getuid();],
309  [AC_MSG_RESULT(C++)
310    AC_DEFINE(HAVE_GETUID)
311    AC_DEFINE(HAVE_GETUID_IN_CPLUSPLUS)],
312    AC_MSG_RESULT(C))
313
314dnl Checks for getuid() language: C or C++
315AC_MSG_CHECKING(for getuid() language: C or C++)
316AC_TRY_LINK([#include <unistd.h>],
317  [(void)getuid();],
318  [AC_MSG_RESULT(C++)
319    AC_DEFINE(HAVE_GETUID)
320    AC_DEFINE(HAVE_GETUID_IN_CPLUSPLUS)],
321    AC_MSG_RESULT(C))
322
323dnl Checks for needing _POSIX_SOURCE to expose struct utsname in <sys/utsname.h>
324AC_MSG_CHECKING(for struct utsname)
325AC_TRY_COMPILE([#include <sys/utsname.h>],
326	[struct utsname uts;],
327	[uts="yes"],
328	[uts="no"])
329
330AC_MSG_RESULT($uts)
331
332if test $uts = "no"
333then
334	AC_MSG_CHECKING(if _POSIX_SOURCE needed for struct utsname)
335	AC_TRY_COMPILE([#define _POSIX_SOURCE 1
336	#include <sys/utsname.h>],
337		[struct utsname uts;],
338		[uts="yes"],
339		[uts="no"])
340		AC_MSG_RESULT($uts)
341		if test $uts = "yes"
342		then
343			AC_DEFINE(_POSIX_SOURCE)
344		fi
345fi
346
347if test $uts = "yes" -a -d /NextLibrary
348then
349	AC_MSG_CHECKING(if -posix needed on NeXT for uname())
350	CFLAGS=-posix
351	AC_TRY_LINK([#define _POSIX_SOURCE 1
352	#include <stdio.h>
353	#include <sys/utsname.h>],
354		[struct utsname uts; (void)uname((struct utsname *)NULL);],
355		[uts="yes"; CFLAGS=-posix],
356		[uts="no"; unset CFLAGS])
357		AC_MSG_RESULT($uts)
358fi
359
360AC_OUTPUT(Makefile)
361