forked from bmc/daemonize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
267 lines (211 loc) · 9.06 KB
/
configure.in
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
dnl Copyright (c) 2003-2009 Brian M. Clapper.
dnl All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions are met:
dnl
dnl * Redistributions of source code must retain the above copyright
dnl notice, this list of conditions and the following disclaimer.
dnl
dnl * Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl
dnl * Neither the name of the clapper.org nor the names of its
dnl contributors may be used to endorse or promote products derived from
dnl this software without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
dnl ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
dnl LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
dnl CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
dnl SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
dnl CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
dnl ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
dnl POSSIBILITY OF SUCH DAMAGE.
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl Autoconf file for daemonize
dnl
dnl Process this file with autoconf to produce a configure script.
dnl ---------------------------------------------------------------------------
AC_INIT(daemonize.c)
AC_CONFIG_HEADER(config.h)
dnl ---------------------------------------------------------------------------
dnl Directories and package-specific vars
dnl ---------------------------------------------------------------------------
LOCAL_TOP_LEVEL=`pwd`
dnl ---------------------------------------------------------------------------
dnl Compiler- and language-specific programs. Must precede the UNIX tests.
dnl ---------------------------------------------------------------------------
AC_PROG_CC
AC_PROG_CPP
AC_SUBST(CC)
AC_SUBST(CPP)
dnl ---------------------------------------------------------------------------
dnl UNIX variant hacks
dnl ---------------------------------------------------------------------------
AC_AIX
dnl ---------------------------------------------------------------------------
dnl Checks for programs via standard macros.
dnl ---------------------------------------------------------------------------
AC_PROG_INSTALL
dnl ---------------------------------------------------------------------------
dnl Checks for header files.
dnl ---------------------------------------------------------------------------
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(errno.h)
AC_CHECK_HEADERS(libgen.h)
export CPPFLAGS
dnl ---------------------------------------------------------------------------
dnl Checks for libraries.
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl Checks for typedefs, structures, and compiler characteristics.
dnl ---------------------------------------------------------------------------
AC_C_CONST
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int)
dnl ***
dnl FreeBSD and some others define "sig_t" as the return type for a signal
dnl handler. Use it if it's there; #define it otherwise.
AC_CACHE_CHECK([for 'sig_t' typedef], local_cv_have_sig_t,
AC_EGREP_HEADER(sig_t, signal.h,
local_cv_have_sig_t=yes,
local_cv_have_sig_t=no))
if test "$local_cv_have_sig_t" = "yes" ; then
AC_DEFINE(HAVE_SIG_T)
fi
dnl ***
dnl Password file stuff
AC_CACHE_CHECK([for 'struct passwd'], local_cv_have_struct_pw,
AC_TRY_COMPILE([#include <pwd.h>],
[struct passwd *pw;],
local_cv_have_struct_pw=yes,
local_cv_have_struct_pw=no))
if test "$local_cv_have_struct_pw" = "no" ; then
AC_MSG_ERROR([Sorry, but I need 'struct passwd'.])
else
dnl pw_comment or pw_gecos? Neither is required by X/Open or POSIX.
AC_CACHE_CHECK([for 'pw_comment' field], wclib_cv_have_pw_comment,
AC_TRY_COMPILE([#include <pwd.h>],
[struct passwd *pw;
char *s = (char *) pw->pw_comment;],
wclib_cv_have_pw_comment=yes,
wclib_cv_have_pw_comment=no))
AC_CACHE_CHECK([for 'pw_gecos' field], wclib_cv_have_pw_gecos,
AC_TRY_COMPILE([#include <pwd.h>],
[struct passwd *pw;
char *s = (char *) pw->pw_gecos;],
wclib_cv_have_pw_gecos=yes,
wclib_cv_have_pw_gecos=no))
if test "$wclib_cv_have_pw_comment" = "yes" ; then
AC_DEFINE(HAVE_PW_COMMENT)
fi
if test "$wclib_cv_have_pw_gecos" = "yes" ; then
AC_DEFINE(HAVE_PW_GECOS)
fi
fi
dnl ***
dnl Predefined `bool' type and various related constants
AC_CACHE_CHECK([for predefined 'bool' type], local_cv_have_bool,
AC_TRY_COMPILE([
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>],
[bool flag;],
local_cv_have_bool=yes,
local_cv_have_bool=no))
if test "$local_cv_have_bool" = "no" ; then
AC_DEFINE(bool, short)
fi
dnl ***
dnl TRUE?
AC_CACHE_CHECK([for TRUE constant in standard headers], local_cv_have_true,
AC_TRY_COMPILE([
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>],
[if (TRUE) ;],
local_cv_have_true=yes,
local_cv_have_true=no))
if test "$local_cv_have_true" = "yes" ; then
AC_DEFINE(HAVE_TRUE)
fi
dnl ***
dnl FALSE?
AC_CACHE_CHECK([for FALSE constant in standard headers], local_cv_have_false,
AC_TRY_COMPILE([
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>],
[if (FALSE) ;],
local_cv_have_false=yes,
local_cv_have_false=no))
if test "$local_cv_have_false" = "yes" ; then
AC_DEFINE(HAVE_FALSE)
fi
dnl ---------------------------------------------------------------------------
dnl Checks for library functions.
dnl ---------------------------------------------------------------------------
AC_CHECK_FUNC(initgroups, AC_DEFINE(HAVE_INITGROUPS))
AC_CHECK_FUNC(getpgrp, AC_DEFINE(HAVE_GETPGRP))
AC_CHECK_FUNC(setpgrp, AC_DEFINE(HAVE_SETPGRP))
dnl setsid(2) appears to be defined for all reasonable (and some unreasonable)
dnl Unices. Hell, even the Single Unix Specification (formerly X/Open, see
dnl `http://www.rdg.opengroup.org/onlinepubs/7908799/toc.htm') has it.
dnl If it isn't there, we define a macro that fails.
AC_CHECK_FUNC(setsid, AC_DEFINE(HAVE_SETSID))
dnl AC_FUNC_GETPGRP defines GETPGRP_VOID if getpgrp() takes no parameters.
AC_FUNC_GETPGRP
AC_FUNC_SETPGRP
AC_FUNC_VPRINTF
AC_CHECK_FUNC(vfork, AC_DEFINE(HAVE_VFORK))
AC_FUNC_VFORK
dnl ***
dnl Generate a list of missing functions that we desperately require.
dnl Any missing functions, below, will be replaced with emulators if
dnl necessary; the value of RUNAS_MISSING_SOURCES will be substituted into
dnl the "portability" Makefile.
AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR),
LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} strerror.c")
dnl Some Unices don't have a daemon(3) function. If it's missing, we
dnl supply our own emulation version.
AC_CHECK_FUNC(daemon, AC_DEFINE(HAVE_DAEMON),
LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} daemon.c")
AC_CHECK_FUNC(basename, AC_DEFINE(HAVE_BASENAME),
LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} basename.c")
AC_CHECK_FUNC(setenv, AC_DEFINE(HAVE_SETENV),
LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} setenv.c")
AC_CHECK_FUNC(flock, AC_DEFINE(HAVE_FLOCK),
LOCAL_MISSING_SOURCES="${LOCAL_MISSING_SOURCES} flock.c")
AC_SUBST(LOCAL_MISSING_SOURCES)
dnl ---------------------------------------------------------------------------
dnl System services
dnl ---------------------------------------------------------------------------
AC_SYS_LONG_FILE_NAMES
dnl ---------------------------------------------------------------------------
dnl Final configuration constants that depend on the previous stuff.
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl Output and variable substitutions
dnl ---------------------------------------------------------------------------
dnl ***
dnl Individual Makefiles
AC_OUTPUT(Makefile)
dnl ---------------------------------------------------------------------------
dnl Copyrights and such
dnl ---------------------------------------------------------------------------
echo ""
echo "***"
echo "*** daemonize is released under a BSD-style license."
echo "*** See the LICENSE file distributed with the source code for details."
echo "***"
echo ""