diff options
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/configure.in b/configure.in new file mode 100644 index 000000000..0fe0f9ee6 --- /dev/null +++ b/configure.in @@ -0,0 +1,242 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_INIT(include/dpkg.h) +AC_CONFIG_HEADER(config.h) + +AC_PREFIX_DEFAULT(/usr) + +AC_PROG_CC +AC_PROG_CXX + +AC_ARG_WITH(arch, +[ --with-arch=value set/override (Debian) architecture value], +[ + if test "x$with_arch" = x; then + AC_MSG_ERROR(--with-arch requires an architecture name) + fi + AC_DEFINE_UNQUOTED(ARCHITECTURE, "${with_arch}") +],[ + AC_MSG_CHECKING(system architecture) + dpkg_archwhy='' + AC_CACHE_VAL(dpkg_cv_arch,[ + dpkg_arch="`dpkg --print-architecture 2>/dev/null`" + if test "x$dpkg_arch" != x; then + dpkg_archwhy=" (obtained from dpkg)" + elif test "${GCC-no}" = yes; then +changequote(, )dnl + dpkg_arch="`$(CC) --print-libgcc-file-name | + sed -e 's,^.*/gcc-lib/,,; s,/libgcc\.a$,,; s,/[0-9.][0-9.]*$,,; s/-.*$//'`" +changequote([, ])dnl + if test "x`echo \"$dpkg_arch\" | tr -d a-z0-9-`" != x -o "x$dpkg_arch" = x + then + dpkg_arch="" + dpkg_archwhy=" (bad output from --print-libgcc-file-name)" + else +changequote(, )dnl + dpkg_arch2="`sed -e '/^'$dpkg_arch'[ ]/!d; s/^[-0-9a-z]*[ ]*//' \ + $srcdir/archtable`" +changequote([, ])dnl + if test "x$dpkg_arch2" = "x$dpkg_arch"; then + dpkg_archwhy=" (obtained from gcc)" + elif test "x$dpkg_arch2" != x; then + dpkg_archwhy=" (from gcc, canonical form of $dpkg_arch)" + dpkg_arch="$dpkg_arch2" + else + dpkg_archwhy=" (from gcc, but not in archtable)" + fi + fi + else + dpkg_archwhy='' + fi + dpkg_cv_arch="$dpkg_arch" + ]) + if test "x$dpkg_cv_arch" != x; then + AC_MSG_RESULT("$dpkg_cv_arch$dpkg_archwhy") + AC_DEFINE_UNQUOTED(ARCHITECTURE, "${dpkg_cv_arch}") + else + AC_MSG_RESULT("failed$dpkg_archwhy") + fi +]) + +AC_ARG_WITH(newdeb, +[ --with-newdeb make dpkg-deb default to new archives], +[ + AC_DEFINE(BUILDOLDPKGFORMAT, 0) +],[ + AC_ARG_WITH(olddeb, +[ --with-olddeb make dpkg-deb default to old archives], +[ + AC_DEFINE(BUILDOLDPKGFORMAT, 1) +], +[ + case "$CC" in + /*) + pathccompiler="$CC" + ;; + *) + AC_PATH_PROG(pathccompiler,"$CC") + ;; + esac + AC_MSG_CHECKING(.deb format to build by default) + if file "$pathccompiler" 2>/dev/null | grep ELF >/dev/null 2>&1; then + AC_MSG_RESULT([new (C compiler looks like ELF)]) + AC_DEFINE(BUILDOLDPKGFORMAT, 0) + else + AC_MSG_RESULT([old (C compiler not ELF)]) + AC_DEFINE(BUILDOLDPKGFORMAT, 1) + fi +])]) + +AC_ARG_WITH(newdeb, +[ --with-newdeb make dpkg-deb default to new archives], +[AC_DEFINE(BUILDOLDPKGFORMAT, 0)]) + + +AC_MSG_CHECKING(for /usr/bin/perl) +if test -f /usr/bin/perl +then + AC_MSG_RESULT(yes) + perlpath=/usr/bin/perl + AC_SUBST(perlpath) +else + AC_MSG_RESULT(no) + AC_PATH_PROG(perlpath,perl) +fi + +AC_STDC_HEADERS +AC_PROG_INSTALL +dnl AC_PROGRAM_PATH(GZIP, gzip, ) use these from $PATH +dnl AC_PROGRAM_PATH(TAR, tar, ) use these from $PATH +AC_PROG_RANLIB +AC_MODE_T +AC_PID_T +AC_SIZE_T +AC_VPRINTF +AC_C_CONST +AC_C_BIGENDIAN +AC_CHECK_SIZEOF(unsigned long) +AC_CHECK_SIZEOF(unsigned int) +AC_CHECK_FUNCS(unsetenv alphasort scandir strerror strsignal strtoul) +AC_CHECK_HEADERS(sys/cdefs.h) + +AC_CHECK_FUNC(sysinfo, + AC_DEFINE(HAVE_SYSINFO), + AC_MSG_CHECKING(__NR_sysinfo) + AC_EGREP_CPP(yes, [ +#include <linux/sys.h> +#include <linux/kernel.h> +#include <linux/unistd.h> +#ifdef __NR_sysinfo + yes +#endif +], + AC_MSG_RESULT([yes; tsk tsk - get your libc fixed.]) + AC_DEFINE(HAVE_NRSYSINFO), + AC_MSG_RESULT(no) + AC_MSG_WARN([sysinfo missing; compilation of dpkg proper may fail.]))) + +AC_SUBST(OPTCFLAGS) +if test "${GCC-no}" = yes; then + CFLAGS=-O2; OPTCFLAGS=-O3 +else + CFLAGS=-O +fi + +dnl DPKG_CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>) +define(DPKG_CACHED_TRY_COMPILE,[ + AC_MSG_CHECKING($1) + AC_CACHE_VAL($2,[ + AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no]) + ]) + if test "x$$2" = xyes; then + true + $5 + else + true + $6 + fi +]) + +DPKG_CACHED_TRY_COMPILE(your C compiler,dpkg_cv_c_works, + [#include <string.h>], [strcmp("a","b")], + AC_MSG_RESULT(works), + AC_MSG_RESULT(broken) + AC_MSG_ERROR(C compiler is broken)) + +DPKG_CACHED_TRY_COMPILE(alphasort declaration,dpkg_cv_header_alphasort,[ +#include <sys/types.h> +#include <sys/dir.h> +], alphasort, + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_ALPHASORT_DECLARATION), + AC_MSG_RESULT(no)) + +DPKG_CACHED_TRY_COMPILE(inlines,dpkg_cv_c_inline,, + [} inline int foo (int x) {], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_INLINE), + AC_MSG_RESULT(no)) + +DPKG_CACHED_TRY_COMPILE(__attribute__((,,)),dpkg_cv_c_attribute_supported,, + [extern int testfunction(int x) __attribute__((,,))], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GNUC25_ATTRIB) + DPKG_CACHED_TRY_COMPILE(__attribute__((noreturn)),dpkg_cv_c_attribute_noreturn,, + [extern int testfunction(int x) __attribute__((noreturn))], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GNUC25_NORETURN), + AC_MSG_RESULT(no)) + DPKG_CACHED_TRY_COMPILE(__attribute__((const)),dpkg_cv_c_attribute_const,, + [extern int testfunction(int x) __attribute__((const))], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GNUC25_CONST), + AC_MSG_RESULT(no)) + DPKG_CACHED_TRY_COMPILE(__attribute__((format...)),dpkg_cv_attribute_format,, + [extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GNUC25_PRINTFFORMAT), + AC_MSG_RESULT(no)), + AC_MSG_RESULT(no)) + +AC_SUBST(CWARNS) +CWARNS="" + +dnl DPKG_C_GCC_TRY_WARNS(<warnings>,<cachevar>) +define(DPKG_C_GCC_TRY_WARNS,[ + AC_MSG_CHECKING([GCC warning flag(s) $1]) + if test "${GCC-no}" = yes + then + AC_CACHE_VAL($2,[ + oldcflags="${CFLAGS-}" + CFLAGS="${CFLAGS-} ${CWARNS} $1 -Werror" + AC_TRY_COMPILE([ +#include <string.h> +#include <stdio.h> +],[ + strcmp("a","b"); fprintf(stdout,"test ok\n"); +], [$2=yes], [$2=no]) + CFLAGS="${oldcflags}"]) + if test "x$$2" = xyes; then + CWARNS="${CWARNS} $1" + AC_MSG_RESULT(ok) + else + $2='' + AC_MSG_RESULT(no) + fi + else + AC_MSG_RESULT(no, not using GCC) + fi +]) + +DPKG_C_GCC_TRY_WARNS(-Wall -Wno-implicit, dpkg_cv_c_gcc_warn_all) +DPKG_C_GCC_TRY_WARNS(-Wwrite-strings, dpkg_cv_c_gcc_warn_writestrings) +DPKG_C_GCC_TRY_WARNS(-Wpointer-arith, dpkg_cv_c_gcc_warn_pointerarith) +DPKG_C_GCC_TRY_WARNS(-Wimplicit -Wnested-externs, dpkg_cv_c_gcc_warn_implicit) + +if test "${GCC-no}" = yes; then + CWARNS="${CWARNS} -Wmissing-prototypes -Wstrict-prototypes" +fi + +AC_OUTPUT(Makefile dpkg-deb/Makefile lib/Makefile include/Makefile + dselect/Makefile split/Makefile methods/Makefile + md5sum/Makefile main/Makefile doc/Makefile scripts/Makefile) |