Skip to content

Commit 6391277

Browse files
committed
grammar.y is now a built file.
It's built from grammar.y.in. Do so in the Makefile, as well as in the configure script, so if the grammar.y.in file is changed, the grammar.c file gets changed. Remove it on "make distclean". Include grammar.y.in in the distribution tarball.
1 parent dd707ae commit 6391277

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

Makefile.in

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ EXTRA_DIST = \
280280
fad-getad.c \
281281
fad-gifc.c \
282282
fad-glifc.c \
283-
grammar.y \
283+
grammar.y.in \
284284
install-sh \
285285
lbl/os-aix4.h \
286286
lbl/os-aix7.h \
@@ -510,7 +510,26 @@ scanner.h: scanner.c
510510
scanner.o: scanner.c grammar.h
511511
$(CC) $(FULL_CFLAGS) -c scanner.c
512512

513-
grammar.c: $(srcdir)/grammar.y
513+
#
514+
# Generate the grammar.y file.
515+
#
516+
# Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<";
517+
# for example, the Solaris 9 make man page says
518+
#
519+
# Because make assigns $< and $* as it would for implicit rules
520+
# (according to the suffixes list and the directory contents),
521+
# they may be unreliable when used within explicit target entries.
522+
#
523+
# and this is an explicit target entry.
524+
#
525+
# Therefore, instead of using $<, we explicitly put in $(srcdir)/libpcap.pc.in.
526+
#
527+
grammar.y: $(srcdir)/grammar.y.in ./config.status
528+
@rm -f $@ $@.tmp
529+
./config.status --file=$@.tmp:$(srcdir)/grammar.y.in
530+
mv $@.tmp $@
531+
532+
grammar.c: grammar.y
514533
$(YACC) -p pcap_ -o grammar.c -d $<
515534
grammar.h: grammar.c
516535
## Recover from the removal of $@
@@ -775,7 +794,7 @@ clean:
775794
cd testprogs; $(MAKE) clean
776795

777796
distclean: clean
778-
rm -f Makefile config.cache config.log config.status \
797+
rm -f Makefile grammar.y config.cache config.log config.status \
779798
config.h gnuc.h net os-proto.h libpcap.pc \
780799
pcap-config stamp-h stamp-h.in
781800
rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)

0 commit comments

Comments
 (0)