diff --git a/Makefile.am b/Makefile.am index a934a9d..947287d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,6 +58,15 @@ CompilerCommands.hs: Makefile echo 'cxxCommand :: String -> String -> String' >> CompilerCommands.hs echo 'cxxCommand inp out = "$(CXX) $(TOCK_CXXFLAGS) -o " ++ out ++ " " ++ inp ++ " $(TOCK_CXXLDFLAGS)"' >> CompilerCommands.hs +TypeSizes.hs: Makefile + echo 'module TypeSizes where' > TypeSizes.hs + echo '--This file is auto-generated by Makefile.am' >> TypeSizes.hs + echo 'cBoolSize, cxxBoolSize, cIntSize, cxxIntSize :: Int' >> TypeSizes.hs + echo 'cBoolSize = @C_BOOL_SIZE@' >> TypeSizes.hs + echo 'cxxBoolSize = @CXX_BOOL_SIZE@' >> TypeSizes.hs + echo 'cIntSize = @C_INT_SIZE@' >> TypeSizes.hs + echo 'cxxIntSize = @CXX_INT_SIZE@' >> TypeSizes.hs + # Both these results are near-identical. The -g flag to alex tells it to generate # a lexer optimised for GHC. The other part of the rule inserts the # -fno-warn-tabs flag under GHC >= 6.8, but doesn't add anything under previous @@ -89,7 +98,7 @@ data/TagAST.hs: GenTagAST$(EXEEXT) data/OrdAST.hs: GenOrdAST$(EXEEXT) ./GenOrdAST$(EXEEXT) > data/OrdAST.hs -BUILT_SOURCES = frontends/LexOccam.hs frontends/LexRain.hs CompilerCommands.hs data/TagAST.hs data/OrdAST.hs +BUILT_SOURCES = frontends/LexOccam.hs frontends/LexRain.hs CompilerCommands.hs TypeSizes.hs data/TagAST.hs data/OrdAST.hs CLEANFILES = $(BUILT_SOURCES) EXTRA_DIST = docextra testcases/automatic diff --git a/configure.ac b/configure.ac index 2310e23..1fa5323 100644 --- a/configure.ac +++ b/configure.ac @@ -140,6 +140,24 @@ fi AM_CONDITIONAL([GHC68],[test $ghc_version_major -ge 6 -a $ghc_version_mid -ge 8]) +# Check the sizes of certain constructs. We'll need to be cleverer if in future +# we want to allow cross-compilation. +AC_LANG(C++) +AC_CHECK_SIZEOF(bool) +AC_COMPUTE_INT(CXX_BOOL_SIZE,SIZEOF_BOOL) +AC_SUBST(CXX_BOOL_SIZE) +AC_CHECK_SIZEOF(int) +AC_COMPUTE_INT(CXX_INT_SIZE,SIZEOF_INT) +AC_SUBST(CXX_INT_SIZE) +AC_LANG(C) +AC_CHECK_SIZEOF(_Bool) +AC_COMPUTE_INT(C_BOOL_SIZE,SIZEOF__BOOL) +AC_SUBST(C_BOOL_SIZE) +AC_CHECK_SIZEOF(int) +AC_COMPUTE_INT(C_INT_SIZE,SIZEOF_INT) +AC_SUBST(C_INT_SIZE) + + AC_SUBST(gnu89_inline) AC_SUBST(ccsp_kroc_available) AC_SUBST(cppcsp_available)