Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8521d13

Browse files
committed
Refactor flex and bison make rules
Numerous flex and bison make rules have appeared in the source treeover time, and they are all virtually identical, so we can replacethem by pattern rules with some variables for customization.Users of pgxs will also be able to benefit from this.
1 parentab11206 commit8521d13

File tree

11 files changed

+24
-126
lines changed

11 files changed

+24
-126
lines changed

‎contrib/cube/Makefile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,6 @@ endif
2727
# cubescan is compiled as part of cubeparse
2828
cubeparse.o: cubescan.c
2929

30-
cubeparse.c: cubeparse.y
31-
ifdefBISON
32-
$(BISON) $(BISONFLAGS) -o $@ $<
33-
else
34-
@$(missing) bison $< $@
35-
endif
36-
37-
cubescan.c: cubescan.l
38-
ifdefFLEX
39-
$(FLEX) $(FLEXFLAGS) -o'$@' $<
40-
else
41-
@$(missing) flex $< $@
42-
endif
43-
4430
distprep: cubeparse.c cubescan.c
4531

4632
maintainer-clean:

‎contrib/seg/Makefile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ endif
2525
# segscan is compiled as part of segparse
2626
segparse.o: segscan.c
2727

28-
segparse.c: segparse.y
29-
ifdefBISON
30-
$(BISON) $(BISONFLAGS) -o $@ $<
31-
else
32-
@$(missing) bison $< $@
33-
endif
34-
35-
segscan.c: segscan.l
36-
ifdefFLEX
37-
$(FLEX) $(FLEXFLAGS) -o'$@' $<
38-
else
39-
@$(missing) flex $< $@
40-
endif
41-
4228
distprep: segparse.c segscan.c
4329

4430
maintainer-clean:

‎src/Makefile.global.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,22 @@ TAS = @TAS@
500500
#
501501
# Global targets and rules
502502

