#----------------------------------------------------------------------- # The Helium Compiler #----------------------------------------------------------------------- # make - build everything that is needed # make depend - build dependencies for hs files, ag dependencies are written by hand # make clean - remove .hi and .o files default: all .PHONY : default compiler all coreasm lvmrun libraries clean depend \ smaller newVersion install movetohome status #directories HELIUMBINDIR = ../bin PARSECDIR = ../../parsec PARSECIMPDIR = $(PARSECDIR)/Text/ParserCombinators LVMLIBDIR = ../../lvm/src/lib LVMRUNTIMEDIR = ../../lvm/src/runtime TOPDIR = ../../Top/src/Top #the main program you want to generate MAIN = helium UPX = @UPX@ STRIP = @STRIP@ EXE = @EXEEXT@ INSTALL = @INSTALL@ MKDIR = ../mkinstalldirs LOGGER = @logger@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ libdir = @prefix@/helium/lib demodir = @prefix@/helium/demo status : @echo "*******************************************************************" @echo "Build process complete." @echo "Type \"make install\" to install." @echo " Binaries will go into $(bindir)" @echo " Libraries will go into $(libdir)" @echo " Demos will go into $(demodir)" @echo "*******************************************************************" HC = @WithHc@ ifdef LOGGER PACKAGENET = -package net else PACKAGENET = endif HC_OPTS = -static -fglasgow-exts \ $(PACKAGENET) -package lang -i$(IFACES) $(EXTRA_HC_OPTS) AG = @WithAG@ AG_OPTS = -mscfr # Helium sources PARSER = \ parser/CollectFunctionBindings.hs parser/OperatorTable.hs \ parser/Parser.hs parser/ResolveOperators.hs parser/Lexer.hs \ parser/ParseLibrary.hs parser/ParseMessage.hs \ parser/LexerMonad.hs parser/LexerMessage.hs parser/LayoutRule.hs \ parser/LexerToken.hs MODULESYSTEM = \ modulesystem/ImportEnvironment.hs \ modulesystem/DictionaryEnvironment.hs \ modulesystem/CoreToImportEnv.hs modulesystem/ExtractImportDecls.hs STATICANALYSIS = \ staticanalysis/constraints/LiftedConstraints.hs \ staticanalysis/messages/HeliumConstraintInfo.hs \ staticanalysis/messages/Messages.hs \ staticanalysis/messages/HeliumMessages.hs \ staticanalysis/messages/StaticErrors.hs \ staticanalysis/messages/TypeErrors.hs \ staticanalysis/messages/KindErrors.hs \ staticanalysis/messages/Warnings.hs \ staticanalysis/messages/UHA_Source.hs \ staticanalysis/messages/DoublyLinkedTree.hs \ staticanalysis/heuristics/OnlyResultHeuristics.hs \ staticanalysis/heuristics/RepairHeuristics.hs \ staticanalysis/heuristics/TieBreakerHeuristics.hs \ staticanalysis/staticchecks/StaticChecks.hs \ staticanalysis/inferencers/TypeInferencing.hs \ staticanalysis/inferencers/KindInferencing.hs \ staticanalysis/inferencers/ExpressionTypeInferencer.hs \ staticanalysis/inferencers/typingstrategies/TS_Parser.hs \ staticanalysis/inferencers/typingstrategies/TS_Syntax.hs \ staticanalysis/inferencers/typingstrategies/Matchers.hs \ staticanalysis/inferencers/typingstrategies/TS_Apply.hs \ staticanalysis/inferencers/typingstrategies/TS_Messages.hs \ staticanalysis/inferencers/typingstrategies/TS_Analyse.hs \ staticanalysis/inferencers/typingstrategies/TS_CoreSyntax.hs \ staticanalysis/inferencers/typingstrategies/TS_ToCore.hs \ staticanalysis/inferencers/typingstrategies/TS_Compile.hs \ staticanalysis/inferencers/typingstrategies/TS_Attributes.hs \ staticanalysis/types/TypesToAlignedDocs.hs \ staticanalysis/types/TypeConversion.hs \ $(TOPDIR)/Types/Basics.hs \ $(TOPDIR)/Types/Quantification.hs \ $(TOPDIR)/Types/Qualification.hs \ $(TOPDIR)/Types/Schemes.hs \ $(TOPDIR)/Types/Classes.hs \ $(TOPDIR)/Types/Substitution.hs \ $(TOPDIR)/Types/Kinds.hs \ $(TOPDIR)/Types/Synonyms.hs \ $(TOPDIR)/Types/Unification.hs \ $(TOPDIR)/Types.hs \ $(TOPDIR)/../Graph.hs \ $(TOPDIR)/Constraints/Constraints.hs \ $(TOPDIR)/Constraints/EqualityConstraint.hs \ $(TOPDIR)/Constraints/InstanceConstraint.hs \ $(TOPDIR)/Constraints/PredicateConstraint.hs \ $(TOPDIR)/States/BasicMonad.hs \ $(TOPDIR)/States/BasicState.hs \ $(TOPDIR)/States/SubstState.hs \ $(TOPDIR)/States/TIState.hs \ $(TOPDIR)/Solvers/GreedySolver.hs \ $(TOPDIR)/Solvers/GreedySubst.hs \ $(TOPDIR)/Solvers/SimpleSolver.hs \ $(TOPDIR)/Solvers/SimpleSubst.hs \ $(TOPDIR)/Solvers/SolveConstraints.hs \ $(TOPDIR)/ComposedSolvers/CombinationSolver.hs \ $(TOPDIR)/ComposedSolvers/ChunkySolver.hs \ $(TOPDIR)/ComposedSolvers/Tree.hs \ $(TOPDIR)/ComposedSolvers/TreeWalk.hs \ $(TOPDIR)/TypeGraph/ApplyHeuristics.hs \ $(TOPDIR)/TypeGraph/Basics.hs \ $(TOPDIR)/TypeGraph/DefaultHeuristics.hs \ $(TOPDIR)/TypeGraph/EquivalenceGroup.hs \ $(TOPDIR)/TypeGraph/Heuristics.hs \ $(TOPDIR)/TypeGraph/Paths.hs \ $(TOPDIR)/TypeGraph/TypeGraphMonad.hs \ $(TOPDIR)/TypeGraph/TypeGraphSolver.hs \ $(TOPDIR)/TypeGraph/TypeGraphState.hs \ $(TOPDIR)/TypeGraph/TypeGraphSubst.hs \ UHA = \ syntax/UHA_Syntax.hs syntax/UHA_Utils.hs syntax/UHA_Range.hs \ syntax/UHA_Pretty.hs syntax/UHA_OneLine.hs CODEGENERATION = \ codegeneration/CoreToLvm.hs codegeneration/PatternMatch.hs \ codegeneration/DerivingShow.hs codegeneration/CoreUtils.hs \ codegeneration/CodeGeneration.hs UTILS = \ utils/Utils.hs utils/Logger.hs utils/OSSpecific.hs utils/OneLiner.hs \ utils/Similarity.hs MAINFILES = \ main/Main.hs main/Version.hs main/Args.hs main/Compile.hs \ main/PhaseLexer.hs main/PhaseParser.hs main/PhaseImport.hs main/PhaseResolveOperators.hs \ main/PhaseStaticChecks.hs main/PhaseTypingStrategies.hs main/PhaseTypeInferencer.hs \ main/PhaseDesugarer.hs main/PhaseCodeGenerator.hs main/CompileUtils.hs \ main/PhaseKindInferencer.hs # Parsec sources PARSEC = \ $(PARSECIMPDIR)/Parsec.hs $(PARSECIMPDIR)/Parsec/Char.hs $(PARSECIMPDIR)/Parsec/Combinator.hs $(PARSECIMPDIR)/Parsec/Error.hs $(PARSECIMPDIR)/Parsec/Expr.hs \ $(PARSECIMPDIR)/Parsec/Language.hs $(PARSECIMPDIR)/Parsec/Perm.hs $(PARSECIMPDIR)/Parsec/Pos.hs $(PARSECIMPDIR)/Parsec/Prim.hs $(PARSECIMPDIR)/Parsec/Token.hs # LVM sources LVMCOMMON = \ $(LVMLIBDIR)/common/Id.hs $(LVMLIBDIR)/common/IdMap.hs $(LVMLIBDIR)/common/IdSet.hs $(LVMLIBDIR)/common/IntMap.hs \ $(LVMLIBDIR)/common/Byte.hs $(LVMLIBDIR)/common/Standard.hs \ $(LVMLIBDIR)/common/TopSort.hs $(LVMLIBDIR)/common/Set.hs \ $(LVMLIBDIR)/common/ghc/Special.hs $(LVMLIBDIR)/common/PPrint.hs LVM = $(LVMLIBDIR)/lvm/Lvm.hs $(LVMLIBDIR)/lvm/LvmPretty.hs $(LVMLIBDIR)/lvm/LvmWrite.hs $(LVMLIBDIR)/lvm/LvmRead.hs \ $(LVMLIBDIR)/lvm/LvmImport.hs $(LVMLIBDIR)/lvm/Module.hs $(LVMLIBDIR)/lvm/ModulePretty.hs \ $(LVMLIBDIR)/lvm/Instr.hs $(LVMLIBDIR)/lvm/InstrPretty.hs $(LVMLIBDIR)/lvm/InstrResolve.hs $(LVMLIBDIR)/lvm/InstrRewrite.hs ASM = $(LVMLIBDIR)/asm/AsmOptimize.hs $(LVMLIBDIR)/asm/AsmInline.hs $(LVMLIBDIR)/asm/AsmOccur.hs \ $(LVMLIBDIR)/asm/Asm.hs $(LVMLIBDIR)/asm/AsmPretty.hs $(LVMLIBDIR)/asm/AsmToLvm.hs CORE = $(LVMLIBDIR)/core/Core.hs $(LVMLIBDIR)/core/CorePretty.hs $(LVMLIBDIR)/core/CoreToAsm.hs \ $(LVMLIBDIR)/core/CoreParse.hs $(LVMLIBDIR)/core/CoreLexer.hs \ $(LVMLIBDIR)/core/CoreNormalize.hs $(LVMLIBDIR)/core/CoreRemoveDead.hs \ $(LVMLIBDIR)/core/CoreNoShadow.hs $(LVMLIBDIR)/core/CoreFreeVar.hs $(LVMLIBDIR)/core/CoreLetSort.hs \ $(LVMLIBDIR)/core/CoreLift.hs $(LVMLIBDIR)/core/CoreSaturate.hs IFACES = $(LVMLIBDIR)/common:$(LVMLIBDIR)/common/ghc:$(LVMLIBDIR)/lvm:$(LVMLIBDIR)/asm:$(LVMLIBDIR)/core:./utils:$(PARSECDIR):./parser:./staticanalysis:./staticanalysis/inferencers:./staticanalysis/inferencers/typingstrategies:./staticanalysis/staticchecks:./staticanalysis/constraints:./staticanalysis/types:./staticanalysis/heuristics:./staticanalysis/messages:./syntax:./codegeneration:./main:./modulesystem:$(TOPDIR):../../Top/src # AG sources AGSOURCES = \ syntax/UHA_Pretty.hs syntax/UHA_OneLine.hs \ staticanalysis/staticchecks/StaticChecks.hs staticanalysis/inferencers/TypeInferencing.hs \ staticanalysis/inferencers/KindInferencing.hs \ codegeneration/CodeGeneration.hs \ syntax/UHA_Syntax.hs modulesystem/ExtractImportDecls.hs staticanalysis/inferencers/typingstrategies/TS_Syntax.hs \ staticanalysis/inferencers/typingstrategies/TS_Apply.hs staticanalysis/inferencers/typingstrategies/TS_Analyse.hs \ staticanalysis/inferencers/typingstrategies/TS_CoreSyntax.hs \ staticanalysis/inferencers/typingstrategies/TS_ToCore.hs parser/ResolveOperators.hs #Sources and object files SRCS = $(PARSER) $(STATICANALYSIS) $(UHA) $(CODEGENERATION) $(UTILS) $(LVMCOMMON) \ $(LVM) $(ASM) $(CORE) $(PARSEC) $(MAINFILES) $(MODULESYSTEM) OBJS = $(SRCS:.hs=.o) # The main target compiler: $(OBJS) # GHC Helium compiler $(HC) -o $(HELIUMBINDIR)/$(MAIN)$(EXE) $(HC_OPTS) $(OBJS) ifdef STRIP $(STRIP) $(HELIUMBINDIR)/$(MAIN)$(EXE) endif all: ag compiler coreasm lvmrun libraries texthint status coreasm: # make core assembler cd $(LVMLIBDIR); $(MAKE) EXTRA_HC_OPTS="$(EXTRA_HC_OPTS)" lvmrun: # make lvmrun cd $(LVMRUNTIMEDIR); $(MAKE) .SUFFIXES : .o .hs .hi .lhs .hc .s .ag $(LVMLIBDIR)/common/ghc/Special.hi: $(LVMLIBDIR)/common/ghc/Special.hs # GHC Special.hs $(HC) -c $< -cpp -fglasgow-exts $(HC_OPTS) libraries: # Building libraries cd ../lib; $(MAKE) cd ../lib/simple; $(MAKE) texthint: texthint/Main.hs utils/OSSpecific.hs # GHC HeliumInterpreter $(HC) $(HC_OPTS) --make -iutils -o $(HELIUMBINDIR)/texthint$(EXE) texthint/Main.hs $(STRIP) $(HELIUMBINDIR)/texthint$(EXE) # AG sources ag : $(AGSOURCES) cleanag : $(RM) $(AGSOURCES) ifdef AG parser/ResolveOperators.hs : \ parser/ResolveOperators.ag syntax/UHA_Syntax.ag # AG ResolveOperators cd parser;$(AG) $(AG_OPTS) --self ResolveOperators.ag;cd .. syntax/UHA_Pretty.hs : \ syntax/UHA_Pretty.ag syntax/UHA_Syntax.ag # AG UHA_Pretty cd syntax;$(AG) $(AG_OPTS) UHA_Pretty.ag;cd .. syntax/UHA_OneLine.hs : \ syntax/UHA_OneLine.ag syntax/UHA_Syntax.ag # AG UHA_OneLine cd syntax;$(AG) $(AG_OPTS) --self UHA_OneLine.ag;cd .. staticanalysis/staticchecks/StaticChecks.hs : \ staticanalysis/staticchecks/StaticChecks.ag \ staticanalysis/staticchecks/KindChecking.ag \ staticanalysis/staticchecks/TopLevelErrors.ag \ staticanalysis/staticchecks/MiscErrors.ag \ staticanalysis/staticchecks/Warnings.ag \ staticanalysis/staticchecks/ExportErrors.ag \ staticanalysis/staticchecks/Collect.ag \ staticanalysis/staticchecks/HeliumPartialSyntax.ag \ staticanalysis/staticchecks/Scope.ag \ staticanalysis/staticchecks/ScopeErrors.ag \ syntax/UHA_Syntax.ag # AG StaticAnalysis cd staticanalysis/staticchecks;$(AG) $(AG_OPTS) --self StaticChecks.ag;cd ../.. staticanalysis/inferencers/TypeInferencing.hs : \ staticanalysis/inferencers/TypeInferencing.ag \ staticanalysis/inferencers/TypeInferenceRules.ag \ staticanalysis/inferencers/TypeInferenceOverloading.ag \ staticanalysis/inferencers/TypeInferenceCollect.ag \ staticanalysis/inferencers/TypeInferenceInfo.ag \ staticanalysis/inferencers/PatternMatchWarnings.ag \ staticanalysis/inferencers/LocalInfo.ag \ staticanalysis/inferencers/GlobalInfo.ag \ staticanalysis/staticchecks/HeliumPartialSyntax.ag \ syntax/UHA_Syntax.ag \ staticanalysis/staticchecks/Scope.ag\ staticanalysis/inferencers/typingstrategies/TS_PatternMatching.ag # AG TypeInferencing cd staticanalysis/inferencers;$(AG) $(AG_OPTS) --self TypeInferencing.ag;cd ../.. staticanalysis/inferencers/KindInferencing.hs : \ staticanalysis/inferencers/KindInferencing.ag \ syntax/UHA_Syntax.ag \ # AG TypeInferencing cd staticanalysis/inferencers;$(AG) $(AG_OPTS) --self KindInferencing.ag;cd ../.. codegeneration/CodeGeneration.hs : \ codegeneration/CodeGeneration.ag \ syntax/UHA_Syntax.ag codegeneration/ToCoreModule.ag codegeneration/ToCoreDecl.ag \ codegeneration/ToCoreExpr.ag codegeneration/ToCorePat.ag codegeneration/ToCoreName.ag # AG CodeGeneration cd codegeneration;$(AG) $(AG_OPTS) --self CodeGeneration.ag;cd .. syntax/UHA_Syntax.hs : syntax/UHA_Syntax.ag # AG UHA_Syntax cd syntax;$(AG) -dmr UHA_Syntax.ag;cd .. modulesystem/ExtractImportDecls.hs : \ modulesystem/ExtractImportDecls.ag codegeneration/ToCoreName.ag syntax/UHA_Syntax.ag # AG ExtractImportDecls cd modulesystem;$(AG) $(AG_OPTS) --self ExtractImportDecls.ag;cd .. staticanalysis/inferencers/typingstrategies/TS_Syntax.hs : \ staticanalysis/inferencers/typingstrategies/TS_Syntax.ag # AG TS_Syntax cd staticanalysis/inferencers/typingstrategies;$(AG) -dmr TS_Syntax.ag;cd ../../.. staticanalysis/inferencers/typingstrategies/TS_Analyse.hs : \ staticanalysis/inferencers/typingstrategies/TS_Syntax.ag \ staticanalysis/inferencers/typingstrategies/TS_Collect.ag \ staticanalysis/inferencers/typingstrategies/TS_Analyse.ag \ syntax/UHA_Syntax.ag # AG TS_Analyse cd staticanalysis/inferencers/typingstrategies;$(AG) $(AG_OPTS) --self TS_Analyse.ag;cd ../../.. staticanalysis/inferencers/typingstrategies/TS_Apply.hs : \ staticanalysis/inferencers/typingstrategies/TS_Syntax.ag \ staticanalysis/inferencers/typingstrategies/TS_Collect.ag \ staticanalysis/inferencers/typingstrategies/TS_Apply.ag \ staticanalysis/inferencers/typingstrategies/TS_CoreData.ag \ syntax/UHA_Syntax.ag \ # AG TS_Syntax cd staticanalysis/inferencers/typingstrategies;$(AG) -mscf TS_Apply.ag;cd ../../.. staticanalysis/inferencers/typingstrategies/TS_CoreSyntax.hs : \ staticanalysis/inferencers/typingstrategies/TS_CoreSyntax.ag \ staticanalysis/inferencers/typingstrategies/TS_CoreData.ag # AG TS_CoreSyntax cd staticanalysis/inferencers/typingstrategies;$(AG) -md TS_CoreSyntax.ag;cd ../../.. staticanalysis/inferencers/typingstrategies/TS_ToCore.hs : \ staticanalysis/inferencers/typingstrategies/TS_Syntax.ag \ staticanalysis/inferencers/typingstrategies/TS_Collect.ag \ staticanalysis/inferencers/typingstrategies/TS_ToCore.ag \ syntax/UHA_Syntax.ag \ syntax/UHA_OneLine.ag # AG TS_Syntax cd staticanalysis/inferencers/typingstrategies;$(AG) -mscrf --self TS_ToCore.ag;cd ../../.. endif # Standard suffix rules .o.hi: @: .lhs.o: $(HC) -c $< $(HC_OPTS) .hs.o: $(HC) -c $< $(HC_OPTS) .hs.hi: $(HC) -c $< $(HC_OPTS) .lhs.hi: $(HC) -c $< $(HC_OPTS) .ag.hs: $(AG) -a $< # Clean up clean: $(RM) `find . -name "*.o" -print` $(RM) `find . -name "*.hi" -print` $(RM) `find . -name "*.class" -print` $(RM) ../lib/*.lvm $(RM) $(HELIUMBINDIR)/$(MAIN)$(EXE) $(RM) $(HELIUMBINDIR)/texthint$(EXE) $(RM) -r $(PARSECIMPDIR)/*.o $(RM) -r $(PARSECIMPDIR)/*.hi $(RM) -r $(PARSECIMPDIR)/Parsec/*.o $(RM) -r $(PARSECIMPDIR)/Parsec/*.hi cd $(LVMLIBDIR); $(MAKE) clean cd $(LVMRUNTIMEDIR); $(MAKE) clean # Inter-module dependencies depend : # Checking dependencies $(HC) -M $(HC_OPTS) $(SRCS) # UTRECHT ONLY newVersion: echo "module Version where version=\"1.1 (`date`)\"" >main/Version.hs smaller: # *** UPX helium, texthint & lvmrun ifdef UPX $(UPX) -q $(HELIUMBINDIR)/$(MAIN)$(EXE) cd $(LVMRUNTIMEDIR); $(UPX) -q lvmrun$(EXE) $(UPX) -q $(HELIUMBINDIR)/texthint$(EXE) endif install : smaller # *** Copy sources to library directory $(MKDIR) $(bindir) $(libdir) $(demodir) $(INSTALL) -m 644 ../lib/Prelude.hs ../lib/List.hs ../lib/Maybe.hs $(libdir) $(INSTALL) -m 755 $(HELIUMBINDIR)/$(MAIN)$(EXE) $(bindir) $(INSTALL) -m 755 $(LVMRUNTIMEDIR)/lvmrun$(EXE) $(bindir) $(INSTALL) -m 755 $(HELIUMBINDIR)/texthint$(EXE) $(bindir) # *** Copying demos to demo directory $(INSTALL) -m 644 ../demo/Calendar.hs ../demo/ParserLibrary.hs ../demo/ParserDemo.hs ../demo/TicTacToe.hs $(demodir) # *** Copy generated lvms and touch them $(INSTALL) -m 644 ../lib/*.lvm $(libdir) touch $(libdir)/*.lvm movetohome: smaller # *** Copying library sources to projects directory cp ../lib/Prelude.hs ../lib/List.hs ../lib/Maybe.hs ../distribution/helium/lib # *** Copying executables to projects directory cp $(HELIUMBINDIR)/$(MAIN)$(EXE) ../distribution/helium/bin cp $(LVMRUNTIMEDIR)/lvmrun$(EXE) ../distribution/helium/bin cp $(HELIUMBINDIR)/texthint$(EXE) ../distribution/helium/bin # *** Copying demos to projects directory cp ../demo/Calendar.hs ../demo/ParserLibrary.hs ../demo/ParserDemo.hs ../demo/TicTacToe.hs ../distribution/helium/demo # *** Copy generated lvms and touch them cp ../lib/*.lvm ../distribution/helium/lib touch ../distribution/helium/lib/*.lvm # so that they are seen as up to date movetobbl: smaller # *** Copying library sources to projects directory cp ../lib/Prelude.hs ../lib/List.hs ../lib/Maybe.hs //r/helium/lib # *** Copying executables to projects directory cp $(HELIUMBINDIR)/$(MAIN)$(EXE) //r/helium/bin cp $(LVMRUNTIMEDIR)/lvmrun$(EXE) //r/helium/bin cp $(HELIUMBINDIR)/texthint$(EXE) //r/helium/bin # *** Copying demos to projects directory cp ../demo/Calendar.hs ../demo/ParserLibrary.hs ../demo/ParserDemo.hs ../demo/TicTacToe.hs //r/helium/demo # *** Copy generated lvms and touch them cp ../lib/*.lvm //r/helium/lib touch //r/helium/lib/*.lvm # so that they are seen as up to date # DON'T FORGET TO CHECK PERMISSIONS cp //c/docs/helium/hint/release/Hint.jar //r/helium/bin proxima: # *** Compiling Proxima Type Inferencer Attribute Grammar cd staticanalysis/inferencers;$(AG) $(AG_OPTS) --self ProximaTypeInferencing.ag;cd ../.. # DO NOT DELETE: Beginning of Haskell dependencies # DO NOT DELETE: End of Haskell dependencies