Path: utzoo!attcan!telly!lethe!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!radar!cadillac!pebbles!ned From: ned@pebbles.cad.mcc.com (Ned Nowotny) Newsgroups: comp.unix.programmer Subject: Re: mkdep program for SysV (Xenix/Unix) Message-ID: <14203@cadillac.CAD.MCC.COM> Date: 21 Dec 90 19:17:02 GMT References: <1990Dec13.010143@cs.yale.edu> <1990Dec14.023842.21164@robobar.co.uk> Sender: news@cadillac.CAD.MCC.COM Reply-To: ned%cad@MCC.COM (Ned Nowotny) Organization: MCC CAD Program, Austin, TX Lines: 34 In article <1990Dec14.023842.21164@robobar.co.uk> ronald@robobar.co.uk (Ronald S H Khoo) writes: >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 > Or, Makefile.depend: $(SRCS) $(HDRS) for src in $(SRCS) ; \ do \ $(CC) $(CFLAGS) -E $${src} | \ grep '^# *1 ' | \ sed 's@[^"]*"\([^"]*\)".*@\1 \\@' | \ grep -v "$${src}" | \ sort -u >> $@ ; \ echo "$${src}" >> $@ ; \ done if your compiler does not have -M but does have -E. Ned Nowotny, MCC CAD Program, Box 200195, Austin, TX 78720 Ph: (512) 338-3715 ARPA: ned@mcc.com UUCP: ...!cs.utexas.edu!milano!cadillac!ned ------------------------------------------------------------------------------- "We have ways to make you scream." - Intel advertisement in the June 1989 DDJ.