Changeset: 00170285ca64 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=00170285ca64
Modified Files:
        buildtools/autogen/autogen/am.py
        buildtools/autogen/autogen/msc.py
        buildtools/conf/rules.mk
        pathfinder/configure.ag
        sql/src/server/Makefile.ag
Branch: Oct2010
Log Message:

Cleaned up cleaning up.
`make clean' should clean up to a state that everything that you would
normally want rebuilt using `make' gets removed, and in such a way
that there is no need to run configure again.
`make distclean' should clean up everything that is not part of the
sources, so that you do have to run configure again.
This is complicated by the fact that we need to distinguish between
sources from Mercurial or sources from a tar ball distribution.
In a Makefile.am file you can set variables MOSTLYCLEANFILES to add
files to the `make clean' scenario that automake doesn't know about.
Before, all files in BUILT_SOURCES were added.  BUILT_SOURCES
basically contains generated source files.  But in the tar ball
scenario, many of those generated source files were part of the tar
ball and hence should not be removed by `make clean'.
So now we add files explicitly:  In am.py there is a variable
am['CLEAN'] that contains the files that have to always be removed
using `make clean' (i.e. files that are not part of the tar ball), and
a variable am['MXCLEAN'] that contains files that should be removed
only when building from Mercurial sources (i.e. generated source
files).

Most of the rest of the changes is just fine-tuning what gets removed
and making sure that configure itself doesn't leave behind junk.

Hopefully this fixes bug 2680.  Unfortunately, I did not receive
confirmation that my analysis of the bug was correct, so I can't be
sure.


diffs (truncated from 463 to 300 lines):

diff -r 36aea7ea5952 -r 00170285ca64 buildtools/autogen/autogen/am.py
--- a/buildtools/autogen/autogen/am.py  Sat Nov 20 20:45:20 2010 +0100
+++ b/buildtools/autogen/autogen/am.py  Wed Nov 24 10:19:40 2010 +0100
@@ -20,8 +20,16 @@
 from codegen import find_org
 
 #automake_ext = ['c', 'h', 'y', 'l', 'glue.c']
-automake_ext = ['o', 'lo', 'c', 'h', 'tab.c', 'tab.h', 'yy.c', 'glue.c', 
'proto.h', 'php.c', 'py.c', 'pm.c', 'ruby.c', 'def', '']
-buildtools_ext = ['mx', 'm', 'y', 'l', 'brg', 't']
+automake_ext = ['', 'c', 'def', 'glue.c', 'h', 'lo', 'o', 'php.c', 'pm.c',
+                'proto.h', 'py.c', 'ruby.c', 'tab.c', 'tab.h', 'yy.c']
+
+# buildtools_ext contains the extensions of files from which sources
+# are generated by rules that are specified in rules.mk in
+# buildtools/conf.  The generated sources should therefore be included
+# in the tar ball and not be removed with `make distclean' when
+# running "in" said tar ball.
+buildtools_ext = ['brg', 'l', 'm', 'mx', 'php.i', 'pm.i', 'py.i',
+                  'ruby.i', 'syms', 't', 'tcl.i', 'y']
 
 am_assign = "+="
 
@@ -139,8 +147,12 @@
 
 def am_list2string(l, pre, post):
     res = ""
-    for i in l:
+    prev = None
+    for i in sorted(l):
+        if i == prev:
+            continue
         res = res + pre + i + post
+        prev = i
     return res
 
 def am_find_srcs(target, deps, am, cond):
@@ -149,8 +161,10 @@
     f = target
     pf = f
     while ext != "h" and deps.has_key(f):
+        b, ext = split_filename(deps[f][0])
+        if ext in buildtools_ext and f not in am['EXTRA_DIST']:
+            am['EXTRA_DIST'].append(f)
         f = deps[f][0]
-        b, ext = split_filename(f)
         if ext in automake_ext:
             pf = f
 
@@ -162,6 +176,10 @@
             if pfext in automake_ext:
                 dist = None
                 am['BUILT_SOURCES'].append(pf)
+                if sfext in buildtools_ext:
+                    am['MXCLEAN'].append(pf)
+                else:
+                    am['CLEAN'].append(pf)
     b, ext = split_filename(pf)
     if ext in automake_ext:
         return (dist,pf)
@@ -275,12 +293,15 @@
     return 0
 
 def am_dep(fd, t, deplist, am, pref = ''):
+    rv = []
     t = t.replace('\\', '/')
     n = t.replace('.o', '.lo', 1)
     f,ext = rsplit_filename(n)
     if t != n and not pref:
         fd.write(t + " ")
+        rv.append(t)
     fd.write(pref + n + ":")
