#-------------------------------------------------------------------------
#
-# Makefile--
-# Makefile for the bootstrap module
+# Makefile for the bootstrap module
#
-# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.22 2000/05/29 05:44:42 tgl Exp $
-#
-#
-# We must build bootparse.c and bootscanner.c with yacc and lex and sed,
-# but bootstrap.c is part of the distribution.
-#
-# Another kinda weird Makefile cause we need two
-# scanner/parsers in the backend and most yaccs and lexs
-# don't have the prefix option.
-#
-# sed files are HACK CITY! - redo...
+# $PostgreSQL: pgsql/src/backend/bootstrap/Makefile,v 1.34 2006/03/07 01:03:12 tgl Exp $
#
#-------------------------------------------------------------------------
-SRCDIR= ../..
-include $(SRCDIR)/Makefile.global
+subdir = src/backend/bootstrap
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
-ifeq ($(CC), gcc)
-CFLAGS+= -Wno-error
-endif
+override CPPFLAGS := -I$(srcdir) $(CPPFLAGS)
-BOOTYACCS= bootstrap_tokens.h bootparse.c
+OBJS= bootparse.o bootstrap.o
-ifneq ($(PORTNAME), qnx4)
-OBJS= bootparse.o bootscanner.o bootstrap.o
-else
-# qnx4's wlink currently crashes with bootstrap.o
-OBJS= bootparse.o bootscanner.o
-endif
-
-# make sure bootstrap.o is built even on qnx4
-all: SUBSYS.o bootstrap.o
+all: SUBSYS.o
SUBSYS.o: $(OBJS)
- $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
+ $(LD) $(LDREL) $(LDOUT) $@ $^
-# bootstrap.o's dependency on bootstrap_tokens.h is computed by the
-# make depend, but we state it here explicitly anyway because
-# bootstrap_tokens.h doesn't even exist at first and if user fails to
-# do make depend, we still want the build to succeed.
-bootstrap.o: bootstrap_tokens.h
+# bootscanner is compiled as part of bootparse
+bootparse.o: $(srcdir)/bootscanner.c
-bootstrap_tokens.h bootparse.c: bootparse.y
- $(YACC) $(YFLAGS) $<
- grep -v "^#" boot.sed > sedfile
- sed -f sedfile < y.tab.c > bootparse.c
- mv y.tab.h bootstrap_tokens.h
- rm -f y.tab.c sedfile
+# See notes in src/backend/parser/Makefile about the following two rules
-bootscanner.c: bootscanner.l
- $(LEX) $<
- grep -v "^#" boot.sed > sedfile
- sed -f sedfile < lex.yy.c > bootscanner.c
- rm -f lex.yy.c sedfile
+$(srcdir)/bootparse.c: $(srcdir)/bootstrap_tokens.h ;
+$(srcdir)/bootstrap_tokens.h: bootparse.y
+ifdef YACC
+ $(YACC) -d $(YFLAGS) $<
+ mv -f y.tab.c $(srcdir)/bootparse.c
+ mv -f y.tab.h $(srcdir)/bootstrap_tokens.h
+else
+ @$(missing) bison $< $@
+endif
+
+$(srcdir)/bootscanner.c: bootscanner.l
+ifdef FLEX
+ $(FLEX) $(FLEXFLAGS) -o'$@' $<
+else
+ @$(missing) flex $< $@
+endif
+
+# Force these dependencies to be known even without dependency info built:
+bootstrap.o bootparse.o: $(srcdir)/bootstrap_tokens.h
+
+
+# bootparse.c, bootstrap_tokens.h, and bootscanner.c are in the distribution
+# tarball, so they are not cleaned here.
clean:
- rm -f SUBSYS.o $(OBJS) bootstrap.o
+ rm -f SUBSYS.o $(OBJS)
# And the garbage that might have been left behind by partial build:
- rm -f y.tab.h y.tab.c y.output lex.yy.c
+ @rm -f y.tab.h y.tab.c y.output lex.yy.c
+
# This is unusual: We actually have to build some of the parts before
# we know what the header file dependencies are.