bison++ do not support absolute paths yet..
Index: ChangeLog
from BenoƮt Perrot <benoit(a)lrde.epita.fr>
Participate to "builddir != srcdir" compilation.
* dev/inst-builder-gen.py,
* dev/inst-nodes-gen.py,
* dev/inst-solver-gen.py,
* dev/doc-inst-set-gen.py,
* dev/parse-asm-scan-gen.py,
* dev/parse-asm-parse-gen.py:
Ask for a directory where the files have to be generated.
* src/parse/Makefile.am,
* src/inst/Makefile.am,
* doc/Makefile.am:
Specify the directory where to generate.
Index: src/parse/Makefile.am
--- src/parse/Makefile.am (revision 136)
+++ src/parse/Makefile.am (revision 137)
@@ -5,8 +5,8 @@
# [asm-parse.cc] from occuring twice in libparse_a_SOURCES to avoid
# double inclusion of [asm-parse.o]."
FROM_ASM_PARSE_YY = \
- stack.hh position.hh location.hh \
- asm-parse.hh
+ $(srcdir)/stack.hh $(srcdir)/position.hh $(srcdir)/location.hh \
+ $(srcdir)/asm-parse.hh
BUILT_SOURCES = \
asm-scan.ll parse-asm-scan.stamp \
@@ -16,19 +16,19 @@
# This code comes from "Handling Tools that Produce Many Outputs",
# from the Automake documentation.
-parse-asm-scan.stamp: $(top_srcdir)/dev/parse-asm-scan-gen.py
$(top_srcdir)/dev/nolimips.xml
+$(srcdir)/parse-asm-scan.stamp: $(top_srcdir)/dev/parse-asm-scan-gen.py
$(top_srcdir)/dev/nolimips.xml
@rm -rf $@.tmp
@touch $@.tmp
- $(top_srcdir)/dev/parse-asm-scan-gen.py < $(top_srcdir)/dev/nolimips.xml
+ $(top_srcdir)/dev/parse-asm-scan-gen.py $(srcdir) < $(top_srcdir)/dev/nolimips.xml
@mv -f $@.tmp $@
-asm-scan.ll: parse-asm-scan.stamp
+$(srcdir)/asm-scan.ll: $(srcdir)/parse-asm-scan.stamp
-parse-asm-parse.stamp: $(top_srcdir)/dev/parse-asm-parse-gen.py
$(top_srcdir)/dev/nolimips.xml
+$(srcdir)/parse-asm-parse.stamp: $(top_srcdir)/dev/parse-asm-parse-gen.py
$(top_srcdir)/dev/nolimips.xml
@rm -rf $@.tmp
@touch $@.tmp
- $(top_srcdir)/dev/parse-asm-parse-gen.py < $(top_srcdir)/dev/nolimips.xml
+ $(top_srcdir)/dev/parse-asm-parse-gen.py $(srcdir) < $(top_srcdir)/dev/nolimips.xml
@mv -f $@.tmp $@
-asm-parse.yy: parse-asm-parse.stamp
+$(srcdir)/asm-parse.yy: $(srcdir)/parse-asm-parse.stamp
BISONXX = $(top_srcdir)/config/bison++
Index: src/inst/Makefile.am
--- src/inst/Makefile.am (revision 136)
+++ src/inst/Makefile.am (revision 137)
@@ -10,28 +10,28 @@
# This code comes from "Handling Tools that Produce Many Outputs",
# from the Automake documentation.
-nodes.mk: $(top_srcdir)/dev/inst-nodes-mk-gen.py $(top_srcdir)/dev/nolimips.xml
+$(srcdir)/nodes.mk: $(top_srcdir)/dev/inst-nodes-mk-gen.py
$(top_srcdir)/dev/nolimips.xml
$(top_srcdir)/dev/inst-nodes-mk-gen.py < $(top_srcdir)/dev/nolimips.xml >$@.tmp
mv -f $@.tmp $@
-inst-nodes-gen.stamp: $(top_srcdir)/dev/inst-nodes-gen.py $(top_srcdir)/dev/nolimips.xml
+$(srcdir)/inst-nodes-gen.stamp: $(top_srcdir)/dev/inst-nodes-gen.py
$(top_srcdir)/dev/nolimips.xml
@rm -rf $@.tmp
@touch $@.tmp
- $(top_srcdir)/dev/inst-nodes-gen.py < $(top_srcdir)/dev/nolimips.xml
+ $(top_srcdir)/dev/inst-nodes-gen.py $(srcdir) < $(top_srcdir)/dev/nolimips.xml
@mv -f $@.tmp $@
$(FROM_INST_NODES_GEN_PY): inst-nodes-gen.stamp
-inst-builder-gen.stamp: $(top_srcdir)/dev/inst-builder-gen.py
$(top_srcdir)/dev/nolimips.xml
+$(srcdir)/inst-builder-gen.stamp: $(top_srcdir)/dev/inst-builder-gen.py
$(top_srcdir)/dev/nolimips.xml
@rm -rf $@.tmp
@touch $@.tmp
- $(top_srcdir)/dev/inst-builder-gen.py < $(top_srcdir)/dev/nolimips.xml
+ $(top_srcdir)/dev/inst-builder-gen.py $(srcdir) < $(top_srcdir)/dev/nolimips.xml
@mv -f $@.tmp $@
program_builder.hh: inst-builder-gen.stamp
-inst-solver-gen.stamp: $(top_srcdir)/dev/inst-solver-gen.py
$(top_srcdir)/dev/nolimips.xml
+$(srcdir)/inst-solver-gen.stamp: $(top_srcdir)/dev/inst-solver-gen.py
$(top_srcdir)/dev/nolimips.xml
@rm -rf $@.tmp
@touch $@.tmp
- $(top_srcdir)/dev/inst-solver-gen.py < $(top_srcdir)/dev/nolimips.xml
+ $(top_srcdir)/dev/inst-solver-gen.py $(srcdir) < $(top_srcdir)/dev/nolimips.xml
@mv -f $@.tmp $@
program_solver.hh program_solver.cc: inst-solver-gen.stamp
Index: doc/Makefile.am
--- doc/Makefile.am (revision 136)
+++ doc/Makefile.am (revision 137)
@@ -9,7 +9,7 @@
$(FROM_DOC_INST_SET_GEN_PY) doc-inst-set-gen.log
doc-inst-set-gen.log: $(top_srcdir)/dev/doc-inst-set-gen.py
$(top_srcdir)/dev/nolimips.xml
- $(top_srcdir)/dev/doc-inst-set-gen.py < $(top_srcdir)/dev/nolimips.xml
+ $(top_srcdir)/dev/doc-inst-set-gen.py . < $(top_srcdir)/dev/nolimips.xml
touch $@
$(FROM_DOC_INST_SET_GEN_PY): doc-inst-set-gen.log
Index: dev/inst-builder-gen.py
--- dev/inst-builder-gen.py (revision 136)
+++ dev/inst-builder-gen.py (revision 137)
@@ -26,6 +26,11 @@
#### Nolimips' program builder generator -------------------
+if __name__ != "__main__" or len(sys.argv) != 2:
+ print "Usage: .. SRCDIR"
+ sys.exit(1)
+srcdir = sys.argv[1]
+
parser = nolimips.InstructionSetParser()
instructions = parser.parse(sys.stdin)
@@ -184,5 +189,6 @@
## Epilogue
sys.stdout.close()
sys.stdout = sys.__stdout__
-nolimips.lazy_overwrite("program_builder.hh",
"program_builder.hh.tmp")
+nolimips.lazy_overwrite(srcdir + os.sep + "program_builder.hh",
+ "program_builder.hh.tmp")
os.remove("program_builder.hh.tmp")
Index: dev/inst-nodes-gen.py
--- dev/inst-nodes-gen.py (revision 136)
+++ dev/inst-nodes-gen.py (revision 137)
@@ -25,6 +25,11 @@
#### Nolimips' instruction classes generator ---------------
+if __name__ != "__main__" or len(sys.argv) != 2:
+ print "Usage: .. SRCDIR"
+ sys.exit(1)
+srcdir = sys.argv[1]
+
## Generate the class corresponding to an instruction
def class_generate(inst):
@@ -229,7 +234,8 @@
# Check differences between old and new files
sys.stdout = sys.__stdout__
f.close()
- nolimips.lazy_overwrite(file_id + "." + ext, file_id + "." + ext
+ ".tmp")
+ nolimips.lazy_overwrite(srcdir + os.sep + file_id + "." + ext,
+ file_id + "." + ext + ".tmp")
os.remove(file_id + "." + ext + ".tmp")
## Main --------------------------------
@@ -252,7 +258,7 @@
print "#endif // !INST_ALL_HH"
sys.stdout.close()
sys.stdout = sys.__stdout__
-nolimips.lazy_overwrite("all.hh", "all.hh.tmp")
+nolimips.lazy_overwrite(srcdir + os.sep + "all.hh", "all.hh.tmp")
os.remove("all.hh.tmp")
## Generate all-declarator
@@ -274,7 +280,7 @@
"""
sys.stdout.close()
sys.stdout = sys.__stdout__
-nolimips.lazy_overwrite("decl.hh", "decl.hh.tmp")
+nolimips.lazy_overwrite(srcdir + os.sep + "decl.hh", "decl.hh.tmp")
os.remove("decl.hh.tmp")
## Generate visitor
@@ -315,5 +321,5 @@
#endif // !INST_VISITOR_HH"""
sys.stdout.close()
sys.stdout = sys.__stdout__
-nolimips.lazy_overwrite("visitor.hh", "visitor.hh.tmp")
+nolimips.lazy_overwrite(srcdir + os.sep + "visitor.hh",
"visitor.hh.tmp")
os.remove("visitor.hh.tmp")
Index: dev/inst-solver-gen.py
--- dev/inst-solver-gen.py (revision 136)
+++ dev/inst-solver-gen.py (revision 137)
@@ -26,6 +26,11 @@
#### Nolimips' program solver generator --------------------
+if __name__ != "__main__" or len(sys.argv) != 2:
+ print "Usage: .. SRCDIR"
+ sys.exit(1)
+srcdir = sys.argv[1]
+
parser = nolimips.InstructionSetParser()
instructions = parser.parse(sys.stdin)
@@ -124,7 +129,8 @@
sys.stdout.close()
sys.stdout = sys.__stdout__
-nolimips.lazy_overwrite("program_solver.hh",
"program_solver.hh.tmp")
+nolimips.lazy_overwrite(srcdir + os.sep + "program_solver.hh",
+ "program_solver.hh.tmp")
os.remove("program_solver.hh.tmp")
@@ -262,5 +268,6 @@
sys.stdout.close()
sys.stdout = sys.__stdout__
-nolimips.lazy_overwrite("program_solver.cc",
"program_solver.cc.tmp")
+nolimips.lazy_overwrite(srcdir + os.sep + "program_solver.cc",
+ "program_solver.cc.tmp")
os.remove("program_solver.cc.tmp")
Index: dev/doc-inst-set-gen.py
--- dev/doc-inst-set-gen.py (revision 136)
+++ dev/doc-inst-set-gen.py (revision 137)
@@ -25,6 +25,11 @@
#### Nolimips' instruction set texi generator --------------
+if __name__ != "__main__" or len(sys.argv) != 2:
+ print "Usage: .. SRCDIR"
+ sys.exit(1)
+srcdir = sys.argv[1]
+
parser = nolimips.InstructionSetParser()
instructions = parser.parse(sys.stdin)
@@ -62,5 +67,5 @@
## Epilogue
sys.stdout.close()
sys.stdout = sys.__stdout__
-nolimips.lazy_overwrite("inst-set.texi", "inst-set.texi.tmp")
+nolimips.lazy_overwrite(srcdir + os.sep + "inst-set.texi",
"inst-set.texi.tmp")
os.remove("inst-set.texi.tmp")
Index: dev/parse-asm-scan-gen.py
--- dev/parse-asm-scan-gen.py (revision 136)
+++ dev/parse-asm-scan-gen.py (revision 137)
@@ -26,6 +26,11 @@
#### Nolimips' Flex scanner generator --------------------------
+if __name__ != "__main__" or len(sys.argv) != 2:
+ print "Usage: .. SRCDIR"
+ sys.exit(1)
+srcdir = sys.argv[1]
+
parser = nolimips.InstructionSetParser()
instructions = parser.parse(sys.stdin)
@@ -280,5 +285,5 @@
sys.stdout.close()
sys.stdout = sys.__stdout__
-nolimips.lazy_overwrite("asm-scan.ll", "asm-scan.ll.tmp")
+nolimips.lazy_overwrite(srcdir + os.sep + "asm-scan.ll",
"asm-scan.ll.tmp")
os.remove("asm-scan.ll.tmp")
Index: dev/parse-asm-parse-gen.py
--- dev/parse-asm-parse-gen.py (revision 136)
+++ dev/parse-asm-parse-gen.py (revision 137)
@@ -26,6 +26,11 @@
#### Nolimips' Bison assembly parser generator -------------
+if __name__ != "__main__" or len(sys.argv) != 2:
+ print "Usage: .. SRCDIR"
+ sys.exit(1)
+srcdir = sys.argv[1]
+
parser = nolimips.InstructionSetParser()
instructions = parser.parse(sys.stdin)
@@ -298,5 +303,5 @@
sys.stdout.close()
sys.stdout = sys.__stdout__
-nolimips.lazy_overwrite("asm-parse.yy", "asm-parse.yy.tmp")
+nolimips.lazy_overwrite(srcdir + os.sep + "asm-parse.yy",
"asm-parse.yy.tmp")
os.remove("asm-parse.yy.tmp")