]> The Tcpdump Group git mirrors - libpcap/commitdiff
Support dependency generation with some non-GCC compilers.
authorGuy Harris <[email protected]>
Wed, 8 May 2013 07:06:44 +0000 (00:06 -0700)
committerGuy Harris <[email protected]>
Mon, 13 May 2013 19:44:54 +0000 (12:44 -0700)
Also, if we don't support it with a given compiler, have "make depend"
not run mkdep, as it won't do anything useful.

Makefile.in
aclocal.m4
configure
mkdep

index 9d99920a6dd0f44ee256f7f72ef47e8a28ed8d46..95d36e734a3296f053c670e5d11f31a59b95673d 100644 (file)
@@ -48,6 +48,7 @@ LD = /usr/bin/ld
 CC = @CC@
 AR = @AR@
 LN_S = @LN_S@
+MKDEP = @MKDEP@
 CCOPT = @V_CCOPT@
 INCLS = -I. @V_INCLS@
 DEFS = @DEFS@ @V_DEFS@
@@ -58,6 +59,7 @@ CFLAGS = @CFLAGS@
 LDFLAGS = @LDFLAGS@
 DYEXT = @DYEXT@
 V_RPATH_OPT = @V_RPATH_OPT@
+DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
 PROG=libpcap
 
 # Standard CFLAGS
@@ -725,7 +727,7 @@ releasetar:
           rm -rf $$name
 
 depend:        $(GENSRC) $(GENHDR) bpf_filter.c
-       ./mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
+       $(MKDEP) -c $(CC) -m $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC)
 
 Makefile: Makefile.in config.status
        ./config.status
index aa0b4d20eb288391e833fb28090ba2c00212368e..667c7b992f7f08f78d909edf51ddde62ccaaa88d 100644 (file)
@@ -202,6 +202,173 @@ AC_DEFUN(AC_LBL_C_INIT,
     fi
 ])
 