+    rv.append(pref + n)
     for d in deplist:
         if not os.path.isabs(d):
             fd.write(" " + am_translate_dir(d, am))
@@ -290,13 +311,15 @@
     if ext == 'mil': # a bit of a hack ....
         am['MILHACK'][n] = " $(%s_LTLIBRARIES)" % os.path.basename(f)
     fd.write("\n")
+    return rv
 
 def am_deps(fd, deps, am):
     if not am['DEPS']:
         fd.write("if NEED_MX\n")
         for t, deplist in deps.items():
             if needbuildtool(deplist):
-                am_dep(fd, t, deplist, am)
+                rv = am_dep(fd, t, deplist, am)
+                am['MXCLEAN'].extend(rv)
         fd.write("endif\n")
         for t, deplist in deps.items():
             if not needbuildtool(deplist):
@@ -358,6 +381,7 @@
                 fd.write("endif\n")
             if not os.path.exists(os.path.join(am['CWDRAW'], script)):
                 am['BUILT_SOURCES'].append("$(C_" +mkname+ ")")
+                am['CLEAN'].append("$(C_" +mkname+ ")")
             am['EXTRA_DIST'].append(script)
         elif os.path.exists(os.path.join(am['CWDRAW'], script)):
             am['EXTRA_DIST'].append(script)
@@ -442,6 +466,9 @@
         am['UNINSTALL'].append(h)
         if header not in headers['SOURCES']:
             am['BUILT_SOURCES'].append(h)
+            am['MXCLEAN'].append(h)
+            if h[-4:] == '.mil':
+                am['MXCLEAN'].append(h[:-3] + 'tmpmil')
         am['InstallList'].append("\t"+sd+"/"+header+cond+"\n")
 
     am_find_ins(am, headers)
@@ -527,6 +554,7 @@
             fd.write("all-local-%s: %s\n" % (name, src))
             fd.write("\t-$(RM) %s\n" % name)
             fd.write("\t$(LN_S) %s %s\n\n" % (src, name))
+            am['CLEAN'].append(name)
             if cond:
                 fd.write('else\n')
                 fd.write("install-exec-local-%s:\n" % name)
@@ -941,14 +969,19 @@
         am['INSTALL'].append(sf)
         am['UNINSTALL'].append(sf)
         fd.write('%s: %s\n' % (f[:-4], f))
-        fd.write('\td=$(dir $<); [ "$$d" -ef . ] || (cd "$$d"; tar cf - %s 
`sed -n \'/.*\.files *= *\[ */{s///;s/ *\].*//;s/"//g;s/ *, */ /g;p;}\' "%s"`) 
| tar xf -\n' % (f, f))
+        fd.write('\td=$(dir $<); [ "$$d" -ef . ] || (cd "$$d"; tar cf - %s 
`sed -n \'/.*\.files *= *\[ */{s///;s/ *\].*//;s/"//g;s/ *, */ /g;p;}\' "%s"`) 
| tar xvf - > files-to-be-cleaned\n' % (f, f))
         fd.write('\tgem build %s\n' % f)
