[alt.sources.d] mkdep program for SysV

fields-doug@cs.yale.edu (Doug Fields) (12/13/90)

Hi. I have alot of Makefiles that call a "makedep" or "mkdep" program, which
I assume adds to the end a zillion dependencies, like:

main.c: header.h defs.h structs.h
other.c: structs.h
another.c: defs.h header.h

And so forth. Anyway, I could really use this program, or one which does
something similar, for those Makefiles and as a general utility. If
anyone has any information about one of these, please let me know where
I can ftp or uuencoded mail it from.

Thanks

Doug

--
Doug Fields -- 100 Midwood Road, Greenwich, CT 06830 --- (FAX) +1 203
661 2996  uucp: {nosc | ucsd}!crash!telesys!admiral!doug,
...uunet!sir-alan!admiral!doug
The Grid BBS & Conference -- Magpie & admiral.UUCP - (TB 2500) +1 203
661 2873
(HST/V32) +1 203 661 1279 - (AX/9624) +1 203 661 2967 - (2400) +1 203
661 0450
INTERNET: fields-doug@cs.yale.edu <---- BEST TO REACH ME voice +1 203
436 0184  NEW ADDRESS: doug@sfleet.uucp - The Admiral's Starfleet
Command Xenix Computer

ronald@robobar.co.uk (Ronald S H Khoo) (12/14/90)

[ OK guys, where *do* you ask about things like makefile makers ?
  comp.unix.programmer ?  alt.sport.toe.wrestling ?  I'll try the former :-) ]

[ Now I'm going to *expect* a followup telling me what the current crop of
  mkdeps do that cc -M doesn't.  Or do people distribute makedepend
  just because some people don't have cc -M ?  Answers on a postcard to
  Craig Shergold, please, or follow up :-) ]

fields-doug@cs.yale.edu (Doug Fields) writes:

> Hi. I have alot of Makefiles that call a "makedep" or "mkdep" program, which
> I assume adds to the end a zillion dependencies [ to the end of Makefiles ]
> Anyway, I could really use [ mkdep ], or one which does
> something similar, for those Makefiles and as a general utility.

One fast and accurate way to make dependencies for makefiles is to use gcc -M.
(Doug's asking about Xenix/Sys V, so he'd need gcc.  BSD cc has -M doesn't it?)

For example, you could add something like

	depend:
		sed "/^# DELETE ME/q" Makefile > Makefile.new
		gcc $(CFLAGS) -M $(OBJS:.o=.c) >> Makefile.new
		mv Makefile.new Makefile

	# DELETE ME

to the end of your makefile.  Then "make depend" would do just that.
This works especially well when your dependencies change a lot depending
on what -I and -D flags you change in CFLAGS, just run make depend again.

Just make sure you haven't got a file called "depend" in the current
directory :-)
-- 
ronald@robobar.co.uk +44 81 991 1142 (O) +44 71 229 7741 (H)