+dnl
+dnl Check whether, if you pass an unknown warning option to the
+dnl compiler, it fails or just prints a warning message and succeeds.
+dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
+dnl to force an error if it would otherwise just print a warning message
+dnl and succeed.
+dnl
+AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
+    [
+       AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
+       save_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
+       AC_TRY_COMPILE(
+           [],
+           [return 0],
+           [
+               AC_MSG_RESULT([no])
+               #
+               # We're assuming this is clang, where
+               # -Werror=unknown-warning-option is the appropriate
+               # option to force the compiler to fail.
+               # 
+               ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
+           ],
+           [
+               AC_MSG_RESULT([yes])
+           ])
+       CFLAGS="$save_CFLAGS"
+    ])
+
+dnl
+dnl Check whether the compiler option specified as the second argument
+dnl is supported by the compiler and, if so, add it to the macro
+dnl specified as the first argument
+dnl
+AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
+    [
+       AC_MSG_CHECKING([whether the compiler supports the $2 option])
+       save_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
+       AC_TRY_COMPILE(
+           [],
+           [return 0],
+           [
+               AC_MSG_RESULT([yes])
+               CFLAGS="$save_CFLAGS"
+               $1="$$1 $2"
+           ],
+           [
+               AC_MSG_RESULT([no])
+               CFLAGS="$save_CFLAGS"
+           ])
+    ])
+
+dnl
+dnl Check whether the compiler supports an option to generate
+dnl Makefile-style dependency lines
+dnl
+dnl GCC uses -M for this.  Non-GCC compilers that support this
+dnl use a variety of flags, including but not limited to -M.
+dnl
+dnl We test whether the flag in question is supported, as older
+dnl versions of compilers might not support it.
+dnl
+dnl We don't try all the possible flags, just in case some flag means
+dnl "generate dependencies" on one compiler but means something else
+dnl on another compiler.
+dnl
+dnl Most compilers that support this send the output to the standard
+dnl output by default.  IBM's XLC, however, supports -M but sends
+dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
+dnl to work around that, so we don't bother with XLC.
+dnl
+AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
+    [
+       AC_MSG_CHECKING([whether the compiler supports generating dependencies])
+       if test "$GCC" = yes ; then
+               #
+               # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
+               # though it's not); we assume that, in this case, the flag
+               # would be -M.
+               #
+               ac_lbl_dependency_flag="-M"
+       else
+               #
+               # Not GCC or a compiler deemed to be GCC; what platform is
+               # this?  (We're assuming that if the compiler isn't GCC
+               # it's the compiler from the vendor of the OS; that won't
+               # necessarily be true for x86 platforms, where it might be
+               # the Intel C compiler.)
+               #
+               case "$host_os" in
+
+               irix*|osf*|darwin*)
+                       #
+                       # MIPS C for IRIX, DEC C, and clang all use -M.
+                       #
+                       ac_lbl_dependency_flag="-M"
+                       ;;
+
+               solaris*)
+                       #
+                       # Sun C uses -xM.
+                       #
+                       ac_lbl_dependency_flag="-xM"
+                       ;;
+
+               hpux*)
+                       #
+                       # HP's older C compilers don't support this.
+                       # HP's newer C compilers support this with
+                       # either +M or +Make; the older compilers
+                       # interpret +M as something completely
+                       # different, so we use +Make so we don't
+                       # think it works with the older compilers.
+                       #
+                       ac_lbl_dependency_flag="+Make"
+                       ;;
+
+               *)
+                       #
+                       # Not one of the above; assume no support for
+                       # generating dependencies.
+                       #
+                       ac_lbl_dependency_flag=""
+                       ;;
+               esac
+       fi
+
+       #
+       # Is ac_lbl_dependency_flag defined and, if so, does the compiler
+       # complain about it?
+       #
+       # Note: clang doesn't seem to exit with an error status when handed
+       # an unknown non-warning error, even if you pass it
+       # -Werror=unknown-warning-option.  However, it always supports
+       # -M, so the fact that this test always succeeds with clang
+       # isn't an issue.
+       #
+       if test ! -z "$ac_lbl_dependency_flag"; then
+               AC_LANG_CONFTEST(
+                   [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
+               echo "$CC" $ac_lbl_dependency_flag conftest.c >&5
+               if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then
+                       AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
+                       DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
+                       MKDEP='${srcdir}/mkdep'
+               else
+                       AC_MSG_RESULT([no])
+                       #
+                       # We can't run mkdep, so have "make depend" do
+                       # nothing.
+                       #
+                       MKDEP=:
+               fi
+               rm -rf conftest*
+       else
+               AC_MSG_RESULT([no])
+               #
+               # We can't run mkdep, so have "make depend" do
+               # nothing.
+               #
+               MKDEP=:
+       fi
+       AC_SUBST(DEPENDENCY_CFLAG MKDEP)
+    ])
+
 dnl
 dnl Determine what options are needed to build a shared library
 dnl
