From 0493c5a5004096ab5118920dec16d6be4cf0fdc9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 26 Feb 2008 14:48:11 +0100 Subject: Move common rules code to separate directory. (This used to be commit 803ebd6479ae388ae65de8de7fb88600452d47df) --- source4/Makefile | 12 ++ source4/build/make/lex_compile.sh | 51 +++++++++ source4/build/make/rules.mk | 223 ++++++++++++++++++++++++++++++++++++ source4/build/make/yacc_compile.sh | 43 +++++++ source4/rules.mk | 228 ------------------------------------- source4/script/lex_compile.sh | 51 --------- source4/script/yacc_compile.sh | 43 ------- 7 files changed, 329 insertions(+), 322 deletions(-) create mode 100755 source4/build/make/lex_compile.sh create mode 100644 source4/build/make/rules.mk create mode 100755 source4/build/make/yacc_compile.sh delete mode 100644 source4/rules.mk delete mode 100755 source4/script/lex_compile.sh delete mode 100755 source4/script/yacc_compile.sh diff --git a/source4/Makefile b/source4/Makefile index 4bd5042f3c..3a303ae39f 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -19,6 +19,18 @@ BNLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS) HOSTCC_FLAGS = -D_SAMBA_HOSTCC_ $(CFLAGS) HOSTLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS) +$(srcdir)/version.h: $(srcdir)/VERSION + @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/ + +regen_version:: + @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/ + +clean_pch:: + @echo "Removing precompiled headers" + @-rm -f include/includes.h.gch + +pch:: clean_pch include/includes.h.gch + .DEFAULT_GOAL := all ifneq ($(automatic_deps),yes) diff --git a/source4/build/make/lex_compile.sh b/source4/build/make/lex_compile.sh new file mode 100755 index 0000000000..9bba7257b1 --- /dev/null +++ b/source4/build/make/lex_compile.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +LEX="$1" +SRC="$2" +DEST="$3" +shift 3 +ARGS="$*" + +dir=`dirname $SRC` +file=`basename $SRC` +base=`basename $SRC .l` +if [ -z "$LEX" ]; then + # if $DEST is more recent than $SRC, we can just touch + # otherwise we touch but print out warnings + if [ -r $DEST ]; then + if [ x`find $SRC -newer $DEST -print` = x$SRC ]; then + echo "warning: lex not found - cannot generate $SRC => $DEST" >&2 + echo "warning: lex not found - only updating the timestamp of $DEST" >&2 + fi + touch $DEST; + exit; + fi + echo "error: lex not found - cannot generate $SRC => $DEST" >&2 + exit 1; +fi +# if $DEST is more recent than $SRC, we can just touch +if [ -r $DEST ]; then + if [ x`find $SRC -newer $DEST -print` != x$SRC ]; then + touch $DEST; + exit; + fi +fi +TOP=`pwd` +if cd $dir && $LEX $ARGS $file; then + if [ -r $base.yy.c ];then + # we must guarantee that config.h comes first + echo "#include \"config.h\"" > $base.c + sed -e "s|$base\.yy\.c|$DEST|" $base.yy.c >> $base.c + rm -f $base.yy.c + elif [ -r $base.c ];then + # we must guarantee that config.h comes first + mv $base.c $base.c.tmp + echo "#include \"config.h\"" > $base.c + sed -e "s|$base\.yy\.c|$DEST|" $base.c.tmp >> $base.c + rm -f $base.c.tmp + elif [ ! -r base.c ]; then + echo "$base.c nor $base.yy.c generated." + exit 1 + fi +fi +cd $TOP diff --git a/source4/build/make/rules.mk b/source4/build/make/rules.mk new file mode 100644 index 0000000000..bd72946593 --- /dev/null +++ b/source4/build/make/rules.mk @@ -0,0 +1,223 @@ +# Rules file for Samba 4 +# This relies on GNU make. +# +# Dependencies command +DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \ + $(CFLAGS) $(CPPFLAGS) $< -o $@ +# Dependencies for host objects +HDEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ \ + $(HOSTCC_FLAGS) $(CPPFLAGS) $< -o $@ +# Dependencies for precompiled headers +PCHDEPENDS = $(CC) -M -MG -MT include/includes.h.gch -MT $@ \ + $(CFLAGS) $(CPPFLAGS) $< -o $@ + +# Run a static analysis checker +CHECK = $(CC_CHECKER) $(CFLAGS) $(PICFLAG) $(CPPLAGS) -c $< -o $@ + +# Run the configured compiler +COMPILE = $(CC) $(CFLAGS) $(PICFLAG) \ + $(CPPFLAGS) \ + -c $< -o $@ + +# Run the compiler for the build host +HCOMPILE = $(HOSTCC) $(HOSTCC_FLAGS) $(CPPFLAGS) -c $< -o $@ + +# Precompile headers +PCHCOMPILE = @$(CC) -Ilib/replace \ + $(CFLAGS) $(PICFLAG) $(CPPFLAGS) -c $< -o $@ + +# Partial linking +PARTLINK = @$(PROG_LD) -r + +make_utility_dir = $(srcdir)/build/make/ + +include/config.h: + @echo "include/config.h not present" + @echo "You need to rerun ./autogen.sh and ./configure" + @/bin/false + +pch:: + +clean:: clean_pch + @echo Removing objects + @-find . -name '*.o' -exec rm -f '{}' \; + @echo Removing hostcc objects + @-find . -name '*.ho' -exec rm -f '{}' \; + @echo Removing binaries + @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS) + @echo Removing libraries + @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES) + @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o + @echo Removing modules + @-rm -f bin/modules/*/*.$(SHLIBEXT) + @-rm -f bin/*_init_module.c + @echo Removing dummy targets + @-rm -f bin/.*_* + @echo Removing generated files + @-rm -f bin/*_init_module.c + @-rm -rf librpc/gen_* + @echo Removing proto headers + @-rm -f $(PROTO_HEADERS) + +distclean:: clean + -rm -f include/config.h include/config_tmp.h include/build.h + -rm -f data.mk + -rm -f config.status + -rm -f config.log config.cache + -rm -f config.pm config.mk + -rm -f $(PC_FILES) + +removebackup:: + -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~ + +realdistclean:: distclean removebackup + -rm -f include/config_tmp.h.in + -rm -f version.h + -rm -f configure + -rm -f $(MANPAGES) + +check:: test + +unused_macros: + $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort + +############################################################################### +# Templates +############################################################################### + +# Partially link +# Arguments: target object file, source object files +define partial_link_template +$(1): $(2) ; + @echo Partially linking $$@ + @mkdir -p $$(@D) + $$(PARTLINK) -o $$@ $$^ +endef + +# Link a binary +# Arguments: target file, depends, flags +define binary_link_template +$(1): $(2) ; + @echo Linking $$@ + @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) +endef + +# Link a host-machine binary +# Arguments: target file, depends, flags +define host_binary_link_template +$(1): $(2) ; + @echo Linking $$@ + @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3) +endef + +# Create a prototype header +# Arguments: header file, c files +define proto_header_template +$(1): $(2) ; + @echo "Creating $$@" + @$$(PERL) $$(srcdir)/script/mkproto.pl --srcdir=$$(srcdir) --builddir=$$(builddir) --all=$$@ $$^ +endef + +############################################################################### +# File types +############################################################################### + +.SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .$(SHLIBEXT) .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .8 .8.xml .ho .idl .hd + +.c.d: + @echo "Generating dependencies for $<" + @$(DEPENDS) + +.c.hd: + @echo "Generating host-compiler dependencies for $<" + @$(HDEPENDS) + +include/includes.d: include/includes.h + @echo "Generating dependencies for $<" + @$(PCHDEPENDS) + +.c.o: + @if test -n "$(CC_CHECKER)"; then \ + echo "Checking $< with '$(CC_CHECKER)'"; \ + $(CHECK) ; \ + fi + @echo "Compiling $<" + @-mkdir -p `dirname $@` + @$(COMPILE) && exit 0 ; \ + echo "The following command failed:" 1>&2;\ + $(COMPILE) >/dev/null 2>&1 + + +# echo "$(COMPILE)" 1>&2;\ + +.c.ho: + @echo "Compiling $< with host compiler" + @-mkdir -p `dirname $@` + @$(HCOMPILE) && exit 0;\ + echo "The following command failed:" 1>&2;\ + echo "$(HCOMPILE)" 1>&2;\ + $(HCOMPILE) >/dev/null 2>&1 + +.h.h.gch: + @echo "Precompiling $<" + @$(PCHCOMPILE) + +.y.c: + @echo "Building $< with $(YACC)" + @-$(make_utility_dir)/yacc_compile.sh "$(YACC)" "$<" "$@" + +.l.c: + @echo "Building $< with $(LEX)" + @-$(make_utility_dir)/script/lex_compile.sh "$(LEX)" "$<" "$@" + +%.a: + @echo Linking $@ + @rm -f $@ + @mkdir -p $(@D) + @$(STLD) $(STLD_FLAGS) $@ $^ + + +DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl + +.1.xml.1: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +.3.xml.3: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +.5.xml.5: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +.7.xml.7: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +.8.xml.8: + $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< + +dist:: idl_full manpages configure distclean + +configure: + ./autogen.sh + +showflags:: + @echo 'Samba will be compiled with flags:' + @echo ' CPP = $(CPP)' + @echo ' CPPFLAGS = $(CPPFLAGS)' + @echo ' CC = $(CC)' + @echo ' CFLAGS = $(CFLAGS)' + @echo ' PICFLAG = $(PICFLAG)' + @echo ' BNLD = $(BNLD)' + @echo ' BNLD_FLAGS = $(BNLD_FLAGS)' + @echo ' STLD = $(STLD)' + @echo ' STLD_FLAGS = $(STLD_FLAGS)' + @echo ' SHLD = $(SHLD)' + @echo ' SHLD_FLAGS = $(SHLD_FLAGS)' + @echo ' MDLD = $(MDLD)' + @echo ' MDLD_FLAGS = $(MDLD_FLAGS)' + @echo ' SHLIBEXT = $(SHLIBEXT)' + +etags: + etags `find $(srcdir) -name "*.[ch]"` + +ctags: + ctags `find $(srcdir) -name "*.[ch]"` diff --git a/source4/build/make/yacc_compile.sh b/source4/build/make/yacc_compile.sh new file mode 100755 index 0000000000..a56a51da0a --- /dev/null +++ b/source4/build/make/yacc_compile.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +YACC="$1" +SRC="$2" +DEST="$3" + +dir=`dirname $SRC` +file=`basename $SRC` +base=`basename $SRC .y` +if [ -z "$YACC" ]; then + # if $DEST is more recent than $SRC, we can just touch + # otherwise we touch but print out warnings + if [ -r $DEST ]; then + if [ x`find $SRC -newer $DEST -print` = x$SRC ]; then + echo "warning: yacc not found - cannot generate $SRC => $DEST" >&2 + echo "warning: yacc not found - only updating the timestamp of $DEST" >&2 + fi + touch $DEST; + exit; + fi + echo "error: yacc not found - cannot generate $SRC => $DEST" >&2 + exit 1; +fi +# if $DEST is more recent than $SRC, we can just touch +if [ -r $DEST ]; then + if [ x`find $SRC -newer $DEST -print` != x$SRC ]; then + touch $DEST; + exit; + fi +fi +TOP=`pwd` +if cd $dir && $YACC -d $file; then + if [ -r y.tab.h -a -r y.tab.c ];then + #echo "info: move files" + sed -e "/^#/!b" -e "s|y\.tab\.h|$SRC|" -e "s|\"$base.y|\"$SRC|" y.tab.h > $base.h + sed -e "s|y\.tab\.c|$SRC|" -e "s|\"$base.y|\"$SRC|" y.tab.c > $base.c + rm -f y.tab.c y.tab.h + elif [ ! -r $base.h -a ! -r $base.c]; then + echo "$base.h nor $base.c generated." + exit 1 + fi +fi +cd $TOP diff --git a/source4/rules.mk b/source4/rules.mk deleted file mode 100644 index 0d529b7314..0000000000 --- a/source4/rules.mk +++ /dev/null @@ -1,228 +0,0 @@ -# Dependencies command -DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \ - $(CFLAGS) $(CPPFLAGS) $< -o $@ -# Dependencies for host objects -HDEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ \ - $(HOSTCC_FLAGS) $(CPPFLAGS) $< -o $@ -# Dependencies for precompiled headers -PCHDEPENDS = $(CC) -M -MG -MT include/includes.h.gch -MT $@ \ - $(CFLAGS) $(CPPFLAGS) $< -o $@ - -# Run a static analysis checker -CHECK = $(CC_CHECKER) $(CFLAGS) $(PICFLAG) $(CPPLAGS) -c $< -o $@ - -# Run the configured compiler -COMPILE = $(CC) $(CFLAGS) $(PICFLAG) \ - $(CPPFLAGS) \ - -c $< -o $@ - -# Run the compiler for the build host -HCOMPILE = $(HOSTCC) $(HOSTCC_FLAGS) $(CPPFLAGS) -c $< -o $@ - -# Precompile headers -PCHCOMPILE = @$(CC) -Ilib/replace \ - $(CFLAGS) $(PICFLAG) $(CPPFLAGS) -c $< -o $@ - -# Partial linking -PARTLINK = @$(PROG_LD) -r - -include/config.h: - @echo "include/config.h not present" - @echo "You need to rerun ./autogen.sh and ./configure" - @/bin/false - -$(srcdir)/version.h: $(srcdir)/VERSION - @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/ - -regen_version:: - @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/ - -clean_pch:: - @echo "Removing precompiled headers" - @-rm -f include/includes.h.gch - -pch:: clean_pch include/includes.h.gch - -clean:: clean_pch - @echo Removing objects - @-find . -name '*.o' -exec rm -f '{}' \; - @echo Removing hostcc objects - @-find . -name '*.ho' -exec rm -f '{}' \; - @echo Removing binaries - @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS) - @echo Removing libraries - @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES) - @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o - @echo Removing modules - @-rm -f bin/modules/*/*.$(SHLIBEXT) - @-rm -f bin/*_init_module.c - @echo Removing dummy targets - @-rm -f bin/.*_* - @echo Removing generated files - @-rm -f bin/*_init_module.c - @-rm -rf librpc/gen_* - @echo Removing proto headers - @-rm -f $(PROTO_HEADERS) - -distclean:: clean - -rm -f include/config.h include/config_tmp.h include/build.h - -rm -f data.mk - -rm -f config.status - -rm -f config.log config.cache - -rm -f config.pm config.mk - -rm -f $(PC_FILES) - -removebackup:: - -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~ - -realdistclean:: distclean removebackup - -rm -f include/config_tmp.h.in - -rm -f version.h - -rm -f configure - -rm -f $(MANPAGES) - -check:: test - -unused_macros: - $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort - -############################################################################### -# Templates -############################################################################### - -# Partially link -# Arguments: target object file, source object files -define partial_link_template -$(1): $(2) ; - @echo Partially linking $$@ - @mkdir -p $$(@D) - $$(PARTLINK) -o $$@ $$^ -endef - -# Link a binary -# Arguments: target file, depends, flags -define binary_link_template -$(1): $(2) ; - @echo Linking $$@ - @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) -endef - -# Link a host-machine binary -# Arguments: target file, depends, flags -define host_binary_link_template -$(1): $(2) ; - @echo Linking $$@ - @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3) -endef - -# Create a prototype header -# Arguments: header file, c files -define proto_header_template -$(1): $(2) ; - @echo "Creating $$@" - @$$(PERL) $$(srcdir)/script/mkproto.pl --srcdir=$$(srcdir) --builddir=$$(builddir) --all=$$@ $$^ -endef - -############################################################################### -# File types -############################################################################### - -.SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .$(SHLIBEXT) .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .8 .8.xml .ho .idl .hd - -.c.d: - @echo "Generating dependencies for $<" - @$(DEPENDS) - -.c.hd: - @echo "Generating host-compiler dependencies for $<" - @$(HDEPENDS) - -include/includes.d: include/includes.h - @echo "Generating dependencies for $<" - @$(PCHDEPENDS) - -.c.o: - @if test -n "$(CC_CHECKER)"; then \ - echo "Checking $< with '$(CC_CHECKER)'"; \ - $(CHECK) ; \ - fi - @echo "Compiling $<" - @-mkdir -p `dirname $@` - @$(COMPILE) && exit 0 ; \ - echo "The following command failed:" 1>&2;\ - $(COMPILE) >/dev/null 2>&1 - - -# echo "$(COMPILE)" 1>&2;\ - -.c.ho: - @echo "Compiling $< with host compiler" - @-mkdir -p `dirname $@` - @$(HCOMPILE) && exit 0;\ - echo "The following command failed:" 1>&2;\ - echo "$(HCOMPILE)" 1>&2;\ - $(HCOMPILE) >/dev/null 2>&1 - -.h.h.gch: - @echo "Precompiling $<" - @$(PCHCOMPILE) - -.y.c: - @echo "Building $< with $(YACC)" - @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@" - -.l.c: - @echo "Building $< with $(LEX)" - @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@" - -%.a: - @echo Linking $@ - @rm -f $@ - @mkdir -p $(@D) - @$(STLD) $(STLD_FLAGS) $@ $^ - - -DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl - -.1.xml.1: - $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< - -.3.xml.3: - $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< - -.5.xml.5: - $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< - -.7.xml.7: - $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< - -.8.xml.8: - $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $< - -dist:: idl_full manpages configure distclean - -configure: - ./autogen.sh - -showflags:: - @echo 'Samba will be compiled with flags:' - @echo ' CPP = $(CPP)' - @echo ' CPPFLAGS = $(CPPFLAGS)' - @echo ' CC = $(CC)' - @echo ' CFLAGS = $(CFLAGS)' - @echo ' PICFLAG = $(PICFLAG)' - @echo ' BNLD = $(BNLD)' - @echo ' BNLD_FLAGS = $(BNLD_FLAGS)' - @echo ' STLD = $(STLD)' - @echo ' STLD_FLAGS = $(STLD_FLAGS)' - @echo ' SHLD = $(SHLD)' - @echo ' SHLD_FLAGS = $(SHLD_FLAGS)' - @echo ' MDLD = $(MDLD)' - @echo ' MDLD_FLAGS = $(MDLD_FLAGS)' - @echo ' SHLIBEXT = $(SHLIBEXT)' - -etags: - etags `find $(srcdir) -name "*.[ch]"` - -ctags: - ctags `find $(srcdir) -name "*.[ch]"` diff --git a/source4/script/lex_compile.sh b/source4/script/lex_compile.sh deleted file mode 100755 index 9bba7257b1..0000000000 --- a/source4/script/lex_compile.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh - -LEX="$1" -SRC="$2" -DEST="$3" -shift 3 -ARGS="$*" - -dir=`dirname $SRC` -file=`basename $SRC` -base=`basename $SRC .l` -if [ -z "$LEX" ]; then - # if $DEST is more recent than $SRC, we can just touch - # otherwise we touch but print out warnings - if [ -r $DEST ]; then - if [ x`find $SRC -newer $DEST -print` = x$SRC ]; then - echo "warning: lex not found - cannot generate $SRC => $DEST" >&2 - echo "warning: lex not found - only updating the timestamp of $DEST" >&2 - fi - touch $DEST; - exit; - fi - echo "error: lex not found - cannot generate $SRC => $DEST" >&2 - exit 1; -fi -# if $DEST is more recent than $SRC, we can just touch -if [ -r $DEST ]; then - if [ x`find $SRC -newer $DEST -print` != x$SRC ]; then - touch $DEST; - exit; - fi -fi -TOP=`pwd` -if cd $dir && $LEX $ARGS $file; then - if [ -r $base.yy.c ];then - # we must guarantee that config.h comes first - echo "#include \"config.h\"" > $base.c - sed -e "s|$base\.yy\.c|$DEST|" $base.yy.c >> $base.c - rm -f $base.yy.c - elif [ -r $base.c ];then - # we must guarantee that config.h comes first - mv $base.c $base.c.tmp - echo "#include \"config.h\"" > $base.c - sed -e "s|$base\.yy\.c|$DEST|" $base.c.tmp >> $base.c - rm -f $base.c.tmp - elif [ ! -r base.c ]; then - echo "$base.c nor $base.yy.c generated." - exit 1 - fi -fi -cd $TOP diff --git a/source4/script/yacc_compile.sh b/source4/script/yacc_compile.sh deleted file mode 100755 index a56a51da0a..0000000000 --- a/source4/script/yacc_compile.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -YACC="$1" -SRC="$2" -DEST="$3" - -dir=`dirname $SRC` -file=`basename $SRC` -base=`basename $SRC .y` -if [ -z "$YACC" ]; then - # if $DEST is more recent than $SRC, we can just touch - # otherwise we touch but print out warnings - if [ -r $DEST ]; then - if [ x`find $SRC -newer $DEST -print` = x$SRC ]; then - echo "warning: yacc not found - cannot generate $SRC => $DEST" >&2 - echo "warning: yacc not found - only updating the timestamp of $DEST" >&2 - fi - touch $DEST; - exit; - fi - echo "error: yacc not found - cannot generate $SRC => $DEST" >&2 - exit 1; -fi -# if $DEST is more recent than $SRC, we can just touch -if [ -r $DEST ]; then - if [ x`find $SRC -newer $DEST -print` != x$SRC ]; then - touch $DEST; - exit; - fi -fi -TOP=`pwd` -if cd $dir && $YACC -d $file; then - if [ -r y.tab.h -a -r y.tab.c ];then - #echo "info: move files" - sed -e "/^#/!b" -e "s|y\.tab\.h|$SRC|" -e "s|\"$base.y|\"$SRC|" y.tab.h > $base.h - sed -e "s|y\.tab\.c|$SRC|" -e "s|\"$base.y|\"$SRC|" y.tab.c > $base.c - rm -f y.tab.c y.tab.h - elif [ ! -r $base.h -a ! -r $base.c]; then - echo "$base.h nor $base.c generated." - exit 1 - fi -fi -cd $TOP -- cgit