Source: apcalc
Version: 2.12.5.0-1
Tags: patch upstream
Control: block 798955 by -1

apcalc checks header existence by searching them in a few file system
locations. Unfortunately, Debian's /usr/include/<triplet> is not among
those locations and that makes apcalc fail to build when built against a
non-glibc or a glibc with multiarch headers (#798955). The attached
patch replaces those file existence tests with compile tests. The
compiler knows much better whether headers exists and thus the
complexity of the Makefile is reduced. Please consider applying the
attached patch.

Helmut
--- apcalc-2.12.5.0.orig/Makefile
+++ apcalc-2.12.5.0/Makefile
@@ -2254,22 +2254,13 @@
        ${Q} echo '' >> endian_calc.h
        ${Q} echo '/* what byte order are we? */' >> endian_calc.h
        -${Q} if [ X"${CALC_BYTE_ORDER}" = X ]; then \
-           if [ -f ${INCDIR}/endian.h ]; then \
-               echo '#include <endian.h>' >> endian_calc.h; \
-               echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \
-           elif [ -f ${INCDIR}/machine/endian.h ]; then \
-               echo '#include <machine/endian.h>' >> endian_calc.h; \
-               echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \
-           elif [ -f ${INCDIR}/sys/endian.h ]; then \
-               echo '#include <sys/endian.h>' >> endian_calc.h; \
-               echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \
-           elif [ -f /usr/include/endian.h ]; then \
+           if echo '#include <endian.h>' | ${CC} -E - >/dev/null 2>&1; then \
                echo '#include <endian.h>' >> endian_calc.h; \
                echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \
-           elif [ -f /usr/include/machine/endian.h ]; then \
+           elif echo '#include <machine/endian.h>' | ${CC} -E - >/dev/null 
2>&1; then \
                echo '#include <machine/endian.h>' >> endian_calc.h; \
                echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \
-           elif [ -f /usr/include/sys/endian.h ]; then \
+           elif echo '#include <sys/endian.h>' | ${CC} -E- >/dev/null 2>&1; 
then \
                echo '#include <sys/endian.h>' >> endian_calc.h; \
                echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \
            else \
@@ -2336,9 +2327,7 @@
            echo '#define HAVE_TIMES_H  /* yes */' >> have_times.h; \
        elif [ X"${HAVE_TIMES_H}" = X"NO" ]; then \
            echo '#undef HAVE_TIMES_H  /* no */' >> have_times.h; \
-       elif [ -f ${INCDIR}/times.h ]; then \
-           echo '#define HAVE_TIMES_H  /* yes */' >> have_times.h; \
-       elif [ -f /usr/include/times.h ]; then \
+       elif echo '#include <times.h>' | ${CC} -E - >/dev/null 2>&1; then \
            echo '#define HAVE_TIMES_H  /* yes */' >> have_times.h; \
        else \
            echo '#undef HAVE_TIMES_H  /* no */' >> have_times.h; \
@@ -2347,9 +2336,7 @@
            echo '#define HAVE_SYS_TIMES_H      /* yes */' >> have_times.h; \
        elif [ X"${HAVE_SYS_TIMES_H}" = X"NO" ]; then \
            echo '#undef HAVE_SYS_TIMES_H  /* no */' >> have_times.h; \
-       elif [ -f ${INCDIR}/sys/times.h ]; then \
-           echo '#define HAVE_SYS_TIMES_H  /* yes */' >> have_times.h; \
-       elif [ -f /usr/include/sys/times.h ]; then \
+       elif echo '#include <sys/times.h>' | ${CC} -E - >/dev/null 2>&1; then \
            echo '#define HAVE_SYS_TIMES_H  /* yes */' >> have_times.h; \
        else \
            echo '#undef HAVE_SYS_TIMES_H  /* no */' >> have_times.h; \
@@ -2358,9 +2345,7 @@
            echo '#define HAVE_TIME_H   /* yes */' >> have_times.h; \
        elif [ X"${HAVE_TIME_H}" = X"NO" ]; then \
            echo '#undef HAVE_TIME_H  /* no */' >> have_times.h; \
-       elif [ -f ${INCDIR}/time.h ]; then \
-           echo '#define HAVE_TIME_H  /* yes */' >> have_times.h; \
-       elif [ -f /usr/include/time.h ]; then \
+       elif echo '#include <time.h>' | ${CC} -E - >/dev/null 2>&1; then \
            echo '#define HAVE_TIME_H  /* yes */' >> have_times.h; \
        else \
            echo '#undef HAVE_TIME_H  /* no */' >> have_times.h; \
@@ -2369,9 +2354,7 @@
            echo '#define HAVE_SYS_TIME_H       /* yes */' >> have_times.h; \
        elif [ X"${HAVE_SYS_TIME_H}" = X"NO" ]; then \
            echo '#undef HAVE_SYS_TIME_H  /* no */' >> have_times.h; \
-       elif [ -f ${INCDIR}/sys/time.h ]; then \
-           echo '#define HAVE_SYS_TIME_H  /* yes */' >> have_times.h; \
-       elif [ -f /usr/include/sys/time.h ]; then \
+       elif echo '#include <sys/time.h>' | ${CC} -E - >/dev/null 2>&1; then \
            echo '#define HAVE_SYS_TIME_H  /* yes */' >> have_times.h; \
        else \
            echo '#undef HAVE_SYS_TIME_H  /* no */' >> have_times.h; \
@@ -2407,9 +2390,7 @@
            echo '#define HAVE_STDLIB_H /* yes */' >> have_stdlib.h; \
        elif [ X"${HAVE_STDLIB_H}" = X"NO" ]; then \
            echo '#undef HAVE_STDLIB_H  /* no */' >> have_stdlib.h; \
-       elif [ -f ${INCDIR}/stdlib.h ]; then \
-           echo '#define HAVE_STDLIB_H  /* yes */' >> have_stdlib.h; \
-       elif [ -f /usr/include/stdlib.h ]; then \
+       elif echo '#include <stdlib.h>' | ${CC} -E - >/dev/null 2>&1; then \
            echo '#define HAVE_STDLIB_H  /* yes */' >> have_stdlib.h; \
        else \
            echo '#undef HAVE_STDLIB_H  /* no */' >> have_stdlib.h; \
@@ -2445,9 +2426,7 @@
            echo '#define HAVE_UNISTD_H /* yes */' >> have_unistd.h; \
        elif [ X"${HAVE_UNISTD_H}" = X"NO" ]; then \
            echo '#undef HAVE_UNISTD_H  /* no */' >> have_unistd.h; \
-       elif [ -f ${INCDIR}/unistd.h ]; then \
-           echo '#define HAVE_UNISTD_H  /* yes */' >> have_unistd.h; \
-       elif [ -f /usr/include/unistd.h ]; then \
+       elif echo '#include <unistd.h>' | ${CC} -E - >/dev/null 2>&1; then \
            echo '#define HAVE_UNISTD_H  /* yes */' >> have_unistd.h; \
        else \
            echo '#undef HAVE_UNISTD_H  /* no */' >> have_unistd.h; \
@@ -2483,9 +2462,7 @@
            echo '#define HAVE_STRING_H /* yes */' >> have_string.h; \
        elif [ X"${HAVE_STRING_H}" = X"NO" ]; then \
            echo '#undef HAVE_STRING_H  /* no */' >> have_string.h; \
-       elif [ -f ${INCDIR}/string.h ]; then \
-           echo '#define HAVE_STRING_H  /* yes */' >> have_string.h; \
-       elif [ -f /usr/include/string.h ]; then \
+       elif echo '#include <string.h>' | ${CC} -E - >/dev/null 2>&1; then \
            echo '#define HAVE_STRING_H  /* yes */' >> have_string.h; \
        else \
            echo '#undef HAVE_STRING_H  /* no */' >> have_string.h; \
@@ -2525,22 +2502,12 @@
            echo '#undef USE_TERMIOS   /* <termios.h> */' >> terminal.h; \
            echo '#undef USE_TERMIO    /* <termio.h> */' >> terminal.h; \
            echo '#undef USE_SGTTY     /* <sys/ioctl.h> */' >> terminal.h; \
-       elif [ -f ${INCDIR}/termios.h ]; then \
-           echo '/* use termios */' >> terminal.h; \
-           echo '#define USE_TERMIOS  /* <termios.h> */' >> terminal.h; \
-           echo '#undef USE_TERMIO    /* <termio.h> */' >> terminal.h; \
-           echo '#undef USE_SGTTY     /* <sys/ioctl.h> */' >> terminal.h; \
-       elif [ -f ${INCDIR}/termio.h ]; then \
-           echo '/* use termio */' >> terminal.h; \
-           echo '#undef USE_TERMIOS   /* <termios.h> */' >> terminal.h; \
-           echo '#define USE_TERMIO   /* <termio.h> */' >> terminal.h; \
-           echo '#undef USE_SGTTY     /* <sys/ioctl.h> */' >> terminal.h; \
-       elif [ -f /usr/include/termios.h ]; then \
+       elif echo '#include <termios.h>' | ${CC} -E - >/dev/null 2>&1; then \
            echo '/* use termios */' >> terminal.h; \
            echo '#define USE_TERMIOS  /* <termios.h> */' >> terminal.h; \
            echo '#undef USE_TERMIO    /* <termio.h> */' >> terminal.h; \
            echo '#undef USE_SGTTY     /* <sys/ioctl.h> */' >> terminal.h; \
-       elif [ -f /usr/include/termio.h ]; then \
+       elif echo '#include <termio.h>' | ${CC} -E - >/dev/null 2>&1; then \
            echo '/* use termio */' >> terminal.h; \
            echo '#undef USE_TERMIOS   /* <termios.h> */' >> terminal.h; \
            echo '#define USE_TERMIO   /* <termio.h> */' >> terminal.h; \

Reply via email to