Xref: news2.mv.net comp.os.msdos.djgpp:2727 From: Broeker AT axp03 DOT physik DOT rwth-aachen DOT de (Hans-Bernhard Broeker) Newsgroups: comp.os.msdos.djgpp Subject: Re: problems with makefiles Date: 15 Apr 96 12:39:32 GMT Organization: RWTH -Aachen / Rechnerbetrieb Informatik Lines: 42 Message-ID: References: NNTP-Posting-Host: axp03.physik.rwth-aachen.de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp "Rafael R. Sevilla" writes: >Hi. I've been using Bison for some time to build a small language, and it >appears to give me lots of problems in conjunction with make. In order to >make my lang.c file for example, my makefile has the following lines >lang.c lang_tab.h: lang.y $(HEADERS) ^^^^^^^^^^^^^^^^^^^ That's the source of your problem. (Explained below) > bison -y -d lang.y > update y_tab.c lang.c > update y_tab.h lang_tab.h >lang.o: lang.c > ... >Trouble is, make does a lot of redundant work: it runs bison twice and >consequently recompiles lang.c twice too, for some reason that escapes me. >Make was invented in order to avoid redundant compiles, but it appears to >be adding to them here. What's going on? Is there something wrong with my >makefile? Yes, as pointed out above, there is something wrong: in a nutshell, you should *never* have make build more than one file per rule. In the case given above, I think this should be changed to something like: y_tab.c: lang.y $(HEADERS) bison -y -d lang.y lang_tab.h: y_tab.c update y_tab.h lang_tab.h lang.c: y_tab.c update y_tab.c lang.c As to the use of update vs. copy/cp, I'm not really sure it is a good choice here, but you'll find out about that yourself soon enought, I guess. And, as Eli already pointed out, using the default .y.c make rules (with YACC=bison -y) might be a good idea as well Hans-Bernhard Broeker (Aachen, Germany)