[Date Prev][Date Next] [Chronological] [Thread] [Top]

mkdep without `cc -M'



Has anyone got a small mkdep program which build/mkdep can use and which
e.g. parses the cc -E output instead of depending on the cc -M option?


mkdep fails if cc's `-M' option does not work as expected.
On Solaris /opt/SUNWspro/bin/cc, `-M' is a linker option.  So `make
depend' complains:
  ld: fatal: file -I../../include: stat failed: No such file or directory
when mkdep runs the command
  cc -M -I../../include -I../../include -DHAVE_CONFIG_H admin.c ...

/opt/SUNWspro/bin/cc calls the "mkdep option" `-xM' or `-xM1':

     -xM  (...) generates makefile dependencies and sends the result
          to the standard output (...)
 
     -xM1 Same as -xM except that -xM1 does not report dependencies
          for /usr/include header files.  (...)


Instead of remembering special cases, mkdep could revert to parsing the
output of `cc -E'.  SUNWspro cc's -E output looks quite normal:

$ cc -E -I. x.c | grep '^#.*".*h"'
# 1 "./b.h"
# 1 "./c.h"
# 1 "/usr/include/stdio.h"
# 1 "/usr/include/sys/feature_tests.h"
# 1 "/usr/include/sys/va_list.h"
# 19 "/usr/include/stdio.h"
# 4 "./a.h"

-- 
Hallvard