From 7cee4e46fc4f50ef3e2862cd3b6cdcc1c350d286 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 8 Oct 2007 17:02:03 +0000 Subject: [PATCH] Changed tock to use autoconf/automake for its build process The old Makefile has been removed, and configure.ac and Makefile.am added in its place, along with the four files (AUTHORS, ChangeLog, NEWS and README) that autoconf requires you to have (all currently blank). tock and tocktest can now be compiled, but the rules for cgtests and compiling the C and C++ files are currently missing. --- AUTHORS | 0 ChangeLog | 0 Makefile | 105 --------------------------------------------------- Makefile.am | 59 +++++++++++++++++++++++++++++ NEWS | 0 README | 0 configure.ac | 82 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 141 insertions(+), 105 deletions(-) create mode 100644 AUTHORS create mode 100644 ChangeLog delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 README create mode 100644 configure.ac diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/Makefile b/Makefile deleted file mode 100644 index 7e771d8..0000000 --- a/Makefile +++ /dev/null @@ -1,105 +0,0 @@ -targets = tock tocktest - -all: $(targets) - -sources = $(wildcard *.hs frontends/*.hs backends/*.hs transformations/*.hs common/*.hs) $(patsubst %.x,%.hs,$(wildcard frontends/*.x)) - -builtfiles = $(patsubst %.x,%.hs,$(wildcard frontends/*.x)) - -%.hs: %.x - alex $< - -# profile_opts = -prof -auto-all -ghc_opts = \ - -fglasgow-exts \ - -fallow-undecidable-instances \ - -fwarn-unused-binds \ - -fwarn-unused-imports \ - -fwarn-type-defaults \ - -icommon -itransformations -ifrontends -ibackends \ - $(profile_opts) - -tock: $(sources) - mkdir -p obj - ghc $(ghc_opts) -o tock --make Main -odir obj -hidir obj - -tocktest: $(sources) - mkdir -p obj - ghc $(ghc_opts) -o tocktest -main-is TestMain --make TestMain -odir obj -hidir obj - -CFLAGS = \ - -O2 \ - -g -Wall \ - -std=gnu99 -fgnu89-inline \ - `kroc --cflags` `kroc --ccincpath` - -CXXFLAGS = -I. -O2 -ggdb3 -Wall - -%x.tock.cpp: %.rain tock - ./tock -v --backend=cppcsp --frontend=rain -o $@ $< - indent -nut -bli0 -pcs $@ - -%x: %x.tock.o tock - g++ $@.tock.o -pthread -lcppcsp2 -o $@ - -%.tock.c: %.occ tock - ./tock -v -o $@ $< - indent -kr -pcs $@ - -%.tock.post.c: %.tock.c tock - $(CC) $(CFLAGS) -S -o $(patsubst %.c,%.s,$<) $< - ./tock -vv --mode=post-c -o $@ $(patsubst %.c,%.s,$<) - -%: %.tock.o %.tock.post.o tock_support.h kroc-wrapper-c.o kroc-wrapper.occ - kroc -o $@ kroc-wrapper.occ $< $(patsubst %.o,%.post.o,$<) kroc-wrapper-c.o -lcif - -cgtests = $(wildcard cgtests/cgtest??.occ) -cgtests_targets = $(patsubst %.occ,%,$(cgtests)) - -get-cgtests: - svn co https://subversion.frmb.org/pubsvn/cgtests/branches/tock cgtests - -all-cgtests: $(cgtests_targets) - -clean-cgtests: - rm -f cgtests/cgtest?? cgtests/*.tock.* - -#Haddock does allow you to customise the description section of a file, but only with more Haskell comments -#Since I want to use an HTML description (with links to SVG using object tags) I have to perform the following hack -#to use my own custom HTML description. Fixes to make the hack nicer are welcome :-) - -haddock: - @mkdir -p doc - @echo "putmycustomdocumentationhere" > .temp-haddock-file - haddock -o doc --html -p .temp-haddock-file -t Tock $(filter-out frontends/LexOccam.hs frontends/LexRain.hs,$(sources)) - cp docextra/*.svg doc/ - @rm .temp-haddock-file - @grep -B 10000 putmycustomdocumentationhere doc/index.html | sed "s/putmycustomdocumentationhere//" > doc/index.html-2 - @cat docextra/description.html >> doc/index.html-2 - @grep -A 10000 putmycustomdocumentationhere doc/index.html | tail -n +2 >> doc/index.html-2 - @rm doc/index.html - @mv doc/index.html-2 doc/index.html - -clean: - rm -f $(targets) $(builtfiles) obj/*.o obj/*.hi - -#This generates the ASTXML module, which is not currently used anywhere in Tock. -#It requires the HaXml modules (1.13.x or earlier), and the DrIFT preprocessor, urls: -# http://www.cs.york.ac.uk/fp/HaXml/ -# http://repetae.net/~john/computer/haskell/DrIFT/ -#I had to exclude a few other definitions from the imports because AST has entries like True, -#and we cannot get DrIFT to import AST qualified. The alternative would be to append the -#instances from DrIFT to AST.hs itself, but I didn't want to do that just yet: - -common/ASTXML.hs: common/AST.hs common/Metadata.hs - echo -e "module ASTXML where\n" > common/ASTXML.hs - echo -e "import AST\n" >> common/ASTXML.hs - echo -e "import Metadata\n" >> common/ASTXML.hs - echo -e "import Text.XML.HaXml.Haskell2Xml hiding (Seq, TagName, Name, Plus, Choice)\n" >> common/ASTXML.hs - echo -e "import Prelude hiding (True,False)\n" >> common/ASTXML.hs - cd common && DrIFT -r AST.hs >> ASTXML.hs - cd common && DrIFT -r Metadata.hs >> ASTXML.hs - - -# Don't delete intermediate files. -.SECONDARY: diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..3bd2712 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,59 @@ + +AM_CFLAGS = @gnu89_inline@ -O2 -g -Wall `kroc --cflags` `kroc --ccincpath` + +AM_CXXFLAGS = -O2 -g -Wall -ggdb3 -I. + +GHC_OPTS = \ + -fglasgow-exts \ + -fallow-undecidable-instances \ + -fwarn-unused-binds \ + -fwarn-unused-imports \ + -fwarn-type-defaults \ + -icommon -itransformations -ifrontends -ibackends + +tock: + @MKDIR_P@ obj + ghc $(GHC_OPTS) -o tock --make Main -odir obj -hidir obj + +#The order of the -main-is and --make flags is important here: +tocktest: + @MKDIR_P@ obj + ghc $(GHC_OPTS) -o tocktest -main-is TestMain --make TestMain -odir obj -hidir obj + +frontends/LexOccam.hs: frontends/LexOccam.x + alex frontends/LexOccam.x + +frontends/LexRain.hs: frontends/LexRain.x + alex frontends/LexRain.x + +BUILT_SOURCES = frontends/LexOccam.hs frontends/LexRain.hs +CLEANFILES = $(BUILT_SOURCES) + +tock_SOURCES = transformations/SimplifyExprs.hs transformations/SimplifyTypes.hs +tock_SOURCES += transformations/Unnest.hs transformations/UsageCheck.hs transformations/SimplifyProcs.hs +tock_SOURCES += frontends/PreprocessOccam.hs frontends/ParseRain.hs frontends/StructureOccam.hs +tock_SOURCES += frontends/ParseOccam.hs frontends/RainTypes.hs frontends/RainPasses.hs frontends/ParseUtils.hs +tock_SOURCES += frontends/LexOccam.x frontends/LexRain.x +tock_SOURCES += common/Pass.hs common/TreeUtil.hs common/Intrinsics.hs common/EvalLiterals.hs +tock_SOURCES += common/Pattern.hs common/Errors.hs common/ShowCode.hs common/PrettyShow.hs +tock_SOURCES += common/EvalConstants.hs common/Utils.hs common/CompState.hs common/Types.hs +tock_SOURCES += common/Metadata.hs common/AST.hs +tock_SOURCES += backends/TLP.hs backends/BackendPasses.hs backends/AnalyseAsm.hs +tock_SOURCES += backends/GenerateC.hs backends/GenerateCPPCSP.hs +tock_SOURCES += Main.hs + +tocktest_SOURCES = $(tock_SOURCES) +tocktest_SOURCES += transformations/PassTest.hs transformations/UsageCheckTest.hs +tocktest_SOURCES += backends/GenerateCTest.hs backends/BackendPassesTest.hs +tocktest_SOURCES += common/TestUtil.hs common/CommonTest.hs +tocktest_SOURCES += frontends/ParseRainTest.hs frontends/RainPassesTest.hs frontends/RainTypesTest.hs +tocktest_SOURCES += TestMain.hs + +#The programs to actually build: +bin_PROGRAMS = tock +noinst_PROGRAMS = tocktest + + +clean-local: + rm -f obj/*.o obj/*.hi + rmdir obj diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..d76ebc2 --- /dev/null +++ b/configure.ac @@ -0,0 +1,82 @@ +AC_INIT([Tock],[0.0.1],[tock-discuss@kent.ac.uk],[tock]) +AC_CANONICAL_TARGET +AM_INIT_AUTOMAKE + +#Store the mkdir -p command: +AC_PROG_MKDIR_P + +#Check the user has specified a valid srcdir +AC_CONFIG_SRCDIR(Main.hs) + +#Find the C and C++ compilers +AC_PROG_CC +AC_PROG_CXX + +ccsp_kroc_available=true + +#Sets "ac_cv_prog_cc_c99" to "no" if C99 is not supported +AC_PROG_CC_C99 +if test "x$ac_cv_prog_cc_c99" = "xno"; then + AC_MSG_WARN([C99 support not found; output from the C backend will not compile on this machine]) + ccsp_kroc_available=false +fi + +#Check that they have alex, GHC, kroc, and the CCSP headers: +AC_CHECK_PROG([HAVE_GHC],[ghc],[true],[false]) +if test "x$HAVE_GHC" = "xfalse"; then + AC_MSG_ERROR([ghc not found]) +fi + +AC_CHECK_PROG([HAVE_ALEX],[alex],[true],[false]) +if test "x$HAVE_ALEX" = "xfalse"; then + AC_MSG_ERROR([alex not found]) +fi + +AC_CHECK_PROG([HAVE_KROC],[kroc],[true],[false]) +if test "x$HAVE_KROC" = "xfalse"; then + AC_MSG_WARN([kroc not found; you will not be able to compile output from the C backend on this machine]) + ccsp_kroc_available=false +fi + +AC_LANG(C) +AC_CHECK_HEADER([cifccsp.h],[HAVE_CIFCCSP=true],[HAVE_CIFCCSP=false]) + +if test "x$HAVE_CIFCCSP_H" = "xfalse"; then + AC_MSG_WARN([cifccsp.h not found; you will not be able to compile output from the C backend on this machine]) + ccsp_kroc_available=false +fi + +#Using AC_CHECK_HEADER for the C++CSP file dies because autoconf attempts to compile it in a C program, which doesn't like the C++. +#Therefore I just test it using the preprocessor: + +AC_LANG(C++) +AC_CHECK_HEADERS([cppcsp/cppcsp.h],[HAVE_CPPCSP=true],[HAVE_CPPCSP=false]) +if test "x$HAVE_CPPCSP_H" = "xfalse"; then + AC_MSG_WARN([cppcsp/cppcsp.h not found; you will not be able to compile output from the C++ backend on this machine]) + cppcsp_available=false +fi + +#Warn them if neither backend is available: +if test "x$cppcsp_available$ccsp_kroc_available" = "xfalsefalse"; then + AC_MSG_WARN([No working backends: Code from neither the C nor C++ backend will compile on your machine]) +fi + + +#Check whether their compiler supports the -fgnu89-inline flag: +AC_LANG(C) +AC_MSG_CHECKING([whether -fgnu89-inline flag is accepted]) +CFLAGS="-fgnu89-inline" +AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ ]]), + AC_MSG_RESULT([yes]) + gnu89_inline=-fgnu89-inline + , + AC_MSG_RESULT([no]) + gnu89_inline= +) + +AC_SUBST(gnu89_inline) +AC_SUBST(ccsp_kroc_available) +AC_SUBST(cppcsp_available) +AC_SUBST(MKDIR_P) + +AC_OUTPUT(Makefile)