1dnl Copyright (c) 2003-2009 Brian M. Clapper. 2dnl All rights reserved. 3dnl 4dnl Redistribution and use in source and binary forms, with or without 5dnl modification, are permitted provided that the following conditions are met: 6dnl 7dnl * Redistributions of source code must retain the above copyright 8dnl notice, this list of conditions and the following disclaimer. 9dnl 10dnl * Redistributions in binary form must reproduce the above copyright 11dnl notice, this list of conditions and the following disclaimer in the 12dnl documentation and/or other materials provided with the distribution. 13dnl 14dnl * Neither the name of the clapper.org nor the names of its 15dnl contributors may be used to endorse or promote products derived from 16dnl this software without specific prior written permission. 17dnl 18dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21dnl ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22dnl LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23dnl CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24dnl SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26dnl CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27dnl ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28dnl POSSIBILITY OF SUCH DAMAGE. 29dnl --------------------------------------------------------------------------- 30 31 32dnl --------------------------------------------------------------------------- 33dnl Autoconf file for daemonize 34dnl 35dnl Process this file with autoconf to produce a configure script. 36dnl --------------------------------------------------------------------------- 37 38AC_INIT(daemonize.c) 39AC_CONFIG_HEADER(config.h) 40 41dnl --------------------------------------------------------------------------- 42dnl Directories and package-specific vars 43dnl --------------------------------------------------------------------------- 44 45LOCAL_TOP_LEVEL=`pwd` 46 47dnl --------------------------------------------------------------------------- 48dnl Compiler- and language-specific programs. Must precede the UNIX tests. 49dnl --------------------------------------------------------------------------- 50 51AC_PROG_CC 52AC_PROG_CPP 53 54AC_SUBST(CC) 55AC_SUBST(CPP) 56 57dnl --------------------------------------------------------------------------- 58dnl UNIX variant hacks 59dnl --------------------------------------------------------------------------- 60 61AC_AIX 62 63dnl --------------------------------------------------------------------------- 64dnl Checks for programs via standard macros. 65dnl --------------------------------------------------------------------------- 66 67AC_PROG_INSTALL 68 69dnl --------------------------------------------------------------------------- 70dnl Checks for header files. 71dnl --------------------------------------------------------------------------- 72 73AC_HEADER_STDC 74AC_HEADER_SYS_WAIT 75AC_CHECK_HEADERS(errno.h) 76AC_CHECK_HEADERS(libgen.h) 77 78export CPPFLAGS 79 80dnl --------------------------------------------------------------------------- 81dnl Checks for libraries. 82dnl --------------------------------------------------------------------------- 83 84dnl --------------------------------------------------------------------------- 85dnl Checks for typedefs, structures, and compiler characteristics. 86dnl --------------------------------------------------------------------------- 87 88AC_C_CONST 89 90AC_TYPE_UID_T 91AC_TYPE_MODE_T 92AC_TYPE_PID_T 93AC_TYPE_SIZE_T 94 95AC_CHECK_TYPE(ssize_t, int) 96 97dnl *** 98dnl FreeBSD and some others define "sig_t" as the return type for a signal 99dnl handler. Use it if it's there; #define it otherwise. 100 101AC_CACHE_CHECK([for 'sig_t' typedef], local_cv_have_sig_t, 102 AC_EGREP_HEADER(sig_t, signal.h, 103 local_cv_have_sig_t=yes, 104 local_cv_have_sig_t=no)) 105if test "$local_cv_have_sig_t" = "yes" ; then 106 AC_DEFINE(HAVE_SIG_T) 107fi 108 109dnl *** 110dnl Password file stuff 111 112AC_CACHE_CHECK([for 'struct passwd'], local_cv_have_struct_pw, 113 AC_TRY_COMPILE([#include <pwd.h>], 114 [struct passwd *pw;], 115 local_cv_have_struct_pw=yes, 116 local_cv_have_struct_pw=no)) 117if test "$local_cv_have_struct_pw" = "no" ; then 118 AC_MSG_ERROR([Sorry, but I need 'struct passwd'.]) 119else 120dnl pw_comment or pw_gecos? Neither is required by X/Open or POSIX. 121 122 AC_CACHE_CHECK([for 'pw_comment' field], wclib_cv_have_pw_comment, 123 AC_TRY_COMPILE([#include <pwd.h>], 124 [struct passwd *pw; 125 char *s = (char *) pw->pw_comment;], 126 wclib_cv_have_pw_comment=yes, 127 wclib_cv_have_pw_comment=no)) 128 129 AC_CACHE_CHECK([for 'pw_gecos' field], wclib_cv_have_pw_gecos, 130 AC_TRY_COMPILE([#include <pwd.h>], 131 [struct passwd *pw; 132 char *s = (char *) pw->pw_gecos;], 133 wclib_cv_have_pw_gecos=yes, 134 wclib_cv_have_pw_gecos=no)) 135 136 if test "$wclib_cv_have_pw_comment" = "yes" ; then 137 AC_DEFINE(HAVE_PW_COMMENT) 138 fi 139 if test "$wclib_cv_have_pw_gecos" = "yes" ; then 140 AC_DEFINE(HAVE_PW_GECOS) 141 fi 142fi 143 144 145dnl *** 146dnl Predefined `bool' type and various related constants 147 148AC_CACHE_CHECK([for predefined 'bool' type], local_cv_have_bool, 149 AC_TRY_COMPILE([ 150#include <stddef.h> 151#include <stdio.h> 152#include <stdlib.h>], 153 [bool flag;], 154 local_cv_have_bool=yes, 155 local_cv_have_bool=no)) 156if test "$local_cv_have_bool" = "no" ; then 157 AC_DEFINE(bool, short) 158fi 159 160dnl *** 161dnl TRUE? 162 163AC_CACHE_CHECK([for TRUE constant in standard headers], local_cv_have_true, 164 AC_TRY_COMPILE([ 165#include <stddef.h> 166#include <stdio.h> 167#include <stdlib.h>], 168 [if (TRUE) ;], 169 local_cv_have_true=yes, 170 local_cv_have_true=no)) 171if test "$local_cv_have_true" = "yes" ; then 172 AC_DEFINE(HAVE_TRUE) 173fi 174 175dnl *** 176dnl FALSE? 177 178AC_CACHE_CHECK([for FALSE constant in standard headers], local_cv_have_false, 179 AC_TRY_COMPILE([ 180#include <stddef.h> 181#include <stdio.h> 182#include <stdlib.h>], 183 [if (FALSE) ;], 184 local_cv_have_false=yes, 185 local_cv_have_false=no)) 186if test "$local_cv_have_false" = "yes" ; then 187 AC_DEFINE(HAVE_FALSE) 188fi 189 190dnl --------------------------------------------------------------------------- 191dnl Checks for library functions. 192dnl --------------------------------------------------------------------------- 193 194AC_CHECK_FUNC(initgroups, AC_DEFINE(HAVE_INITGROUPS)) 195AC_CHECK_FUNC(getpgrp, AC_DEFINE(HAVE_GETPGRP)) 196AC_CHECK_FUNC(setpgrp, AC_DEFINE(HAVE_SETPGRP)) 197 198dnl setsid(2) appears to be defined for all reasonable (and some unreasonable) 199dnl Unices. Hell, even the Single Unix Specification (formerly X/Open, see 200dnl `http://www.rdg.opengroup.org/onlinepubs/7908799/toc.htm') has it. 201dnl If it isn't there, we define a macro that fails. 202 203AC_CHECK_FUNC(setsid, AC_DEFINE(HAVE_SETSID)) 204 205dnl AC_FUNC_GETPGRP defines GETPGRP_VOID if getpgrp() takes no parameters. 206AC_FUNC_GETPGRP 207 208AC_FUNC_SETPGRP 209AC_FUNC_VPRINTF 210AC_CHECK_FUNC(vfork, AC_DEFINE(HAVE_VFORK)) 211AC_FUNC_VFORK 212 213dnl *** 214dnl Generate a list of missing functions that we desperately require. 215dnl Any missing functions, below, will be replaced with emulators if 216dnl necessary; the value of RUNAS_MISSING_SOURCES will be substituted into 217dnl the "portability" Makefile. 218 219AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR), 220 LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} strerror.c") 221 222dnl Some Unices don't have a daemon(3) function. If it's missing, we 223dnl supply our own emulation version. 224 225AC_CHECK_FUNC(daemon, AC_DEFINE(HAVE_DAEMON), 226 LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} daemon.c") 227 228AC_CHECK_FUNC(basename, AC_DEFINE(HAVE_BASENAME), 229 LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} basename.c") 230 231AC_CHECK_FUNC(setenv, AC_DEFINE(HAVE_SETENV), 232 LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} setenv.c") 233 234AC_CHECK_FUNC(flock, AC_DEFINE(HAVE_FLOCK), 235 LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} flock.c") 236 237AC_SUBST(LOCAL_MISSING_SOURCES) 238 239dnl --------------------------------------------------------------------------- 240dnl System services 241dnl --------------------------------------------------------------------------- 242 243AC_SYS_LONG_FILE_NAMES 244 245dnl --------------------------------------------------------------------------- 246dnl Final configuration constants that depend on the previous stuff. 247dnl --------------------------------------------------------------------------- 248 249dnl --------------------------------------------------------------------------- 250dnl Output and variable substitutions 251dnl --------------------------------------------------------------------------- 252 253dnl *** 254dnl Individual Makefiles 255 256AC_OUTPUT(Makefile) 257 258dnl --------------------------------------------------------------------------- 259dnl Copyrights and such 260dnl --------------------------------------------------------------------------- 261 262echo "" 263echo "***" 264echo "*** daemonize is released under a BSD-style license." 265echo "*** See the LICENSE file distributed with the source code for details." 266echo "***" 267echo "" 268