@@ -789,6 +956,22 @@ AC_DEFUN(AC_LBL_DEVEL,
            $1="$$1 ${LBL_CFLAGS}"
     fi
     if test -f .devel ; then
+           #
+           # At least one version of HP's C compiler will not
+           # exit with a non-zero exit status when given an
+           # unknown -W flag, even if you use +We and the
+           # number of the warning it gives for that issue.
+           #
+           # We therefore skip all the warning option stuff
+           # on HP-UX.
+           #
+           if test "$ac_lbl_cc_is_hp_c" != yes; then
+                   AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
+                   AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
+                   AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
+                   AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
+           fi
+           AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
            if test "$GCC" = yes ; then
                    if test "${LBL_CFLAGS+set}" != set; then
                            if test "$ac_cv_prog_cc_g" = yes ; then
index 927ba097fcabacbdbbc176af59eeca2b285984fe..12afe9e642a48222877b082167e4353be187d003 100755 (executable)
--- a/configure
+++ b/configure
@@ -681,6 +681,7 @@ V_YACC
 RANLIB
 AR
 LN_S
+DEPENDENCY_CFLAG MKDEP
 V_CCOPT
 V_DEFS
 V_FINDALLDEVS
@@ -10472,6 +10473,347 @@ rm -f os-proto.h
            V_CCOPT="$V_CCOPT ${LBL_CFLAGS}"
     fi
     if test -f .devel ; then
+           #
+           # At least one version of HP's C compiler will not
+           # exit with a non-zero exit status when given an
+           # unknown -W flag, even if you use +We and the
+           # number of the warning it gives for that issue.
+           #
+           # We therefore skip all the warning option stuff
+           # on HP-UX.
+           #
+           if test "$ac_lbl_cc_is_hp_c" != yes; then
+
+       { echo "$as_me:$LINENO: checking whether the compiler fails when given an unknown warning option" >&5
+echo $ECHO_N "checking whether the compiler fails when given an unknown warning option... $ECHO_C" >&6; }
+       save_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_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
+
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               #
+               # We're assuming this is clang, where
+               # -Werror=unknown-warning-option is the appropriate
+               # option to force the compiler to fail.
+               #
+               ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       CFLAGS="$save_CFLAGS"
+
+
+       { echo "$as_me:$LINENO: checking whether the compiler supports the -Wall option" >&5
+echo $ECHO_N "checking whether the compiler supports the -Wall option... $ECHO_C" >&6; }
+       save_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall"
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_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
+
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               CFLAGS="$save_CFLAGS"
+               V_CCOPT="$V_CCOPT -Wall"
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CFLAGS="$save_CFLAGS"
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+       { echo "$as_me:$LINENO: checking whether the compiler supports the -Wmissing-prototypes option" >&5
+echo $ECHO_N "checking whether the compiler supports the -Wmissing-prototypes option... $ECHO_C" >&6; }
+       save_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes"
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_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
+
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               CFLAGS="$save_CFLAGS"
+               V_CCOPT="$V_CCOPT -Wmissing-prototypes"
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CFLAGS="$save_CFLAGS"
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+       { echo "$as_me:$LINENO: checking whether the compiler supports the -Wstrict-prototypes option" >&5
+echo $ECHO_N "checking whether the compiler supports the -Wstrict-prototypes option... $ECHO_C" >&6; }
+       save_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes"
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_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
+
+               { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               CFLAGS="$save_CFLAGS"
+               V_CCOPT="$V_CCOPT -Wstrict-prototypes"
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               CFLAGS="$save_CFLAGS"
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+           fi
+
+       { echo "$as_me:$LINENO: checking whether the compiler supports generating dependencies" >&5
+echo $ECHO_N "checking whether the compiler supports generating dependencies... $ECHO_C" >&6; }
+       if test "$GCC" = yes ; then
+               #
+               # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
+               # though it's not); we assume that, in this case, the flag
+               # would be -M.
+               #
+               ac_lbl_dependency_flag="-M"
+       else
+               #
+               # Not GCC or a compiler deemed to be GCC; what platform is
+               # this?  (We're assuming that if the compiler isn't GCC
+               # it's the compiler from the vendor of the OS; that won't
+               # necessarily be true for x86 platforms, where it might be
+               # the Intel C compiler.)
+               #
+               case "$host_os" in
+
+               irix*|osf*|darwin*)
+                       #
+                       # MIPS C for IRIX, DEC C, and clang all use -M.
+                       #
+                       ac_lbl_dependency_flag="-M"
+                       ;;
+
+               solaris*)
+                       #
+                       # Sun C uses -xM.
+                       #
+                       ac_lbl_dependency_flag="-xM"
+                       ;;
+
+               hpux*)
+                       #
+                       # HP's older C compilers don't support this.
+                       # HP's newer C compilers support this with
+                       # either +M or +Make; the older compilers
+                       # interpret +M as something completely
+                       # different, so we use +Make so we don't
+                       # think it works with the older compilers.
+                       #
+                       ac_lbl_dependency_flag="+Make"
+                       ;;
+
+               *)
+                       #
+                       # Not one of the above; assume no support for
+                       # generating dependencies.
+                       #
+                       ac_lbl_dependency_flag=""
+                       ;;
+               esac
+       fi
+
+       #
+       # Is ac_lbl_dependency_flag defined and, if so, does the compiler
+       # complain about it?
+       #
+       # Note: clang doesn't seem to exit with an error status when handed
+       # an unknown non-warning error, even if you pass it
+       # -Werror=unknown-warning-option.  However, it always supports
+       # -M, so the fact that this test always succeeds with clang
+       # isn't an issue.
+       #
+       if test ! -z "$ac_lbl_dependency_flag"; then
+               cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+int main(void) { return 0; }
+_ACEOF
+               echo "$CC" $ac_lbl_dependency_flag conftest.c >&5
+               if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then
+                       { echo "$as_me:$LINENO: result: yes, with $ac_lbl_dependency_flag" >&5
+echo "${ECHO_T}yes, with $ac_lbl_dependency_flag" >&6; }
+                       DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
+                       MKDEP='${srcdir}/mkdep'
+               else
+                       { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+                       #
+                       # We can't run mkdep, so have "make depend" do
+                       # nothing.
+                       #
+                       MKDEP=:
+               fi
+               rm -rf conftest*
+       else
+               { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+               #
+               # We can't run mkdep, so have "make depend" do
+               # nothing.
+               #
+               MKDEP=:
+       fi
+
+
            if test "$GCC" = yes ; then
                    if test "${LBL_CFLAGS+set}" != set; then
                            if test "$ac_cv_prog_cc_g" = yes ; then
@@ -12844,6 +13186,8 @@ V_YACC!$V_YACC$ac_delim
 RANLIB!$RANLIB$ac_delim
 AR!$AR$ac_delim
 LN_S!$LN_S$ac_delim
+DEPENDENCY_CFLAG!$DEPENDENCY_CFLAG$ac_delim
+MKDEP!$MKDEP$ac_delim
 V_CCOPT!$V_CCOPT$ac_delim
 V_DEFS!$V_DEFS$ac_delim
 V_FINDALLDEVS!$V_FINDALLDEVS$ac_delim
@@ -12872,8 +13216,6 @@ CAN_SRC!$CAN_SRC$ac_delim
 PKGCONFIG!$PKGCONFIG$ac_delim
 PCAP_SUPPORT_DBUS!$PCAP_SUPPORT_DBUS$ac_delim
 DBUS_SRC!$DBUS_SRC$ac_delim
-INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
-INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -12915,11 +13257,13 @@ _ACEOF
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
+INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
+INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
 INSTALL_DATA!$INSTALL_DATA$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 2; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 4; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/mkdep b/mkdep
index b41a00e1da407ab3d88418625aea66bc2e6961a9..bfe4a2614a4f02d2c2c18c23cdd8df7d031158e0 100755 (executable)
--- a/mkdep
+++ b/mkdep
@@ -18,6 +18,7 @@ export PATH
 
 MAKE=Makefile                  # default makefile name is "Makefile"
 CC=cc                          # default C compiler is "cc"
+DEPENDENCY_CFLAG=-M            # default dependency-generation flag is -M
 
 while :
        do case "$1" in
@@ -31,6 +32,11 @@ while :
                        MAKE=$2
                        shift; shift ;;
 
+               # -m allows you to specify the dependency-generation flag
+               -m)
+                       DEPENDENCY_CFLAG=$2
+                       shift; shift ;;
+
                # the -p flag produces "program: program.c" style dependencies
                # so .o's don't get produced
                -p)
@@ -42,7 +48,7 @@ while :
 done
 
 if [ $# = 0 ] ; then
-       echo 'usage: mkdep [-p] [-c cc] [-f makefile] [flags] file ...'
+       echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...'
        exit 1
 fi
 
@@ -74,7 +80,7 @@ _EOF_
 # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
 
 # XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
-$CC -M $* |
+$CC $DEPENDENCY_CFLAG $* |
 sed "
        s; \./; ;g
        $SED" |