summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 0cc06a2a8465930e85fb07bb4653b7f40e079f6b (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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#
# Copyright (C) 1999-2021 Thorsten Kukuk <kukuk@thkukuk.de>
#
dnl Process this file with autoconf to produce a configure script.
AC_INIT([ypserv],[4.2],[kukuk@thkukuk.de])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([ypserv/ypserv.c])
AC_CONFIG_HEADERS([config.h])
AC_PREFIX_DEFAULT(/usr)
AH_BOTTOM([#include <conf_post.h>])

AC_SUBST(PACKAGE)
AC_SUBST(VERSION)

dnl Some hacks...
test "${prefix}" = "NONE" && prefix="/usr"
if test ${prefix} = '/usr'
then
dnl If we use /usr as prefix, use /etc for ypserv.conf
	if test ${sysconfdir} = '${prefix}/etc'
	then
	   sysconfdir="/etc"
	fi
dnl If we use /usr as prefix, use /usr/share/man for manual pages
	if test ${mandir} = '${prefix}/man'
	then
	   mandir='${prefix}/share/man'
	fi
fi
dnl Change libexec to lib/yp
if test ${libexecdir} = '${exec_prefix}/libexec'
then
  libexecdir='${exec_prefix}/lib/yp'
  if test "${exec_prefix}" = "NONE"
  then
    YPBINDIR=/usr/lib/yp
  else
    YPBINDIR=${exec_prefix}/lib/yp
  fi
else
  YPBINDIR=${libexecdir}
fi
AC_SUBST(YPBINDIR)

dnl Location of the NIS maps.  default: /var/yp
AC_ARG_ENABLE([ypmapdir],
       AS_HELP_STRING([--enable-ypmapdir=path],
		[Location of NIS maps (default=/var/yp)]),
              YPMAPDIR=$enableval, YPMAPDIR=/var/yp)
AC_SUBST(YPMAPDIR)


if test ${sbindir} = '${exec_prefix}/sbin'
then
  if test "${exec_prefix}" = "NONE"
  then
    SBINDIR=/usr/sbin
  else
    SBINDIR=${exec_prefix}/sbin
  fi
else
  SBINDIR=${sbindir}
fi
AC_SUBST(SBINDIR)

dnl Checks for programs.
AC_PROG_CC
AC_SEARCH_LIBS([strerror],[cposix])
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AM_PROG_CC_C_O
AC_USE_SYSTEM_EXTENSIONS
AC_GNU_SOURCE
AC_C___ATTRIBUTE__

if eval "test x$GCC = xyes"; then
  for flag in \
      -W \
      -Wall \
      -Wbad-function-cast \
      -Wcast-align \
      -Wcast-qual \
      -Wmissing-declarations \
      -Wmissing-prototypes \
      -Wpointer-arith \
      -Wreturn-type \
      -Wstrict-prototypes
  do
    JAPHAR_GREP_CFLAGS($flag, [ CFLAGS="$CFLAGS $flag" ])
  done
fi

AC_ARG_ENABLE(pie,AS_HELP_STRING([--disable-pie],
			[Disable position-independent executeables (PIE)]),
	USE_PIE=$enableval, USE_PIE=yes)

AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
  cat > conftest.c <<EOF
int foo;
main () { return 0;}
EOF
  if test "$USE_PIE" = "yes" &&
	AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fpie
                              -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
  then
    libc_cv_fpie=yes
    PIE_CFLAGS="-fpie"
    PIE_LDFLAGS="-pie"
  else
    libc_cv_fpie=no
    PIE_CFLAGS=""
    PIE_LDFLAGS=""
  fi
  rm -f conftest*])
AC_SUBST(libc_cv_fpie)
AC_SUBST(PIE_CFLAGS)
AC_SUBST(PIE_LDFLAGS)

dnl Check for big or little endian system
AC_C_BIGENDIAN
dnl Check for 64bit systems
AC_CHECK_SIZEOF(long)

dnl Search a awk program
AC_PATH_PROGS(AWK, mawk gawk nawk awk, ERROR)
if test $AWK = ERROR
then
   echo " "
   echo "ERROR: You must have at last one of the following programs:"
   echo "       mawk, gawk, nawk or awk !"
   echo " "
   exit
fi

dnl Search the bash
AC_PATH_PROGS(BASH, bash /sbin/sh, /bin/sh)

dnl Search make
AC_PATH_PROGS(MAKE, gmake make, "", $PATH:/usr/ccs/bin:/usr/local/bin)
if test x$MAKE = x
then
   echo " "
   echo "Warning: No make on this system?"
   echo " "
   exit
fi
AC_SUBST(MAKE)

dnl Check for aliases path
AC_PATH_PROG(ALIASES, aliases, /etc/mail/aliases, /etc/mail:/etc)

dnl Should we use a gethostbyname after gethostname to use FQDN ? default yes
AC_ARG_ENABLE(fqdn, AS_HELP_STRING([--disable-fqdn],
			[Always use FQDN (default=yes)]),
              USE_PARAM_FQDN=$enableval, USE_PARAM_FQDN=yes)
if test "$USE_PARAM_FQDN" = "no"; then
  USE_FQDN=0
else
  USE_FQDN=1
fi
AC_SUBST(USE_FQDN)

dnl Should we allow root to change a password with yppasswd ? default: yes
AC_ARG_ENABLE([checkroot],AS_HELP_STRING([--disable-checkroot],
	[Disable check for root password (default=yes)]),
              CHECKROOT=$enableval, CHECKROOT=yes)
AC_SUBST(CHECKROOT)

# Check for --with-dbmliborder
dbmliborder="gdbm ndbm qdbm tokyocabinet"
AC_MSG_CHECKING(for --with-dbmliborder)
AC_ARG_WITH(dbmliborder,
            AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm', `qdbm' and `tokyocabinet'.]),
[
if test x$with_dbmliborder = xyes
then
  AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
else
  dbmliborder=`echo $with_dbmliborder | sed 's/:/ /g'`
  for db in $dbmliborder; do
    if test x$db != xndbm && test x$db != xgdbm && test x$db != xqdbm && test x$db != xtokyocabinet
    then
      AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
    fi
  done
fi])
AC_MSG_RESULT($with_dbmliborder)

# find which dbm we have
for db in $dbmliborder; do
  if test x$db = xqdbm
  then
    AC_CHECK_LIB(qdbm,gdbm_open,LIBDBM="$( pkg-config --libs qdbm )" ; CFLAGS="$( pkg-config --cflags qdbm ) $CFLAGS",LIBDBM="")
    if test x"" != x"${LIBDBM}"
    then
      AC_DEFINE(HAVE_LIBQDBM, 1, [Use qdbm library as database])
      libdb_parameter=yes
      break
    fi
  elif test x$db = xgdbm
  then
    AC_CHECK_LIB(gdbm,gdbm_open,LIBDBM="-lgdbm",LIBDBM="")
    if test x"" != x"${LIBDBM}"
    then
      AC_DEFINE(HAVE_LIBGDBM, 1, [Use gdbm library as database])
      libdb_parameter=yes
      break
    fi
  elif test x$db = xtokyocabinet
  then
    AC_CHECK_LIB(tokyocabinet,tcbdbopen,LIBDBM="-ltokyocabinet",LIBDBM="")
    if test x"" != x"${LIBDBM}"
    then
      AC_DEFINE(HAVE_LIBTC, 1, [Use tokyocabinet library as database])
      libdb_parameter=yes
      break
    fi
  elif test x$db = xndbm
  then
    AC_CHECK_FUNCS(dbm_open)
    if test x$ac_cv_func_dbm_open = xyes
    then
      AC_DEFINE(HAVE_NDBM, 1, [Use ndbm library as database])
      libdb_parameter=yes
      break
    fi
  fi
done
AC_SUBST(LIBDBM)

if test x$libdb_parameter != xyes
then
  echo "

 You need the GNU GDBM, QDBM, Tokyo Cabinet or the Solaris NDBM functions for this package !"
  echo ""
  echo ""
  exit
fi

AC_CHECK_LIB(crypt,crypt,LIBCRYPT="-lcrypt",LIBCRYPT="")
AC_CHECK_HEADERS(crypt.h)
AC_SUBST(LIBCRYPT)

dnl save old CFLAGS/CPPFLAGS/LIBS variable, we need to modify them
dnl to find out which functions they provide
old_CFLAGS=$CFLAGS
old_CPPFLAGS=$CPPFLAGS
old_LIBS=$LIBS
PKG_CHECK_MODULES([NSL], [libnsl], [], [AC_CHECK_LIB([nsl],[yp_match],[NSL_LIBS="-lnsl"],[NSL_LIBS=""])])
CFLAGS="$CFLAGS $NSL_CFLAGS"
CPPFLAGS="$CPPFLAGS $NSL_CFLAGS"
LIBS="$LIBS $NSL_LIBS"
PKG_CHECK_MODULES([TIRPC], [libtirpc], [], [TIRPC_LIBS=""])
if test -n "$TIRPC_LIBS"; then
  AC_DEFINE(HAVE_TIRPC, 1, [Define to 1 if TIRPC is available])
fi
CFLAGS="$CFLAGS $TIRPC_CFLAGS"
CPPFLAGS="$CPPFLAGS $TIRPC_CFLAGS"
LIBS="$LIBS $TIRPC_LIBS"
AC_CHECK_FUNCS([getrpcport rpcb_getaddr])
CFLAGS="$old_CFLAGS"
CPPFLAGS="$old_CPPFLAGS"
LIBS="$old_LIBS"

PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209], [USE_SD_NOTIFY=1], [USE_SD_NOTIFY=0])
AC_SUBST(USE_SD_NOTIFY)

AC_CHECK_LIB(resolv, res_gethostbyname, RESOLV="-lresolv", RESOLV="")
if test x$RESOLV != x
then
	AC_DEFINE(HAVE_RES_GETHOSTBYNAME, 1, [Define if you have the res_gethostbyname function.])
else
	AC_CHECK_LIB(resolv+, gethostbyname, RESOLV="-lresolv+", RESOLV="")
fi
AC_SUBST(RESOLV)

dnl
dnl Check for xsltproc
dnl
enable_man=yes
AC_PATH_PROG([XSLTPROC], [xsltproc])
if test -z "$XSLTPROC"; then
     enable_man=no
fi
AC_PATH_PROG([XMLLINT], [xmllint],[/bin/true])
dnl check for DocBook DTD and stylesheets in the local catalog.
JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.3//EN],
                [DocBook XML DTD V4.3], [], enable_man=no)
JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
                [DocBook XSL Stylesheets], [], enable_man=no)
AM_CONDITIONAL(ENABLE_REGENERATE_MAN, test x$enable_man != xno)

AC_CONFIG_FILES([Makefile
	lib/Makefile etc/Makefile ypserv/Makefile
	ypxfr/Makefile yppush/Makefile makedbm/Makefile mknetid/Makefile
	revnetgroup/Makefile rpc.yppasswdd/Makefile rpc.ypxfrd/Makefile
	yphelper/Makefile scripts/Makefile scripts/ypxfr_1perhour
	scripts/ypxfr_1perday scripts/ypxfr_2perday scripts/pwupdate
	scripts/create_printcap scripts/match_printcap
	scripts/ypinit scripts/ypMakefile])
AC_OUTPUT

echo "
Configuration:

  Source code location:   ${srcdir}
  Compiler:               ${CC}
  Compiler flags:         ${CFLAGS}
  Preprocessor:		  ${CPP}
  Preprocessor flags:     ${CPPFLAGS}
  Libraries:		  ${LIBS} ${LIBDBM} ${LIBCRYPT} ${SYSTEMD_LIBS} ${TIRPC_LIBS} ${NSL_LIBS}
  Awk:                    ${AWK}
  Shell:		  ${BASH}
  NIS map dir:            ${YPMAPDIR}
  Install path prefix:    ${prefix}"
if test ${sysconfdir} != '${prefix}/etc'
then
  echo "  Install ypserv.conf in:  ${sysconfdir}"
else
  echo "  Install ypserv.conf in:  ${prefix}/etc"
fi
  echo "  Allow root password:     ${CHECKROOT}"
  echo "  Use FQDN as master name: ${USE_FQDN}"
  echo "  Notify systemd:	   ${USE_SD_NOTIFY}"
echo ""