From: Christos Zoulas Date: Sun, 2 Dec 2007 00:28:10 +0000 (+0000) Subject: fix compression code to only be compiled when we have both zlib.h and libz. X-Git-Tag: FILE4_22~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b950f1f426f8855e69d6f3dcc32067e931e015b7;p=file fix compression code to only be compiled when we have both zlib.h and libz. --- diff --git a/ChangeLog b/ChangeLog index b64b4939..4d5d0be9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ +2007-12-01 19:55 Christos Zoulas + + * make sure we have zlib.h and libz to compile the builtin + decompress code + 2007-10-28 20:48 Christos Zoulas * float and double magic support (Behan Webster) diff --git a/config.guess b/config.guess index 3d427f02..b6e69558 100755 --- a/config.guess +++ b/config.guess @@ -1,13 +1,10 @@ #! /bin/sh -# -# $NetBSD: config.guess,v 1.9 2006/10/29 23:50:54 wiz Exp $ -# # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-07-02' +timestamp='2007-03-06' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -784,7 +781,7 @@ EOF i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; - i*:MINGW*:*) + *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) @@ -794,12 +791,15 @@ EOF i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - x86:Interix*:[3456]*) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - EM64T:Interix*:[3456]*) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; + *:Interix*:[3456]*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T | authenticamd) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; @@ -954,6 +954,9 @@ EOF x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; + xtensa:Linux:*:*) + echo xtensa-unknown-linux-gnu + exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent @@ -1212,6 +1215,15 @@ EOF SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; diff --git a/config.h.in b/config.h.in index 2682a238..a745cf13 100644 --- a/config.h.in +++ b/config.h.in @@ -133,6 +133,9 @@ /* Define to 1 if you have the `wcwidth' function. */ #undef HAVE_WCWIDTH +/* Define to 1 if you have the header file. */ +#undef HAVE_ZLIB_H + /* Define to 1 if `major', `minor', and `makedev' are declared in . */ #undef MAJOR_IN_MKDEV diff --git a/config.sub b/config.sub index 5b2ab482..5defff65 100755 --- a/config.sub +++ b/config.sub @@ -1,13 +1,10 @@ #! /bin/sh -# -# $NetBSD: config.sub,v 1.8 2006/10/29 23:52:55 wiz Exp $ -# # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-09-20' +timestamp='2007-01-18' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -248,12 +245,12 @@ case $basic_machine in | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ + | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore \ + | maxq | mb | microblaze | mcore | mep \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -327,7 +324,7 @@ case $basic_machine in | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ @@ -1225,7 +1222,7 @@ case $os in | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1420,6 +1417,9 @@ case $basic_machine in m68*-cisco) os=-aout ;; + mep-*) + os=-elf + ;; mips*-cisco) os=-elf ;; diff --git a/configure b/configure index 986eb476..c7a6bb8f 100755 --- a/configure +++ b/configure @@ -21503,6 +21503,146 @@ fi done +for ac_header in zlib.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + { echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } if test "${ac_cv_c_const+set}" = set; then diff --git a/configure.in b/configure.in index 1c9b64c9..f975ac93 100644 --- a/configure.in +++ b/configure.in @@ -85,6 +85,7 @@ AC_HEADER_STDINT AC_CHECK_HEADERS(fcntl.h locale.h stdint.h inttypes.h unistd.h getopt.h) AC_CHECK_HEADERS(utime.h wchar.h wctype.h limits.h) AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h) +AC_CHECK_HEADERS(zlib.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/magic/Makefile.in b/magic/Makefile.in index d6b082fe..ba2ef9df 100644 --- a/magic/Makefile.in +++ b/magic/Makefile.in @@ -216,6 +216,7 @@ Magdir/digital \ Magdir/dolby \ Magdir/dump \ Magdir/editors \ +Magdir/efi \ Magdir/elf \ Magdir/encore \ Magdir/epoc \ @@ -224,6 +225,7 @@ Magdir/fcs \ Magdir/filesystems \ Magdir/flash \ Magdir/fonts \ +Magdir/fortran \ Magdir/frame \ Magdir/freebsd \ Magdir/fsav \ diff --git a/src/Makefile.am b/src/Makefile.am index 4a941380..9ab9258c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,8 @@ AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"' libmagic_la_SOURCES = magic.c apprentice.c softmagic.c ascmagic.c \ compress.c is_tar.c readelf.c print.c fsmagic.c \ - funcs.c file.h names.h patchlevel.h readelf.h tar.h apptype.c + funcs.c file.h names.h patchlevel.h readelf.h tar.h apptype.c \ + file_opts.h libmagic_la_LDFLAGS = -no-undefined -version-info 1:0:0 file_SOURCES = file.c diff --git a/src/Makefile.in b/src/Makefile.in index 6a219435..1eb70bfb 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -202,7 +202,8 @@ EXTRA_DIST = test.c AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"' libmagic_la_SOURCES = magic.c apprentice.c softmagic.c ascmagic.c \ compress.c is_tar.c readelf.c print.c fsmagic.c \ - funcs.c file.h names.h patchlevel.h readelf.h tar.h apptype.c + funcs.c file.h names.h patchlevel.h readelf.h tar.h apptype.c \ + file_opts.h libmagic_la_LDFLAGS = -no-undefined -version-info 1:0:0 file_SOURCES = file.c diff --git a/src/compress.c b/src/compress.c index 5fc741f6..a785072e 100644 --- a/src/compress.c +++ b/src/compress.c @@ -49,13 +49,14 @@ #if defined(HAVE_SYS_TIME_H) #include #endif -#ifdef HAVE_LIBZ +#if defined(HAVE_ZLIB_H) && defined(HAVE_LIBZ) +#define BUILTIN_DECOMPRESS #include #endif #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.52 2007/08/19 03:45:08 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.53 2007/10/17 19:33:31 christos Exp $") #endif private struct { @@ -86,7 +87,7 @@ private size_t ncompr = sizeof(compr) / sizeof(compr[0]); private ssize_t swrite(int, const void *, size_t); private size_t uncompressbuf(struct magic_set *, int, size_t, const unsigned char *, unsigned char **, size_t); -#ifdef HAVE_LIBZ +#ifdef BUILTIN_DECOMPRESS private size_t uncompressgzipped(struct magic_set *, const unsigned char *, unsigned char **, size_t); #endif @@ -293,7 +294,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf, return fd; } -#ifdef HAVE_LIBZ +#ifdef BUILTIN_DECOMPRESS #define FHCRC (1 << 1) #define FEXTRA (1 << 2) @@ -372,7 +373,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method, int fdin[2], fdout[2]; int r; -#ifdef HAVE_LIBZ +#ifdef BUILTIN_DECOMPRESS if (method == 2) return uncompressgzipped(ms, old, newch, n); #endif