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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
|
dnl configure.in for RPM
dnl
dnl Don't add checks for things we can't work around, unless those checks
dnl failing causes the script to bomb out with a message. If we can't fix
dnl it, why check it?
AC_INIT(rpm.c)
AC_CONFIG_HEADER(config.h)
dnl default to not using NLS
XGETTEXT=""
LIBINTL=""
PO=""
GETTEXTSTUB="gettextstub.o"
MISCOBJS=
AC_CANONICAL_SYSTEM
RPMCONFIGDIR='$(libdir)'
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
dnl
dnl if CC is gcc, we can rebuild the dependencies (since the depend rule
dnl requires gcc). If it's not, don't rebuild dependencies -- use what was
dnl shipped with RPM.
dnl
if test X"$GCC" = Xyes ; then
TARGET="depend everything"
else
TARGET="everything"
#
# let the top level Makefile know that we're done with `depend'
#
echo > .depend-done
fi
AC_SUBST(TARGET)
dnl
dnl This is a quick hack, to make it so that we can statically link the
dnl rpm binary on as many platforms as possible.
dnl
dnl a *much* better solution would be to use libtool to determine the proper
dnl way to statically link on your platform.
dnl
AC_MSG_CHECKING(what additional CFLAGS are needed to link statically)
if test X"$GCC" = Xyes ; then
case "$target" in
*-*-hpux*) CFLAGS_STATIC="-Wl,-a,archive_shared";; #works better
*-*-*) CFLAGS_STATIC="-static";;
esac
elif test X"$CC" = Xcc ; then
case "$target" in
*-*-linux*) CFLAGS_STATIC="-static";;
*-*-freebsd*) CFLAGS_STATIC="-static";;
*-*-osf*) CFLAGS_STATIC="-non_shared";;
*-*-aix*) CFLAGS_STATIC="";; # -Wl,-bnso doesn't seem to work...
*-*-hpux*) CFLAGS_STATIC="-Wl,-a,archive_shared";;
*-*-solaris*) CFLAGS_STATIC="-B static";;
*-*-irix*) CFLAGS_STATIC="";; #should be -non_shared, but can't
# link because of crt1.o then.
*-*-ultrix*) CFLAGS_STATIC="";; #ultrix doesn't have shared libs.
*-*-*) CFLAGS_STATIC=""
AC_MSG_WARN([
Unable to guess what option to pass to $CC to generate a static
executable. You will need to set the CFLAGS_STATIC macro in Makefile.inc to
the appropriate argument(s) if you want to build a static rpm executable.
])
;;
esac
else
# a shot in the dark...
CFLAGS_STATIC="-static"
fi
AC_MSG_RESULT($CFLAGS_STATIC)
AC_SUBST(CFLAGS_STATIC)
AC_MSG_CHECKING(POSIX chmod...)
touch foo.chmodtest
chmod 744 foo.chmodtest
chmod +X foo.chmodtest 2>/dev/null
a=`ls -l foo.chmodtest | awk '{print $1}'`
rm -f foo.chmodtest
if test "$a" = "-rwxr-xr-x"; then
AC_MSG_RESULT(yes)
FIXPERMS=a+rX,g-w,o-w
else
AC_MSG_RESULT(no (tell your OS vendor about GNU fileutils))
FIXPERMS=a+r,g-w,o-w
fi
dnl
dnl see if we have a mkdir that supports `-p'.
dnl
AC_PATH_PROGS(MKDIR, mkdir, mkdir)
AC_MSG_CHECKING(if $MKDIR supports -p)
rm -rf conftest
$MKDIR -p conftest/a 2>/dev/null
if test $? = 0 ; then
rmdir conftest/a 2>/dev/null
if test $? = 0 ; then
:
else
MKDIR_P=0
fi
rmdir conftest 2>/dev/null
if test $? = 0 ; then
MKDIR_P="$MKDIR -p"
else
MKDIR_P=0
fi
else
MKDIR_P=0
fi
if test X"$MKDIR_P" = X0 ; then
AC_MSG_RESULT(no)
AC_PATH_PROGS(MKDIRHIER, mkdirhier, mkdirhier)
MKDIR_P="$MKDIRHIER"
else
AC_MSG_RESULT(yes)
fi
dnl
dnl substitute this into config.h, so the C source picks it up.
dnl
AC_DEFINE_UNQUOTED(MKDIR_P, "${MKDIR_P}")
AC_AIX
AC_MINIX
AC_ISC_POSIX
AC_PROG_AWK
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_CHECK_TOOL(AR, ar, :)
if test "$cross_compiling" != "yes"; then
AC_MSG_CHECKING(GNU gzip...)
if test -z "$GZIPBIN"; then
oldifs="$IFS"
IFS=:
for n in $PATH:/opt/gnu/bin; do
if test -f $n/gzip; then
GZIPBIN="$n/gzip";
break
fi
done
IFS="$oldifs"
fi
if test -z "$GZIPBIN"; then
GZIPBIN="gzip"
AC_MSG_RESULT(no)
AC_MSG_WARN(RPM will not work without GNU gzip.)
else
AC_MSG_RESULT(yes)
fi
AC_MSG_CHECKING(old version of patch)
PATCHVERSION=`patch --version 2>&1`
if test "$PATCHVERSION" = "Patch version 2.1"; then
AC_DEFINE(HAVE_OLDPATCH_21)
AC_MSG_RESULT(patch older then 2.2 found)
else
AC_MSG_RESULT(patch later then 2.2 found)
fi
fi
topdir=`pwd`
topsrcdir=`cd ${srcdir}; pwd`
addlib() {
l=$1
shift
case "$target" in
*-*-solaris*) LIBS="$LIBS -L$l -R $l $*";;
*) LIBS="$LIBS -L$l $*";;
esac
}
if test $prefix != "/usr" -a $prefix != "/usr/local"; then
AC_MSG_CHECKING("$prefix/lib... $ac_c")
if test -d $prefix/lib ; then
addlib $prefix/lib
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
echo $ac_n "checking for $prefix/include... $ac_c"
if test -d $prefix/include ; then
INCPATH="$INCPATH -I$prefix/include"
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
AC_MSG_CHECKING(/usr/local/lib...)
if test -d /usr/local/lib ; then
addlib /usr/local/lib
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(/usr/local/include...)
if test -d /usr/local/include ; then
INCPATH="$INCPATH -I/usr/local/include"
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING(/usr/ucblib...)
if test -d /usr/ucblib ; then
if test "$build" = "mips-sni-sysv4" ; then
addlib /usr/ccs/lib -lc
fi
addlib /usr/ucblib
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
dnl Checks for libraries.
AC_CHECK_FUNC(strcasecmp, [], [
AC_CHECK_LIB(ucb, strcasecmp, [LIBS="$LIBS -lucb" USEUCB=y])
])
AC_CHECK_FUNC(rand, [], [
AC_CHECK_LIB(rand, rand, [LIBS="$LIBS -lm"])
])
dnl
dnl handle --disable-nls
dnl
AC_ARG_ENABLE([nls],
[ --disable-nls do not use National Language Support],
USE_NLS=$enableval, USE_NLS=yes)
if test "$USE_NLS" != "no"; then
AC_CHECK_FUNC(gettext, [HAVEGETTEXT="yes"],
AC_CHECK_LIB(intl, gettext, [LIBINTL="-lintl" HAVEGETTEXT="y"],
AC_MSG_WARN([sorry this package needs libintl.a (from the
gettext package)])
)
)
AC_CHECK_PROG(XGETTEXT, xgettext, xgettext)
if test "$XGETTEXT" != ""; then
if xgettext --help 2>&1 | grep illegal >/dev/null ; then
echo "xgettext isn't GNU version"
XGETTEXT=""
fi
fi
if test "$XGETTEXT" != "" -a "$HAVEGETTEXT" != ""; then
echo "xgettext and gettext() exist; will build i18n support"
PO=po
GETTEXTSTUB=""
else
echo "xgettext and libintl.a don't both exist; will not build i18n support"
fi
else
echo "user specificed no gettext; will not build i18n support"
fi
AC_CHECK_FUNC(getdomainname, [], [
AC_CHECK_LIB(nsl, getdomainname, [LIBS="$LIBS -lnsl"])
])
AC_CHECK_FUNC(socket, [], [
AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"])
])
AC_CHECK_FUNC(dbopen, [],
AC_CHECK_LIB(db, dbopen, [], AC_MSG_WARN([sorry this package needs libdb.a
(from the db package)]))
)
AC_CHECK_FUNC(fork, [], [echo "using vfork() instead of fork()";
MISCOBJS=fakefork.o])
dnl AmigaOS and IXEmul have a fork() dummy
case "$target" in
m68k-*-amigaos )
echo "Building for AmigaOS: using vfork() instead of fork()";
CFLAGS="$CFLAGS -Dfork=vfork"
;;
esac
ZLIB=
for zlib in z gz ; do
AC_CHECK_LIB(${zlib}, gzread,
[LIBS="$LIBS -l${zlib}"; break],
[if test ${zlib} = gz; then
AC_MSG_WARN([sorry this package needs libz.a or libgz.a (from the zlib package)])
fi]
)
done
dnl Checks for header files we can live without.
AC_HEADER_STDC
AC_HEADER_MAJOR
AC_CHECK_HEADERS(netinet/in_systm.h limits.h)
AC_CHECK_HEADERS(alloca.h dirent.h sys/socket.h sys/select.h)
AC_CHECK_HEADERS(machine/types.h string.h)
AC_CHECK_HEADERS(sys/types.h sys/stdtypes.h unistd.h)
AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/systemcfg.h)
AC_CHECK_HEADERS(sys/mount.h sys/mntctl.h sys/vmount.h)
AC_CHECK_HEADERS(glob.h,,MISCOBJS="$MISCOBJS glob.o")
AC_CHECK_HEADERS(fnmatch.h,,MISCOBJS="$MISCOBJS fnmatch.o")
if test "$PO" = po; then
AC_CHECK_HEADERS(libintl.h)
fi
AC_C_BIGENDIAN
AC_C_INLINE
dnl look for libc features
PROVIDES_ERRNO=no
AC_MSG_CHECKING(if <netdb.h> defines h_errno...)
AC_TRY_LINK([#include <netdb.h>],printf("%d",h_errno),PROVIDES_ERRNO=yes)
AC_MSG_RESULT($PROVIDES_ERRNO)
if test $PROVIDES_ERRNO = yes; then
AC_DEFINE(HAVE_HERRNO)
fi
dnl If a system doesn't have S_IFSOCK, define it as 0 which will
dnl make S_ISSOCK always return false (nice, eh?)
AC_MSG_CHECKING(if <sys/stat.h> defines S_IFSOCK...)
AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_IFSOCK),
HAS_S_IFSOCK=yes,HAS_S_IFSOCK=no)
AC_MSG_RESULT($HAS_S_IFSOCK)
if test $HAS_S_IFSOCK = yes; then
AC_DEFINE(HAVE_S_IFSOCK)
fi
dnl Some Unix's are missing S_ISLNK, S_ISSOCK
AC_MSG_CHECKING(if <sys/stat.h> defines S_ISLNK...)
AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISLNK(0755)),
HAS_S_ISLNK=yes,HAS_S_ISLNK=no)
AC_MSG_RESULT($HAS_S_ISLNK)
if test $HAS_S_ISLNK = yes; then
AC_DEFINE(HAVE_S_ISLNK)
fi
AC_MSG_CHECKING(if <sys/stat.h> defines S_ISSOCK...)
AC_TRY_LINK([#include <sys/stat.h>],printf("%d", S_ISSOCK(0755)),
HAS_S_ISSOCK=yes,HAS_S_ISSOCK=no)
AC_MSG_RESULT($HAS_S_ISSOCK)
if test $HAS_S_ISSOCK = yes; then
AC_DEFINE(HAVE_S_ISSOCK)
fi
AC_MSG_CHECKING(if timezone is defined...)
AC_TRY_LINK([#include <time.h>],printf("%ld", timezone),
HAS_TIMEZONE=yes,HAS_TIMEZONE=no)
AC_MSG_RESULT($HAS_TIMEZONE)
dnl Checks for library functions.
AC_CHECK_FUNC(inet_aton, AC_DEFINE(HAVE_INET_ATON), MISCOBJS="$MISCOBJS inet_aton.o")
AC_CHECK_FUNC(realpath, AC_DEFINE(HAVE_REALPATH), MISCOBJS="$MISCOBJS realpath.o")
AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT), [
AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL),[
AC_CHECK_FUNC(getmntinfo_r, AC_DEFINE(HAVE_GETMNTINFO_R), [
AC_CHECK_LIB(c_r, getmntinfo_r, [LIBS="$LIBS -lc_r";
AC_DEFINE(HAVE_GETMNTINFO_R)],
MISCOBJS="$MISCOBJS getmntent.o")])])])
AC_CHECK_FUNC(strerror, [], MISCOBJS="$MISCOBJS strerror.o")
AC_CHECK_FUNC(strtol, [], MISCOBJS="$MISCOBJS strtol.o")
AC_CHECK_FUNC(strtoul, [], MISCOBJS="$MISCOBJS strtoul.o")
AC_CHECK_FUNC(strdup, [], MISCOBJS="$MISCOBJS strdup.o")
LCHOWN=no
AC_CHECK_FUNC(lchown, [LCHOWN=yes; AC_DEFINE(HAVE_LCHOWN)])
if test "$LCHOWN" = no; then
dnl Does chown() follow symlinks? This should be a good enough test.
AC_MSG_CHECKING(whether chown() follows symlinks...)
AC_ARG_ENABLE([broken-chown],
[ --enable-broken-chown this system's chown follows symbolic links],
result=$enableval, result=unknown)
if echo "$build" | egrep "(aix)|(hpux)|(linux)" > /dev/null ; then
result=yes
elif echo "$build" | egrep "(nextstep)" > /dev/null ; then
result=no
fi
if test $result = unknown; then
if test `id | cut -f2 -d\= | cut -f1 -d\(` = 0; then
rm -f foo bar
touch foo
ln -s foo bar
chown 10 bar
if test `ls -l foo | awk '{print $3}'` != "root"; then
result=yes
else
result=no
fi
rm -f foo bar
else
AC_MSG_CHECKING((cannot check by non-root user))
result=no
fi
fi
AC_MSG_RESULT($result)
if test $result = yes; then
AC_DEFINE(CHOWN_FOLLOWS_SYMLINK)
fi
fi
dnl
dnl figure out what root's primary group is
dnl
AC_MSG_CHECKING(root's primary group)
AC_TRY_RUN([#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
int main()
{
struct passwd *root = NULL;
struct group *roots_group = NULL;
FILE * tempfile = NULL;
root = getpwuid( (uid_t) 0 );
if (root != NULL) {
roots_group = getgrgid(root->pw_gid);
if (roots_group != NULL) {
tempfile = fopen("conftest_rootg", "w");
if (tempfile != NULL) {
fprintf(tempfile, "%s\n", roots_group->gr_name);
fclose(tempfile);
exit(0);
}
}
}
exit(1);
}], ROOT_GROUP=`cat conftest_rootg`,
ROOT_GROUP="root",ROOT_GROUP="root"
)
AC_DEFINE_UNQUOTED(ROOT_GROUP, "$ROOT_GROUP")
AC_MSG_RESULT($ROOT_GROUP)
AC_SUBST(ROOT_GROUP)
if test "x$varprefix" = "x"; then
varprefix=`echo $prefix | sed 's/usr/var/'`
test "x$prefix" = xNONE && varprefix=`echo $ac_default_prefix | sed 's/usr/var/'`
fi
if test "x$tmpdir" = "x"; then
if test -d $varprefix/tmp; then
tmpdir=$varprefix/tmp
else
if test -d /var/tmp; then
tmpdir=/var/tmp
else
tmpdir=/tmp
fi
fi
fi
#This test will obviate a special case for at least Solaris;
#possibly others also.
AC_CHECK_FUNC(dlopen,RPM=rpm,RPM=rpm.shared)
if echo "$build_os" | grep sco > /dev/null; then
echo "hacking things up for sco"
RPM=rpm.shared
AC_DEFINE(NEED_STRINGS_H)
AC_DEFINE(HAVE_STRUCT_MNTTAB)
elif echo "$build_os" | grep sunos > /dev/null; then
echo "hacking things up for sunos"
CFLAGS="$CFLAGS -D__USE_FIXED_PROTOTYPES__"
AC_DEFINE(NEED_STRINGS_H)
AC_DEFINE(NEED_MYREALLOC)
MISCOBJS="$MISCOBJS myrealloc.o"
elif echo "$build_os" | grep hpux > /dev/null; then
#RPM=rpm.shared
RPM=rpm
LIBDL=-ldld
echo "hacking things up for hpux"
elif echo "$build_os" | grep irix > /dev/null; then
RPM=rpm.shared
echo "hacking things up for irix"
elif echo "$build_os" | grep aix > /dev/null; then
RPM=rpm.shared
echo "hacking things up for aix"
fi
#
# get rid of the 4-th tuple, if config.guess returned "linux-gnu" for build_os
#
if echo "$build_os" | grep '.*-gnu' > /dev/null ; then
build_os=`echo "${build_os}" | sed 's/-gnu$//'`
fi
changequote(<, >)
build_os_exact="${build_os}"
build_os_major=`echo "${build_os}" | sed 's/\..*$//'`
build_os_noversion=`echo "${build_os}" | sed 's/[0-9]*\..*$//'`
changequote([, ])
rm -f ./find-provides.sh
if test -f ${srcdir}/autodeps/${build_os_exact}.prov ; then
echo "using ${srcdir}/autodeps/${build_os_exact}.prov for automatic provides generation"
ln -s ${srcdir}/autodeps/${build_os_exact}.prov ./find-provides.sh
elif test -f ${srcdir}/autodeps/${build_os_major}.prov ; then
echo "using ${srcdir}/autodeps/${build_os_major}.prov for automatic provides generation"
ln -s ${srcdir}/autodeps/${build_os_major}.prov ./find-provides.sh
elif test -f ${srcdir}/autodeps/${build_os_noversion}.prov ; then
echo "using ${srcdir}/autodeps/${build_os_noversion}.prov for automatic provides generation"
ln -s ${srcdir}/autodeps/${build_os_noversion}.prov ./find-provides.sh
else
echo "*** no default provides information is available for ${build_os_noversion}"
ln -s ${srcdir}/autodeps/none ./find-provides.sh
fi
rm -f ./find-requires.sh
if test -f ${srcdir}/autodeps/${build_os_exact}.req ; then
echo "using ${srcdir}/autodeps/${build_os_exact}.req for automatic requires generation"
ln -s ${srcdir}/autodeps/${build_os_exact}.req ./find-requires.sh
elif test -f ${srcdir}/autodeps/${build_os_major}.req ; then
echo "using ${srcdir}/autodeps/${build_os_major}.req for automatic requires generation"
ln -s ${srcdir}/autodeps/${build_os_major}.req ./find-requires.sh
elif test -f ${srcdir}/autodeps/${build_os_noversion}.req ; then
echo "using ${srcdir}/autodeps/${build_os_noversion}.req for automatic requires generation"
ln -s ${srcdir}/autodeps/${build_os_noversion}.req ./find-requires.sh
else
echo "*** no default requires information is available for ${build_os_noversion}"
ln -s ${srcdir}/autodeps/none ./find-requires.sh
fi
if test -n "$MISCOBJS" ; then
MISCDIR=misc
LIBMISC=-lmisc
MISCPATH=misc/libmisc.a
fi
AC_SUBST(MISCOBJS)
AC_SUBST(INCPATH)
AC_SUBST(LIBINTL)
AC_SUBST(varprefix)
AC_SUBST(tmpdir)
AC_SUBST(topdir)
AC_SUBST(topsrcdir)
AC_SUBST(INTLDEF)
AC_SUBST(XGETTEXT)
AC_SUBST(LIBINTL)
AC_SUBST(LIBS)
AC_SUBST(LIBDL)
AC_SUBST(PO)
AC_SUBST(GETTEXTSTUB)
AC_SUBST(RPM)
AC_SUBST(GZIPBIN)
AC_SUBST(FIXPERMS)
AC_SUBST(MISCDIR)
AC_SUBST(LIBMISC)
AC_SUBST(MISCPATH)
AC_SUBST(RPMCONFIGDIR)
AC_SUBST(MKDIR_P)
if test -d newbuild ; then
NBMAKEFILE=newbuild/Makefile
else
NBMAKEFILE=
fi
AC_CONFIG_SUBDIRS(popt)
AC_OUTPUT(Makefile Makefile.inc lib-rpmrc lib/Makefile build/Makefile $NBMAKEFILE tools/Makefile po/Makefile misc/Makefile)
|