1dnl  Copyright (C) 2000-2018 Peter Selinger.
2dnl  This file is part of ccrypt. It is free software and it is covered
3dnl  by the GNU general public license. See the file COPYING for details.
4
5dnl  Process this file with autoconf to produce a configure script.
6
7dnl ----------------------------------------------------------------------
8AC_INIT([ccrypt], [1.11], [selinger at users.sourceforge.net])
9AC_CONFIG_SRCDIR([src/ccrypt.c])
10AM_INIT_AUTOMAKE
11AC_CONFIG_HEADERS([config.h])
12AC_CONFIG_MACRO_DIR([m4])
13
14DATE="July 2018"
15
16dnl ----------------------------------------------------------------------
17dnl  Find lisp installation directory
18AM_PATH_LISPDIR
19
20dnl ----------------------------------------------------------------------
21dnl  The names of the installed executables and the default suffix are in
22dnl  principle configurable. However, they should not normally be changed,
23dnl  because other scripts might depend on them.
24
25NAMECCRYPT=ccrypt
26NAMEENCRYPT=ccencrypt
27NAMEDECRYPT=ccdecrypt
28NAMECAT=ccat
29SUF=.cpt
30
31dnl Upper case name
32NAMEUC=`echo $NAMECCRYPT | tr a-z A-Z`
33
34dnl ----------------------------------------------------------------------
35dnl Export some parameters to config file
36AC_DEFINE_UNQUOTED(NAMECCRYPT,"$NAMECCRYPT",Name of the ccrypt binary)
37AC_DEFINE_UNQUOTED(NAMEENCRYPT,"$NAMEENCRYPT",Name of the ccencrypt binary)
38AC_DEFINE_UNQUOTED(NAMEDECRYPT,"$NAMEDECRYPT",Name of the ccdecrypt binary)
39AC_DEFINE_UNQUOTED(NAMECAT,"$NAMECAT",Name of the ccat binary)
40AC_DEFINE_UNQUOTED(SUF,"$SUF",Default suffix for encrypted files)
41
42dnl ----------------------------------------------------------------------
43dnl Check for C compiler and flags
44AC_PROG_CC([gcc clang cc c99 mgcc c89 pcc opencc sunc99 suncc])
45AC_USE_SYSTEM_EXTENSIONS
46
47dnl Also add CADD to the CFLAGS at configure time or compile time
48AC_SUBST(CADD)
49
50AC_MSG_CHECKING(what compiler options to use)
51AC_MSG_RESULT($CADD $CFLAGS)
52
53dnl ----------------------------------------------------------------------
54dnl Check for other programs
55
56AC_CHECK_PROGS(TAR, gtar, tar)
57
58dnl ----------------------------------------------------------------------
59dnl enable large file support
60
61AC_SYS_LARGEFILE
62
63dnl ----------------------------------------------------------------------
64dnl check for features
65
66AC_ARG_ENABLE(libcrypt,
67 AS_HELP_STRING([--disable-libcrypt],[do not link against libcrypt, use own replacement]))
68
69AC_ARG_ENABLE(emacs,
70 AS_HELP_STRING([--disable-emacs],[omit emacs support]),
71 if test "$enableval" = no; then
72     EMACS=no
73 fi
74)
75
76dnl ----------------------------------------------------------------------
77dnl Checks for libraries.
78
79dnl Unless explicitly disabled, link against libcrypt if possible
80if test "$enable_libcrypt" != no; then
81  AC_CHECK_LIB(crypt, crypt)
82fi
83
84dnl If not linking against libcrypt, must link against replacement
85if test "$ac_cv_lib_crypt_crypt" != yes; then
86   EXTRA_OBJS="$EXTRA_OBJS unixcrypt3.o"
87fi
88
89dnl SCO Open Server requires -lsocket for gethostname()
90AC_CHECK_LIB(socket, gethostname)
91
92dnl ----------------------------------------------------------------------
93dnl Checks for header files.
94AC_CHECK_HEADERS(stdint.h crypt.h)
95
96dnl ----------------------------------------------------------------------
97dnl Checks for library functions.
98
99dnl Check for getopt_long
100AC_CHECK_FUNC(getopt_long, have_getopt_long=yes, have_getopt_long=no)
101if test "$have_getopt_long" = "yes"; then
102   dnl Check whether getopt_long reorders its arguments
103   AC_MSG_CHECKING([whether getopt_long reorders its arguments])
104   AC_RUN_IFELSE([AC_LANG_PROGRAM(
105   [[ #include <getopt.h>
106      static struct option longopts[] = {
107        {"help", 0, 0, 'h'},
108	{0, 0, 0, 0}
109      };
110   ]],
111   [[ int ac = 3;
112      char *av[] = { "main", "file", "-h" };
113      return 'h' == getopt_long(ac, av, "h", longopts, (int *)0) ? 0 : 1;
114   ]])],
115   [AC_MSG_RESULT(yes)],
116   [AC_MSG_RESULT(no)
117   have_getopt_long=no],
118   [AC_MSG_RESULT(maybe (cross-compiling))
119   have_getopt_long=no])
120fi
121
122AC_ARG_WITH(included-getopt,
123 AS_HELP_STRING([--with-included-getopt],[avoid using the system-wide getopt library]))
124
125AC_MSG_CHECKING(whether to use included getopt)
126if test "$have_getopt_long" != "yes" || test "$with_included_getopt" = yes; then
127   EXTRA_OBJS="$EXTRA_OBJS getopt.o getopt1.o"
128   EXTRA_INCLUDES="$EXTRA_INCLUDES -I\$(srcdir)/include/getopt"
129   AC_MSG_RESULT(yes)
130else
131   AC_MSG_RESULT(no)
132fi
133
134dnl ----------------------------------------------------------------------
135dnl Find sizes of some types
136AC_CHECK_SIZEOF(unsigned int, 4)
137AC_CHECK_SIZEOF(unsigned long, 4)
138
139dnl Determine 32-bit unsigned integer type
140AC_MSG_CHECKING([for 32 bit unsigned integer type])
141if test "$ac_cv_sizeof_unsigned_int" -eq 4; then
142   UINT32_TYPE="unsigned int";
143elif test "$ac_cv_sizeof_unsigned_long" -eq 4; then
144   UINT32_TYPE="unsigned long";
145else
146AC_MSG_ERROR(cannot find 32 bit integer type)
147fi
148AC_MSG_RESULT($UINT32_TYPE)
149AC_DEFINE_UNQUOTED(UINT32_TYPE,$UINT32_TYPE,unsigned 32 bit integer type)
150
151dnl ----------------------------------------------------------------------
152dnl Internationalization
153
154GETTEXT_PACKAGE=ccrypt
155AC_SUBST(GETTEXT_PACKAGE)
156AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name for gettext])
157
158AM_GNU_GETTEXT
159AM_GNU_GETTEXT_VERSION([0.19.8])
160dnl IT_PO_SUBDIR(po)
161
162dnl ----------------------------------------------------------------------
163dnl Libtool (needed by intl/)
164
165LT_INIT
166
167dnl ----------------------------------------------------------------------
168dnl Set up substitutions of non-standard configuration parameters
169AC_SUBST(NAMECCRYPT)
170AC_SUBST(NAMEENCRYPT)
171AC_SUBST(NAMEDECRYPT)
172AC_SUBST(NAMECAT)
173AC_SUBST(SUF)
174AC_SUBST(DATE)
175AC_SUBST(NAMEUC)
176AC_SUBST(EXTRA_OBJS)
177AC_SUBST(EXTRA_INCLUDES)
178AC_SUBST(TAR)
179
180dnl ----------------------------------------------------------------------
181AC_CONFIG_FILES([doc/ccrypt.1
182	   doc/ccguess.1
183	   po/Makefile.in
184	   m4/Makefile
185	   intl/Makefile
186	   Makefile
187	   src/Makefile
188	   emacs/Makefile
189	   check/Makefile
190	   doc/Makefile
191          ])
192AC_OUTPUT
193