From 153b4495c1bdf38e84f75986563dbae336000fad Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 6 May 2005 09:42:34 -0400 Subject: [PATCH] If the .c and .h file already exist, and they have not changed, use the original versions of the files, so as to avoid rebuilding files when not necessary. Also fixes a potential SMP/Parallel build problem when one make process runs compile_et to generate the .h file, and a partially generated .c file is compiled by another make process. (Addresses Sourceforge Bug: #1157933) --- lib/et/compile_et.sh.in | 14 ++++++++++++-- lib/et/et_c.awk | 5 ++++- lib/et/et_h.awk | 5 ++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/et/compile_et.sh.in b/lib/et/compile_et.sh.in index e41b51b..27bb3cd 100644 --- a/lib/et/compile_et.sh.in +++ b/lib/et/compile_et.sh.in @@ -32,5 +32,15 @@ if test ! -f "$ROOT.et" ; then exit 1; fi -$AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h" "$ROOT.et" -$AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c" "$ROOT.et" +$AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h.$$" "outfn=${BASE}.h" "$ROOT.et" +if test -f ${BASE}.h && cmp -s ${BASE}.h.$$ ${BASE}.h ; then + rm ${BASE}.h.$$ +else + mv ${BASE}.h.$$ ${BASE}.h +fi +$AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c.$$" "outfn=${BASE}.c" "$ROOT.et" +if test -f ${BASE}.c && cmp -s ${BASE}.c.$$ ${BASE}.c ; then + rm ${BASE}.c.$$ +else + mv ${BASE}.c.$$ ${BASE}.c +fi diff --git a/lib/et/et_c.awk b/lib/et/et_c.awk index ab0079f..1769b79 100644 --- a/lib/et/et_c.awk +++ b/lib/et/et_c.awk @@ -1,4 +1,7 @@ BEGIN { +if ( length(outfn) == 0) { + outfn = outfile +} char_shift=64 ## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; c2n["A"]=1 @@ -119,7 +122,7 @@ c2n["_"]=63 } } print "/*" > outfile - print " * " outfile ":" > outfile + print " * " outfn ":" > outfile print " * This file is automatically generated; please do not edit it." > outfile print " */" > outfile diff --git a/lib/et/et_h.awk b/lib/et/et_h.awk index 73caffc..8337121 100644 --- a/lib/et/et_h.awk +++ b/lib/et/et_h.awk @@ -1,4 +1,7 @@ BEGIN { +if ( length(outfn) == 0) { + outfn = outfile +} char_shift=64 ## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; c2n["A"]=1 @@ -123,7 +126,7 @@ c2n["_"]=63 curr_high = tab_base_high curr_sign = tab_base_sign print "/*" > outfile - print " * " outfile ":" > outfile + print " * " outfn ":" > outfile print " * This file is automatically generated; please do not edit it." > outfile print " */" > outfile print "" > outfile -- 1.8.3.1