503+
%.c:%.l
504+
ifdefFLEX
505+
$(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
506+
@$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
507+
else
508+
@$(missing) flex $< '$@'
509+
endif
510+
511+
%.c:%.y
512+
$(if$(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
513+
ifdefBISON
514+
$(BISON) $(BISONFLAGS) -o $@ $<
515+
else
516+
@$(missing) bison $< $@
517+
endif
518+
503519
%.i:%.c
504520
$(CPP)$(CPPFLAGS) -o$@$<
505521

‎src/backend/bootstrap/Makefile

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,8 @@ OBJS= bootparse.o bootstrap.o
1616

1717
include$(top_srcdir)/src/backend/common.mk
1818

19-
2019
# bootscanner is compiled as part of bootparse
2120
bootparse.o: bootscanner.c
2221

23-
bootparse.c: bootparse.y
24-
ifdefBISON
25-
$(BISON) $(BISONFLAGS) -o $@ $<
26-
else
27-
@$(missing) bison $< $@
28-
endif
29-
30-
bootscanner.c: bootscanner.l
31-
ifdefFLEX
32-
$(FLEX) $(FLEXFLAGS) -o'$@' $<
33-
else
34-
@$(missing) flex $< $@
35-
endif
36-
37-
3822
# bootparse.c and bootscanner.c are in the distribution tarball, so
3923
# they are not cleaned here.

‎src/backend/parser/Makefile

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ OBJS= analyze.o gram.o keywords.o kwlookup.o parser.o \
1717
parse_expr.o parse_func.o parse_node.o parse_oper.o parse_param.o\
1818
parse_relation.o parse_target.o parse_type.o parse_utilcmd.o scansup.o
1919

20-
FLEXFLAGS = -CF -b -p -p
21-
2220
include$(top_srcdir)/src/backend/common.mk
2321

2422

@@ -40,22 +38,12 @@ endif
4038

4139
gram.h: gram.c ;
4240

43-
gram.c: gram.y
44-
$(PERL)$(srcdir)/check_keywords.pl$<$(top_srcdir)/src/include/parser/kwlist.h
45-
ifdefBISON
46-
$(BISON) -d $(BISONFLAGS) -o $@ $<
47-
else
48-
@$(missing) bison $< $@
49-
endif
41+
gram.c: BISONFLAGS += -d
42+
gram.c: BISON_CHECK_CMD =$(PERL)$(srcdir)/check_keywords.pl$<$(top_srcdir)/src/include/parser/kwlist.h
5043

5144

52-
scan.c: scan.l
53-
ifdefFLEX
54-
$(FLEX) $(FLEXFLAGS) -o'$@' $<
55-
@if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup, see lex.backup."; exit 1; fi
56-
else
57-
@$(missing) flex $< $@
58-
endif
45+
scan.c: FLEXFLAGS = -CF -p -p
46+
scan.c: FLEX_NO_BACKUP=yes
5947

6048

6149
# Force these dependencies to be known even without dependency info built:

‎src/backend/replication/Makefile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,5 @@ include $(top_srcdir)/src/backend/common.mk
2222
# repl_scanner is compiled as part of repl_gram
2323
repl_gram.o: repl_scanner.c
2424

25-
repl_gram.c: repl_gram.y
26-
ifdefBISON
27-
$(BISON) $(BISONFLAGS) -o $@ $<
28-
else
29-
@$(missing) bison $< $@
30-
endif
31-
32-
repl_scanner.c: repl_scanner.l
33-
ifdefFLEX
34-
$(FLEX) $(FLEXFLAGS) -o'$@' $<
35-
else
36-
@$(missing) flex $< $@
37-
endif
38-
3925
# repl_gram.c and repl_scanner.c are in the distribution tarball, so
4026
# they are not cleaned here.

‎src/backend/utils/misc/Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ include $(top_srcdir)/src/backend/common.mk
2828
# guc-file is compiled as part of guc
2929
guc.o: guc-file.c
3030

31-
guc-file.c: guc-file.l
32-
ifdefFLEX
33-
$(FLEX) $(FLEXFLAGS) -o'$@' $<
34-
else
35-
@$(missing) flex $< $@
36-
endif
37-
3831
# Note: guc-file.c is not deleted by 'make clean',
3932
# since we want to ship it in distribution tarballs.
4033
clean:

‎src/bin/psql/Makefile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ OBJS=command.o common.o help.o input.o stringutils.o mainloop.o copy.o \
2626
sql_help.o\
2727
$(WIN32RES)
2828

29-
FLEXFLAGS = -Cfe -b -p -p
30-
3129

3230
all: psql
3331

@@ -49,13 +47,8 @@ sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
4947
# psqlscan is compiled as part of mainloop
5048
mainloop.o: psqlscan.c
5149

52-
psqlscan.c: psqlscan.l
53-
ifdefFLEX
54-
$(FLEX) $(FLEXFLAGS) -o'$@' $<
55-
@if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup, see lex.backup."; exit 1; fi
56-
else
57-
@$(missing) flex $< $@
58-
endif
50+
psqlscan.c: FLEXFLAGS = -Cfe -p -p
51+
psqlscan.c: FLEX_NO_BACKUP=yes
5952

6053
distprep: sql_help.h psqlscan.c
6154

‎src/interfaces/ecpg/preproc/Makefile

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,7 @@ ecpg: $(OBJS) | submake-libpgport
4242
preproc.o: pgc.c
4343

4444
preproc.h: preproc.c ;
45-
46-
preproc.c: preproc.y
47-
ifdefBISON
48-
$(BISON) -d $(BISONFLAGS) -o $@ $<
49-
else
50-
@$(missing) bison $< $@
51-
endif
52-
53-
pgc.c: pgc.l
54-
ifdefFLEX
55-
$(FLEX) $(FLEXFLAGS) -o'$@' $<
56-
else
57-
@$(missing) flex $< $@
58-
endif
45+
preproc.c: BISONFLAGS += -d
5946

6047
preproc.y: ../../../backend/parser/gram.y parse.pl ecpg.addons ecpg.header ecpg.tokens ecpg.trailer ecpg.type
6148
$(PERL)$(srcdir)/parse.pl$(srcdir)<$<>$@

‎src/pl/plpgsql/src/Makefile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,8 @@ uninstall-headers:
5555
pl_gram.opl_handler.opl_comp.opl_exec.opl_funcs.opl_scanner.o: plpgsql.h pl_gram.h plerrcodes.h
5656

5757
# See notes in src/backend/parser/Makefile about the following two rules
58-
5958
pl_gram.h: pl_gram.c ;
60-
61-
pl_gram.c: pl_gram.y
62-
ifdefBISON
63-
$(BISON) -d $(BISONFLAGS) -o $@ $<
64-
else
65-
@$(missing) bison $< $@
66-
endif
59+
pl_gram.c: BISONFLAGS += -d
6760

6861
# generate plerrcodes.h from src/backend/utils/errcodes.txt
6962
plerrcodes.h:$(top_srcdir)/src/backend/utils/errcodes.txt generate-plerrcodes.pl

‎src/test/isolation/Makefile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,6 @@ specparse.h: specparse.c ;
4343
# specscanner is compiled as part of specparse
4444
specparse.o: specscanner.c
4545

46-
specparse.c: specparse.y
47-
ifdefBISON
48-
$(BISON) $(BISONFLAGS) -o $@ $<
49-
else
50-
@$(missing) bison $< $@
51-
endif
52-
53-
specscanner.c: specscanner.l
54-
ifdefFLEX
55-
$(FLEX) $(FLEXFLAGS) -o'$@' $<
56-
else
57-
@$(missing) flex $< $@
58-
endif
59-
6046
# specparse.c and specscanner.c are in the distribution tarball,
6147
# so do not clean them here
6248
cleandistclean:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp