1dnl Process this file with autoconf to produce a configure script.
2dnl
3dnl configure.ac: Part of GNU CSSC.
4dnl
5dnl Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007,
6dnl 2008, 2010, 2011, 2014, 2019 Free Software Foundation, Inc.
7dnl
8dnl This program is free software: you can redistribute it and/or modify
9dnl it under the terms of the GNU General Public License as published by
10dnl the Free Software Foundation, either version 3 of the License, or
11dnl (at your option) any later version.
12dnl
13dnl This program is distributed in the hope that it will be useful,
14dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16dnl GNU General Public License for more details.
17dnl
18dnl You should have received a copy of the GNU General Public License
19dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
20dnl
21
22dnl Initialise.   Look for sccsfile.h to double-check that we are looking
23dnl at the correct directory.
24dnl The package version should match the regexp
25dnl ([0-9]+)\.([0-9]+)([a-z])?
26dnl ...at least according to the "Gnits" rules outlined
27dnl in the Automake manual.
28dnl   usually use -git to indicate that the person who compiled
29dnl   the code got it from git.
30AC_INIT([GNU CSSC], [1.4.1], [bug-CSSC@gnu.org], [CSSC])
31AC_CONFIG_SRCDIR([src/sccsfile.h])
32AC_CONFIG_AUX_DIR([build-aux])
33
34# Changes to AC_CONFIG_MACRO_DIR shoulld be reflected in ACLOCAL_AMFLAGS in Makefile.am.
35AC_CONFIG_MACRO_DIR([m4])
36AC_CONFIG_MACRO_DIR([unit-tests/googletest/m4])
37AC_SUBST(AUXDIR,$ac_aux_dir)
38AM_INIT_AUTOMAKE([gnits readme-alpha check-news tar-ustar 1.11.6])
39AC_CONFIG_HEADERS(config.h)
40
41dnl Feature and package checks
42binary_defaulted=no
43AC_MSG_CHECKING([if binary file support should be disabled])
44AC_ARG_ENABLE(binary,
45[--enable-binary
46
47    Enables support for creating "binary" SCCS files (required for
48    interoperability with Solaris).  If binary support is disabled,
49    encoded SCCS files can still be read, but not created.  You should
50    disable this feature only if you need to interoperate with a
51    version of SCCS which lacks binary file support.  To disable this
52    feature, use --enable-binary=no or --disable-binary.  This setting
53    is overridden by the environment variable CSSC_BINARY_SUPPORT.
54
55--disable-binary
56
57    This is the opposite of --enable-binary; see above.
58],
59dnl action if given
60,
61dnl action if not given
62binary_defaulted=yes
63enable_binary=yes
64)
65if test "$enable_binary" = yes; then
66	AC_MSG_RESULT(no)
67else
68	AC_DEFINE([CONFIG_DISABLE_BINARY_SUPPORT], [1], [Define if support for "binary" (encoded) files is to be disabled])
69	AC_MSG_RESULT(yes)
70fi
71if test "$binary_defaulted" = "yes"; then
72	echo WARNING
73	echo WARNING This was assumed because you did not specify either
74	echo WARNING --enable-binary or --disable-binary.
75	echo WARNING
76	# Pause for a bit so that the user notices this message.
77	( sleep 10 2>/dev/null )
78fi
79AC_SUBST(enable_binary)dnl
80
81AC_MSG_CHECKING([for required SCCS file line length limits])
82AC_ARG_ENABLE(max-line-length,
83[--enable-max-line-length=N
84
85    Sets the maximum line length allowed in SCCS files to N.  By
86    default, CSSC has no limit.  Use this option only if you need to
87    make CSSC interoperate with other versions of SCCS.  Setting this
88    option to 0 will impose no limit (which is the default in any case).
89    This setting is overridden by the environment variable
90    CSSC_MAX_LINE_LENGTH.
91
92--disable-max-line-length
93
94    This is equivalent to --enable-max-line-length=0 (which is the default).
95],
96if test "$enable_max_line_length" = "no"
97then
98	enable_max_line_length=0
99	AC_MSG_RESULT(no limit)
100else
101	AC_MSG_RESULT(limit is $enable_max_line_length)
102fi
103max_line_length_description=$enable_max_line_length
104
105,
106AC_MSG_RESULT(no limit)
107enable_max_line_length=0
108)
109AC_DEFINE_UNQUOTED([CONFIG_MAX_BODY_LINE_LENGTH],$enable_max_line_length,
110[Maximum length of line which CSSC will create in an SCCS file])
111
112
113if test $enable_max_line_length -eq 0
114then
115	max_line_length_description="no limit"
116else
117	max_line_length_description=$enable_max_line_length
118fi
119
120AC_SUBST(max_line_length_description)dnl
121
122dnl Checks for programs.
123
124AC_PROG_CC
125gl_EARLY
126
127AC_PROG_INSTALL
128dnl Figure out how to get a POSIX compilation environment on ISC.
129dnl We have to call this macro after the [AC_PROG_CC] macro and
130dnl before any other macro that calls the compiler.   We also do
131dnl something similar for MINIX (though CSSC has never been tested
132dnl on Minix as far as I know).
133AC_ISC_POSIX
134AC_MINIX
135
136AC_PROG_LIBTOOL
137
138AC_PROG_CXX
139AC_SUBST(GXX)dnl
140AC_PROG_CPP
141AC_PROG_CXXCPP
142dnl AC_PROG_INSTALL([])
143
144
145dnl The next test must be done in C++.
146
147AC_LANG([C++])
148
149dnl Determine if we need to work around the bogus printf macro in
150dnl glibc 2.2.3, with GCC versions 2.97 and above.
151dnl
152dnl We cannot do this test with AC_EGREP_CPP because the configure
153dnl script does not pass the correct -O option to the compiler (well,
154dnl the preprocessor)
155dnl
156AC_MSG_CHECKING([if you are using a broken version of glibc with a version of GCC (>=2.97) that doesn't like it])
157AC_TRY_COMPILE([
158#include <stdio.h>
159int x = 0;
160class foo {
161public:
162foo() { }
163void some_member_function(void) { };
164int printf(const char *fmt, ...);
165};
166],
167[/* no function body*/],
168AC_MSG_RESULT(no),
169AC_MSG_RESULT(yes)
170
171oldCFLAGS="$CFLAGS"
172oldCXXFLAGS="$CXXFLAGS"
173if echo "$CFLAGS" | grep -e "-O" >/dev/null
174then
175	CFLAGS="-g"
176	CXXFLAGS="-g"
177[
178echo
179echo WARNING It seems that you are using a version of GNU lilbc
180echo WARNING that has a broken printf macro in /usr/include/bits/stdio.h.
181echo WARNING I have changed CFLAGS and CXXFLAGS to turn optimisation off
182echo WARNING in order to work around the problem.
183echo WARNING
184echo WARNING Other possible workarounds would be to use GCC 2.96 or
185echo WARNING earlier, or a version of glibc which does not have this
186echo WARNING bug.
187echo WARNING
188echo WARNING CFLAGS   has been changed from "$oldCFLAGS"   to "$CFLAGS"
189echo WARNING CXXFLAGS has been changed from "$oldCXXFLAGS" to "$CXXFLAGS"
190echo
191]
192fi
193)
194
195AC_LANG([C])
196gl_INIT
197
198
199AC_OBJEXT
200AC_EXEEXT
201
202
203AC_PATH_PROG(UNAME,uname,/bin/uname)
204AC_PATH_PROG(PR,pr,/usr/bin/pr)
205dnl It would be a good idea to default the path for diff
206dnl to install_dir/diff-program so the installer can
207dnl add a symlink later.   TODO.
208AC_PATH_PROG(CONFIG_DIFF_COMMAND,diff,/usr/bin/diff)
209AC_DEFINE_UNQUOTED([CONFIG_DIFF_COMMAND],"$ac_cv_path_CONFIG_DIFF_COMMAND",
210[Path to the diff command])
211
212
213AC_MSG_CHECKING([for GNU diff])
214if $ac_cv_path_CONFIG_DIFF_COMMAND --version 2>/dev/null | grep "GNU diff" >/dev/null
215then
216	AC_MSG_RESULT(yes)
217	AC_DEFINE_UNQUOTED([HAVE_GNU_DIFF],1,[Define if we are using GNU diff])
218else
219	AC_MSG_RESULT(no)
220fi
221
222
223##
224## Search for something we can use to decompress a .Z file.
225##
226AC_CHECK_PROG(ZCAT_PROGRAM, uncompress, uncompress)
227if test "$ZCAT_PROGRAM" = ""
228then
229  AC_CHECK_PROG(ZCAT_PROGRAM, compress,   compress -d)
230fi
231if test "$ZCAT_PROGRAM" = ""
232then
233  AC_CHECK_PROG(ZCAT_PROGRAM, gzip,       gzip -d)
234fi
235if test "$ZCAT_PROGRAM" = ""
236then
237  AC_CHECK_PROG(ZCAT_PROGRAM, zcat,       zcat)
238fi
239if test "$ZCAT_PROGRAM" = ""
240then
241  AC_CHECK_PROG(ZCAT_PROGRAM, gunzip,     gunzip)
242fi
243
244if test "$ZCAT_PROGRAM" = ""
245then
246echo
247echo "WARNING: Cannot find a program that will decompress a compressed file."
248echo "WARNING: This means that you cannot run the test suite, since some"
249echo "WARNING: if the test input files in the test suite are provided"
250echo "WARNING: compressed.  The software should still compile."
251echo "WARNING: "
252echo "WARNING: If you have a command which will decompress a .Z file,"
253echo "WARNING: please set the variable ZCAT_PROGRAM and re-run configure."
254echo
255fi
256
257AC_ARG_WITH([valgrind],
258	AS_HELP_STRING([--with-valgrind],
259		[Run tests under Valgrind, if it is installed]),
260	[with_valgrind=$withval],
261	[with_valgrind=yes])
262if test "$with_valgrind" = yes; then
263   # Most CSSC programs exit with status 1 when there is a problem, and
264   # some of the regression tests check those cases.  However, if valgrind
265   # detects a problem, we need to exit with some other status so that
266   # a test expecting an exit status of 1 will actually fail.
267   AC_CHECK_PROG([VALGRIND], [valgrind],
268                 [valgrind -q --trace-children=yes --error-exitcode=10], [])
269else
270   VALGRIND=""
271   AC_SUBST(VALGRIND)
272fi
273
274dnl Checks for header files.
275
276dnl Standard C header files:-
277dnl We check these with language set to C only, otherwise autoconf-2.13 will
278dnl attempt to make the check with the C++ compiler.  It will then moan about
279dnl an undeclared "exit" library function.
280AC_LANG([C])
281AC_HEADER_STDC
282
283AC_LANG([C++])
284echo "Start checking accessibility of C headers while compiling as C++"
285AC_CHECK_HEADERS(locale.h)
286echo "Done checking accessibility of C headers while compiling as C++"
287
288dnl Posix/Unix header files:-
289AC_CHECK_HEADERS(prototypes.h io.h process.h pwd.h)
290AC_CHECK_HEADERS(sys/param.h sys/types.h)
291AC_CHECK_HEADERS(grp.h)
292AC_HEADER_DIRENT
293AC_HEADER_SYS_WAIT
294AC_HEADER_STAT
295
296dnl C++ Header files...
297AC_CHECK_HEADERS(string)
298
299dnl Checks for typedefs, structures, and compiler characteristics.
300
301dnl Do not use AC_C_CONST, because the tests for a fully working C "const"
302dnl break when you use a standard-conforming C++ compiler.
303dnl AC_C_CONST
304
305AC_TYPE_SIZE_T
306AC_TYPE_MODE_T
307AC_TYPE_PID_T
308AC_TYPE_UID_T
309
310dnl AC_CHECK_DECL_IN_HEADER(IDENTIFIER, HEADERS)
311AC_DEFUN([AC_CHECK_DECL_IN_HEADER],
312[AC_MSG_CHECKING(for $1 in $2)
313ac_tr_ident=`echo $1 | tr '.abcdefghijklmnopqrstuvwxyz' '_ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
314ac_tr_header=`echo $2 | tr '.abcdefghijklmnopqrstuvwxyz' '_ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
315ac_tr_define=${ac_tr_header}_DECLARES_${ac_tr_ident}
316AC_CACHE_VAL(ac_cv_decl_$ac_tr_define,
317[AC_EGREP_HEADER([$1], [$2],
318eval "ac_cv_decl_$ac_tr_define=yes",
319eval "ac_cv_decl_$ac_tr_define=no")])dnl
320if eval "test \"`echo '$ac_cv_decl_'$ac_tr_define`\" = yes"; then
321	 AC_MSG_RESULT(yes)
322	 # echo 'defining' $ac_tr_define
323	 AC_DEFINE_UNQUOTED($ac_tr_define,1,Define if we have header file $1)
324else
325	 # echo 'NOT defining' $ac_tr_define
326	 AC_MSG_RESULT(no)
327fi
328])
329
330dnl Deductions from proprocessor macros...
331AC_MSG_CHECKING([for _POSIX_SAVED_IDS])
332AC_CACHE_VAL(cssc_cv_sys_savedids_set,
333AC_EGREP_CPP(yes,
334[
335#include <unistd.h>
336#ifdef _POSIX_SAVED_IDS
337       yes
338#endif
339],
340cssc_cv_sys_savedids_set=yes,
341cssc_cv_sys_savedids_set=no
342))
343if test "$cssc_cv_sys_savedids_set" = "yes"; then
344	AC_MSG_RESULT(yes)
345	AC_DEFINE([SAVED_IDS_OK],1,[Define if _POSIX_SAVED_IDS is provided])
346else
347	AC_MSG_RESULT(no)
348fi
349
350
351dnl Look for declarations in headers.
352
353dnl src/sccs.c uses sys_siglist[], if available.
354AC_DECL_SYS_SIGLIST
355
356dnl fatalsig.cc uses signal handlers
357AC_TYPE_SIGNAL
358
359dnl Checks for library functions.
360dnl AC_FUNC_MEMCMP
361dnl The "select" that autoscan found was a method. AC_CHECK_FUNCS(select)
362
363AC_CHECK_FUNCS(abort wait)
364
365dnl Check for symlink() and readlink(), which lndir uses.
366dnl Check for fsetpos, which testutils/seeker uses.
367AC_CHECK_FUNCS(symlink readlink unsetenv fsetpos fileno fstat sysconf memchr)
368AC_CHECK_FUNCS(stat getpwuid getlogin setreuid pipe spawn geteuid getegid)
369
370
371AC_CHECK_FUNCS(setgroups)
372
373dnl
374dnl On AmigsOS, fork() is a stub (in ixemul.library).  This means that
375dnl AC_CHECK_FUNC will find it and so unless we handle it specially,
376dnl configure will set up for using fork().  For AmigaOS, we will probably
377dnl use system().  On AmigaOS system() is not going to be a security hole,
378dnl since there is no concept of separate users and so no setuid execution,
379dnl which is the potential problem with system, and the reason we don't
380dnl use it by default.
381dnl
382AC_MSG_CHECKING([for AmigaOS target])
383AC_EGREP_CPP(yes,
384[#ifdef __amigaos__
385       yes
386#endif
387], is_amigaos=yes, is_amigaos=no)
388
389if test $is_amigaos = yes
390then
391	AC_MSG_RESULT([avoiding fork on AmigaOS])
392else
393	AC_MSG_RESULT(no)
394	AC_CHECK_FUNCS(fork)
395fi
396
397
398AC_DEFUN([AC_CHECK_GLOBAL],
399[
400# JY: AC_CHECK_GLOBAL begins
401for ac_global in $1
402do
403   ac_tr_global=HAVE_`echo $ac_global | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
404   AC_MSG_CHECKING([for global variable ${ac_global}])
405   AC_CACHE_VAL(ac_cv_global_$ac_global,
406   [
407    AC_TRY_LINK(dnl
408    [/* no includes */],
409    [ extern long int $ac_global;  exit((int)$ac_global)],
410    eval "ac_cv_global_${ac_global}=yes",
411    eval "ac_cv_global_${ac_global}=no"
412    )
413   ]
414   )
415  if eval "test \"`echo '$ac_cv_global_'$ac_global`\" = yes"; then
416    AC_MSG_RESULT(yes)
417    AC_DEFINE_UNQUOTED($ac_tr_global,1,Define if the global variable $ac_global is available)
418  else
419    AC_MSG_RESULT(no)
420  fi
421done
422# JY: AC_CHECK_GLOBAL ends
423])
424
425dnl Enable some warnings, or not.
426want_warnings=no
427AC_ARG_ENABLE([warnings],
428		AS_HELP_STRING([--enable-warnings], [Turn on all potentially-useful compiler warnings]),
429		[want_warnings=$enableval],[want_warnings=no])
430gl_MANYWARN_ALL_GCC([ALL_GCC_WARNINGS])
431# Warnings not suitable for C++.
432WARNINGS_NOT_CXX="-Waggregate-return -Winline -Wnested-externs -Wtraditional -Wtraditional-conversion -Wdeclaration-after-statement -Wbad-function-cast -Wc++-compat -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wdesignated-init -Wdiscarded-array-qualifiers -Wdiscarded-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wincompatible-pointer-types -Wint-conversion -Wjump-misses-init -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -Wpointer-sign -Wpointer-to-int-cast"
433# Warnings which give too many false positives from system headers.
434WARNINGS_SYS_HEADER_FALSE_POSITIVE="-Wsystem-headers -Wunreachable-code"
435# Warnings for things that are actually normal
436WARNINGS_NORMAL="-Wundef -Wpadded -Wredundant-decls"
437# Warnings that are just hints we don't want to take advantage of now.
438WARNINGS_HINTS_NOTYET="-Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-attribute=format"
439# All unwanted warnings
440UNWANTED_CXX_WARNINGS="$WARNINGS_NOT_CXX $WARNINGS_SYS_HEADER_FALSE_POSITIVE $WARNINGS_NORMAL $WARNINGS_HINTS_NOTYET"
441AS_IF([test "x$want_warnings" != xno],
442[
443gl_MANYWARN_COMPLEMENT([GCC_WARNINGS], [$ALL_GCC_WARNINGS], [$UNWANTED_CXX_WARNINGS])
444for warning_option in $GCC_WARNINGS
445do
446    gl_WARN_ADD([$warning_option])
447done
448],[])
449
450
451## ==============================================================================
452## Googletest tests begin
453## ==============================================================================
454# TODO(chandlerc@google.com): Currently we aren't running the Python tests
455# against the interpreter detected by AM_PATH_PYTHON, and so we condition
456# HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's
457# version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env"
458# hashbang.
459PYTHON=  # We *do not* allow the user to specify a python interpreter
460AC_PATH_PROG([PYTHON],[python],[:])
461AS_IF([test "$PYTHON" != ":"],
462      [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])])
463AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"])
464
465# Configure pthreads.
466AC_ARG_WITH([pthreads],
467            [AS_HELP_STRING([--with-pthreads],
468               [use pthreads (default is yes)])],
469            [with_pthreads=$withval],
470            [with_pthreads=check])
471
472have_pthreads=no
473AS_IF([test "x$with_pthreads" != "xno"],
474      [ACX_PTHREAD(
475        [],
476        [AS_IF([test "x$with_pthreads" != "xcheck"],
477               [AC_MSG_FAILURE(
478                 [--with-pthreads was specified, but unable to be used])])])
479       have_pthreads="$acx_pthread_ok"])
480AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" = "xyes"])
481AC_SUBST(PTHREAD_CFLAGS)
482AC_SUBST(PTHREAD_LIBS)
483## ==============================================================================
484## Googletest tests end
485## ==============================================================================
486
487
488dnl *** NOTE:
489dnl There can be only ONE call to AC_OUTPUT in each configure.ac,
490dnl otherwise you get an error when you run configure.  AC_OUTPUT
491dnl deletes confdefs.h and so the second invocation can't find it
492dnl and so things go wrong.
493
494AC_CONFIG_FILES([src/version.cc Makefile gl/Makefile gl/lib/Makefile gl/doc/Makefile gl/tests/Makefile testutils/Makefile src/Makefile src/sccsdiff.sh unit-tests/Makefile tests/Makefile docs/Makefile testutils/decompress_stdin.sh auxfiles/Makefile auxfiles/CSSC.spec sccs-cgi/Makefile docs/config-info.texi unit-tests/testwrapper.sh])
495AC_OUTPUT
496