+        fd.write('mostlyclean-local: mostlyclean-local-%s\n' % sf)
+        fd.write('.PHONY: mostlyclean-local-%s\n' % sf)
+        fd.write('mostlyclean-local-%s:\n' % sf)
+        fd.write('\t[ ! -f files-to-be-cleaned ] || rm -f `cat 
files-to-be-cleaned` files-to-be-cleaned\n')
         fd.write('install-exec-local-%s: %s\n' % (sf, f[:-4]))
         fd.write('\tmkdir -p $(DESTDIR)%s\n' % rd)
         fd.write('\tgem install --local --install-dir $(DESTDIR)%s --force 
--rdoc %s\n' % (rd, f[:-4]))
         fd.write('uninstall-exec-local-%s: %s\n' % (sf, f[:-4]))
         fd.write('\tgem uninstall --install-dir $(DESTDIR)%s %s\n' % (rd, 
f[:-4]))
         am['BUILT_SOURCES'].append(f[:-4])
+        am['CLEAN'].append(f[:-4])
     fd.write('else\n')
     for f in gem['FILES']:
         sf = f.replace('.', '_')
@@ -1129,6 +1162,8 @@
         am['CWD'] = cwd[len(topdir)+1:].replace('\\', '/')+'/'
     am['CWDRAW'] = cwd
     am['BUILT_SOURCES'] = []
+    am['MXCLEAN'] = []                  # files created when NEED_MX is set
+    am['CLEAN'] = []                    # files to be cleaned with make clean
     am['EXTRA_DIST'] = []
     am['LIBS'] = []     # all libraries (am_libs and am_library)
     am['NLIBS'] = []     # all libraries which are not installed
@@ -1164,11 +1199,13 @@
         elif i != 'TARGETS':
             am_assignment(fd, i, v, am)
 
+    if am['MXCLEAN']:
+        fd.write('if NEED_MX\nMXCLEAN =%s\nelse\nMXCLEAN =\nendif\n' % 
am_list2string(am['MXCLEAN'], ' ', ''))
     fd.write("BUILT_SOURCES =%s\n" % am_list2string(am['BUILT_SOURCES'], " ", 
""))
     # the BUILT_SOURCES should be cleaned up by make (mostly)clean
-    fd.write("MOSTLYCLEANFILES =%s\n" % am_list2string(am['BUILT_SOURCES'], " 
", ""))
+    fd.write("MOSTLYCLEANFILES =%s $(MXCLEAN)\n" % am_list2string(am['CLEAN'], 
' ', ''))
 
-    fd.write("EXTRA_DIST = Makefile.msc%s " % \
+    fd.write("EXTRA_DIST = Makefile.msc%s" % \
           am_list2string(am['EXTRA_DIST'], " ", ""))
     fd.write(" $(BUILT_SOURCES)\n")
 
@@ -1240,12 +1277,22 @@
         fd.write("nodist_%sinclude_HEADERS = %s %s\n" % (name, 
am_list2string(am['HDRS'], " ", ""), incs))
 
     fd.write('''
+# When building from a tar ball (HAVE_BUILDTOOLS is false), don\'t
+# include rules.mk, and don\'t remove bison-generated files.  By
+# default, bison-generated files are removed by automake, and we
+# will do the same if building from Mercurial sources.
 if HAVE_BUILDTOOLS
   include $(BUILDTOOLS_CONFDIR)/rules.mk
+  REMOVE_BISON_FILES = -rm -f *.tab.c
+else
+  REMOVE_BISON_FILES = @:
 endif
 if HAVE_EXTRA_MK
   include $(top_builddir)/extra.mk
 endif
+
+distclean-compile:
+\t$(REMOVE_BISON_FILES)
 ''')
     if cwd == topdir:
         fd.write('include $(top_builddir)/rpm.mk\n')
diff -r 36aea7ea5952 -r 00170285ca64 buildtools/autogen/autogen/msc.py
--- a/buildtools/autogen/autogen/msc.py Sat Nov 20 20:45:20 2010 +0100
+++ b/buildtools/autogen/autogen/msc.py Wed Nov 24 10:19:40 2010 +0100
@@ -402,10 +402,12 @@
                          (split_filename(msc_basename(src))[0], name, name, t, 
src))
     if ext == 'py' and deplist[0].endswith('.py.i'):
         fd.write('\t$(SWIG) -python $(SWIGFLAGS) -outdir . -o dummy.c "%s"\n' 
% src)
+        fd.write('\t$(DEL) dummy.c\n')
     if ext == 'py.c' and deplist[0].endswith('.py.i'):
         fd.write('\t$(SWIG) -python $(SWIGFLAGS) -outdir . -o "$@" "%s"\n' % 
src)
     if ext == 'pm' and deplist[0].endswith('.pm.i'):
         fd.write('\t$(SWIG) -perl $(SWIGFLAGS) -outdir . -o dummy.c "%s"\n' % 
src)
+        fd.write('\t$(DEL) dummy.c\n')
     if ext == 'pm.c' and deplist[0].endswith('.pm.i'):
         fd.write('\t$(SWIG) -perl $(SWIGFLAGS) -outdir . -o "$@" "%s"\n' % src)
     if ext == 'res':
diff -r 36aea7ea5952 -r 00170285ca64 buildtools/conf/rules.mk
--- a/buildtools/conf/rules.mk  Sat Nov 20 20:45:20 2010 +0100
+++ b/buildtools/conf/rules.mk  Wed Nov 24 10:19:40 2010 +0100
@@ -21,6 +21,73 @@
 MV=mv
 HIDE=1
 
+# in the next few rules, make sure that "$(CONFIG_H)" is included
+# first, also with [f]lex- and bison-generated files.  This is crucial
+# to prevent inconsistent (re-)definitions of macros.
+%.yy.c: %.l
+       $(LEX) $(LFLAGS) $<
+       if [ -f lex.$*.c ]; then $(MV) lex.$*.c $*.yy.c ; fi
+       if [ -f lex.yy.c ]; then $(MV) lex.yy.c $*.yy.c ; fi
+       if [ -f lex.$(PARSERNAME).c ]; then $(MV) lex.$(PARSERNAME).c $*.yy.c ; 
fi
+       $(MV) $*.yy.c $*.yy.c.tmp
+       echo '#include <'"$(CONFIG_H)"'>' > $*.yy.c
+       grep -v '^#include.*[<"]'"$(CONFIG_H)"'[">]' $*.yy.c.tmp >> $*.yy.c
+       $(RM) $*.yy.c.tmp
+
+%.yy.cc: %.ll
+       $(LEX) $(LFLAGS) $<
+       if [ -f lex.$*.cc ]; then $(MV) lex.$*.cc $*.yy.c ; fi
+       if [ -f lex.yy.c ]; then $(MV) lex.yy.c $*.yy.cc ; fi
+       $(MV) $*.yy.cc $*.yy.cc.tmp
+       echo '#include <'"$(CONFIG_H)"'>' > $*.yy.cc
+       grep -v '^#include.*[<"]'"$(CONFIG_H)"'[">]' $*.yy.cc.tmp >> $*.yy.cc
+       $(RM) $*.yy.cc.tmp
+
+%.tab.c: %.y
+       $(LOCKFILE) waiting
+       $(YACC) $(YFLAGS) $< || { $(RM) waiting ; exit 1 ; }
+       if [ -f y.tab.c ]; then $(MV) y.tab.c $*.tab.c ; fi
+       $(MV) $*.tab.c $*.tab.c.tmp
+       echo '#include <'"$(CONFIG_H)"'>' > $*.tab.c
+       grep -v '^#include.*[<"]'"$(CONFIG_H)"'[">]' $*.tab.c.tmp >> $*.tab.c
+       $(RM) $*.tab.c.tmp
+       [ ! -f y.tab.h ] || $(RM) y.tab.h
+       $(RM) waiting
+
+%.tab.cc: %.yy
+       $(LOCKFILE) waiting
+       $(YACC) $(YFLAGS) $< || { $(RM) waiting ; exit 1 ; }
+       if [ -f y.tab.c ]; then $(MV) y.tab.c $*.tab.cc ; fi
+       $(MV) $*.tab.cc $*.tab.cc.tmp
+       echo '#include <'"$(CONFIG_H)"'>' > $*.tab.cc
+       grep -v '^#include.*[<"]'"$(CONFIG_H)"'[">]' $*.tab.cc.tmp >> $*.tab.cc
+       $(RM) $*.tab.cc.tmp
+       [ ! -f y.tab.h ] || $(RM) y.tab.h
+       $(RM) waiting
+
+%.tab.h: %.yy
+       $(LOCKFILE) waiting
+       $(YACC) $(YFLAGS) $< || { $(RM) waiting ; exit 1 ; } 
+       if [ -f y.tab.h ]; then $(MV) y.tab.h $*.tab.h ; fi
+       [ ! -f y.tab.c ] || $(RM) y.tab.c
+       [ ! -f y.tab.cc ] || $(RM) y.tab.cc
+       $(RM) waiting
+
+%.tab.h: %.y
+       $(LOCKFILE) waiting
+       $(YACC) $(YFLAGS) $< || { $(RM) waiting ; exit 1 ; }
+       if [ -f y.tab.h ]; then $(MV) y.tab.h $*.tab.h ; fi
+       [ ! -f y.tab.c ] || $(RM) y.tab.c
+       $(RM) waiting
+
+%.def: %.syms
+       case `(uname -s) 2> /dev/null || echo unknown` in CYGWIN*) cat $<;; *) 
grep -v DllMain $<;; esac > $@
+
+ifdef NEED_MX
+# NEED_MX stands for having some not-so-generally-available tools at
+# your disposal: Mx, mel, swig; the first two are built when compiling
+# buildtools
+
 %.h: %.mx
        $(MX) $(MXFLAGS) -l -x h $<
 
@@ -33,79 +100,15 @@
 %.l: %.mx
        $(MX) $(MXFLAGS) -x l $< 
 
-%.yy.c: %.l
-       $(LEX) $(LFLAGS) $<
-       if [ -f lex.$*.c ]; then $(MV) lex.$*.c $*.yy.c ; fi
-       if [ -f lex.yy.c ]; then $(MV) lex.yy.c $*.yy.c ; fi
-       if [ -f lex.$(PARSERNAME).c ]; then $(MV) lex.$(PARSERNAME).c $*.yy.c ; 
fi
-       # make sure that "$(CONFIG_H)" is included first, also with 
[f]lex-generated files.
-       # This is crucial to prevent inconsistent (re-)definitions of macros.
-       $(MV) $*.yy.c $*.yy.c.tmp
-       echo '#include <'"$(CONFIG_H)"'>' > $*.yy.c
-       grep -v '^#include.*[<"]'"$(CONFIG_H)"'[">]' $*.yy.c.tmp >> $*.yy.c
-       $(RM) $*.yy.c.tmp
-
 %.cc: %.mx
        $(MX) $(MXFLAGS) -x C $<
 
 %.yy: %.mx
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to