Subversion

Relation

?curdirlinks? - Rev 5

?prevdifflink? - Blame


###########################################################################
#
# Variables
#

top             = .
hsmodules       = $(shell find $(top) -name "*.hs")
lhsmodules      = $(shell find $(top) -name "*.lhs")
modules         = $(shell find $(top) -name "*.hs" -or -name "*.lhs")
humodules       = $(shell find $(top) -name "*HUnit.hs" -or \
                                      -name "*HUnit.lhs")
ghmodules       = $(shell find $(top) -name "*GHood.hs" -or \
                                      -name "*GHood.lhs")
qcmodules       = $(shell find $(top) -name "*QuickCheck.hs" -or \
                                      -name "*QuickCheck.lhs")
grammars        = $(shell find $(top) -name "*.def" -or -name "*.dtd")
tables          = $(shell find $(top) -name "*.tbl")

contrib         = $(PWD)/../contrib

###########################################################################
#
# Instructions
#

all:
        @cat instructions

###########################################################################
#
# GHC
#

sfLib           = $(contrib)/StrategyLib-5.0
sfModel         = drift-default
sfPath          = $(sfLib)/library:$(sfLib)/models/$(sfModel)

shPath          = $(contrib)/Sdf2Haskell-2.3/generator

atLib           = $(contrib)/haterm-1.5
atPath          = $(atLib)/library
hlistPath       = $(contrib)/HList
oohaskellPath   = $(contrib)/OOHaskell

hsqlPath        = $(contrib)/HSQL-1.7/HSQL
postgreshsqlPath= $(contrib)/HSQL-1.7/PostgreSQL
haxmlPath       = $(contrib)/HaXml-1.12/src
washPath        = $(contrib)/WashNGo-2.0.5/cgi:$(contrib)/WashNGo-2.0.5/Utility:$(contrib)/WashNGo-2.0.5/WASH

hsPluginsPath   = $(contrib)/hs-plugins-0.9.8/src/altdata

ghcPath         = :$(contrib)/HUnit-1.0:$(sfPath):$(shPath):$(atPath):$(haxmlPath):$(hsPluginsPath):$(hlistPath):$(oohaskellPath):$(hsqlPath):$(postgreshsqlPath)

ghcOpts         = -w -fwarn-overlapping-patterns -fwarn-deprecations -fwarn-duplicate-exports \
                          -fwarn-missing-fields -fglasgow-exts -fallow-overlapping-instances \
                  -fallow-undecidable-instances -fwarn-unused-imports \
                  -i$(ghcPath)

washModules     = $(shell egrep -l "</[a-z]+>" `find $(top) -iname "*hs"`)
ghciModules     = $(filter-out $(washModules), $(modules))

sql-happy:
ifeq ($(SQL),max)
        happy -i -g -a -c Text/SQL/PostgreSQLmax.y
else
        happy -i -g -a -c Text/SQL/PostgreSQLmin.y
endif

ghci:
        mkdir -p ${docDir}
        mkdir -p hidir
        mkdir -p odir
ifeq ($(hsql),postgres)
        hsc2hs $(hsqlPath)/Database/HSQL.hsc
        hsc2hs $(postgreshsqlPath)/Database/HSQL/PostgreSQL.hsc -I/usr/local/pgsql/include -I/usr/local/pgsql/include/server
        ghc --make -hidir hidir -odir odir -fglasgow-exts -i$(hsqlPath) -i$(postgreshsqlPath) $(postgreshsqlPath)/Database/HSQL/PostgreSQL.hs
        ghci -hidir hidir -odir odir ${ghcOpts} $(ghciModules) -L/usr/local/pgsql/lib -lpq
else
        ghci -hidir hidir -odir odir ${ghcOpts} $(ghciModules)
endif

ghc:
        mkdir -p hidir
        mkdir -p odir
ifeq ($(hsql),postgres)
        hsc2hs $(hsqlPath)/Database/HSQL.hsc
        hsc2hs $(postgreshsqlPath)/Database/HSQL/PostgreSQL.hsc -I/usr/local/pgsql/include -I/usr/local/pgsql/include/server
        ghc --make -hidir hidir -odir odir ${ghcOpts} $(ghciModules) -L/usr/local/pgsql/lib -lpq
else
        ghc --make -hidir hidir -odir odir ${ghcOpts} $(ghciModules)
endif

# Don't rely on this rule. It's a temporary patch
hsql:
        mkdir -p hidir
        mkdir -p odir
        ghc --make -hidir hidir -odir odir ${ghcOpts} -cpp $(ghciModules)



###########################################################################
#
# Documentation
#

docDir          = ./documentation
infixModules    = $(shell egrep -l ":.:" `find $(top) -name "*hs"`)
skipModules     = $(infixModules) $(washModules)
skipModulesCodd= $(washModules) $(qcmodules) $(humodules)
lhs2hsModules   = $(patsubst %.lhs, %.lhs2hs, $(filter-out $(skipModules), $(lhsmodules)))
hddkModules     = $(filter-out $(skipModules), $(hsmodules)) $(lhs2hsModules)

haddock: lhs2hs
        @$(RM) -r ${docDir}
        @mkdir -p ${docDir}
        @echo "Running Haddock, redirecting warnings to haddock.log"
        @haddock -o ${docDir} -h \
          --title="UMinho Haskell Libraries ($(distVersion))" \
          -p Prologue \
          $(filter-out $(skipModules), $(hsmodules)) \
          $(lhs2hsModules) 2> haddock.log
        @echo "Generated documentation in $(docDir)"
        @echo "Skipped modules: $(skipModules)"
        @echo "because Haddock can't handle them"

haddockCodd: lhs2hs
        @$(RM) -r ${docDir}
        @mkdir -p ${docDir}
        @echo "Running Haddock, redirecting warnings to haddock.log"
        @haddock -o ${docDir} -h \
          --title="CoddFish Libraries" \
          -p PrologueCodd \
          $(filter-out $(skipModulesCodd), $(hsmodules)) \
          $(lhs2hsModules) 2> haddock.log
        @echo "Generated documentation in $(docDir)"
        @echo "Skipped modules: $(skipModules)"
        @echo "because Haddock can't handle them"
lhs2hs: $(lhs2hsModules)

%.lhs2hs: %.lhs
        @ghc -E $< -o /tmp/q
        @egrep -v "^#" /tmp/q > $@

###########################################################################
#
# Monitoring
#

report:
        @echo "Running report generation on Haskell modules..."
        @echo "runMetrics \"$(top)\" \"$(distFullName)-metrics.txt\"" \
          > metrics.hsc
        @ghci -hidir hidir -odir odir -v0 ${ghcOpts} Language.Haskell.Metrics < metrics.hsc


###########################################################################
#
# Distribution
#

distName        = UMinhoHaskellLibraries
distVersion     = $(shell date "+%Y.%m.%d")
distFiles       = $(modules) $(docDir) $(appletDir) $(grammars) $(tables) \
                  Makefile instructions Prologue
distFullName    = $(distName)-$(distVersion)
lnDistFiles     = $(subst /./,/, $(patsubst %, $(distFullName)/%, $(distFiles)))

dist:
        @mkdir -p ${docDir}
        @mkdir -p ${appletDir}
        @echo "Creating distribution $(distFullName)"
        @rm -rf $(distFullName)
        @ln -s . $(distFullName)
        @zip -q -r $(distFullName).zip $(lnDistFiles)
        @tar zcf $(distFullName).tgz $(lnDistFiles)
        @rm -f $(distFullName)
        @echo "  READY for distribution:"
        @echo "    $(distFullName).zip"
        @echo "    $(distFullName).tgz"
        
# Specific distribution: 2LT

distFiles2LT = ${wildcard Data/Transform/*hs} README-2LT
dist-2LT:
        $(MAKE) distName=2LT distFiles="$(distFiles2LT)" dist-simple

dist-simple:
        @echo "Creating distribution $(distFullName)"
        @rm -rf $(distFullName)
        @ln -s . $(distFullName)
        @rm -f $(distFullName).zip $(distFullName).tgz
        @zip -q -r $(distFullName).zip $(lnDistFiles)
        @tar zcf $(distFullName).tgz $(lnDistFiles)
        @rm -f $(distFullName)
        @echo "  READY for distribution:"
        @echo "    $(distFullName).zip"
        @echo "    $(distFullName).tgz"


###########################################################################
#
# HUnit
#

huSession = session.hunit

hunit:
        @echo "Running HUnit on modules: $(humodules)"
        @echo "" > $(huSession)
        @$(MAKE) $(patsubst %, %.hunit, $(humodules))
        @ghci -hidir hidir -odir odir -w $(ghcOpts) -v0 < $(huSession)
        @rm $(huSession)

%.hunit:
        @echo ":l $*" >>  $(huSession)
        @echo "main" >> $(huSession)

###########################################################################
#
# QuickCheck
#

quickCheck:
        @echo "Running QuickCheck"
        @$(contrib)/quickCheck +names -w -v0 -fglasgow-exts -i$(ghcPath) $(qcmodules)

###########################################################################
#
# GHood
#

ghSession = session.ghood
appletDir = ./applets

ghood:
        @echo "Running GHood, redirecting warnings to ghood.log"
        @echo "Animation modules: $(ghmodules)"
        @$(RM) -r $(appletDir)
        @mkdir $(appletDir)
        @echo "" > ghood.log
        @cp $(contrib)/GHood.jar $(appletDir)
        @echo "If the GHood window appears, please press exit."
        @$(MAKE) $(patsubst %, %.ghood, $(ghmodules))
        @echo "Generated applets in $(appletDir)"

%.ghood:
        @echo "" > $(ghSession)
        @echo ":l $*" >>  $(ghSession)
        @echo "main" >> $(ghSession)
        @ghci $(ghcOpts) -v0 < $(ghSession) >> ghood.log 2>> ghood.log
        @export modName="$(subst /,.,$(basename $*))"; \
        mv ObserveEvents.log $(appletDir)/$$modName.ObserveEvents.log; \
        sed "s|__ObserveEventsLog__|$$modName.ObserveEvents.log|g" \
          ghood_applet_template.html > \
          $(appletDir)/$$modName.applet.html


###########################################################################
#
# Generic rules to create an haskell data type module and its pretty-printer
# from a SDF Grammar file.
#
# It requires two global variables:
#   SDFGRAMMAR     - file name with the sdf grammar
#   HASKELL_MODULE - name to be used in the module hierarchy (e.g. Data.XYZ.)
#

Syntax.hs: $(SDFGRAMMAR)
        Sdf2Haskell -i $< -o $@ -h -m $(HASKELL_MODULE)Syntax

SyntaxPP.hs: $(SDFGRAMMAR)
        Sdf2Haskell -i $< -o $@.tmp -p -m $(HASKELL_MODULE)Syntax
        sed 's/SyntaxTermInstances/TermInstances/1' < $@.tmp > $@.tmp1
        sed 's/HughesPJ/HughesPJ hiding (Mode)/1' < $@.tmp1 > $@
        rm -f $@.tmp $@.tmp1


###########################################################################
#
# Generic rules for creating instances of miscellaneous Haskell classes
# using the DrIFT tool.
#
# It requires two global variables:
#    SYNTAX         - The name of the Haskell module where the grammar AST
#    HASKELL_MODULE - name to be used in the module hierarchy (same variable
#                     used in the Sdf2Haskell generation)
#


generate: $(patsubst %.def, %.generate, $(shell find $(top) -name "*.def"))

%.generate: %.def
        (cd $(dir $<);\
     $(MAKE) -f $(PWD)/Makefile\
             SYNTAX=Syntax \
             HASKELL_MODULE=$(subst /,.,$(dir $<))\
             SDFGRAMMAR=$(PWD)/$< \
             instances )

instances: EqInstances.hs OrdInstances.hs ShowInstances.hs \
           ReadInstances.hs TermInstances.hs ATermInstances.hs

EqInstances.hs: $(SYNTAX).hs
        @echo 'module $(HASKELL_MODULE)EqInstances where'     > $@
        @echo ''                                             >> $@
        @echo 'import $(HASKELL_MODULE)$(SYNTAX)'            >> $@
        @echo ''                                             >> $@
        DrIFT -r -g Eq $<                                    >> $@

OrdInstances.hs: $(SYNTAX).hs EqInstances.hs
        @echo 'module $(HASKELL_MODULE)OrdInstances where'    > $@
        @echo ''                                             >> $@
        @echo 'import $(HASKELL_MODULE)$(SYNTAX)'            >> $@
        @echo 'import $(HASKELL_MODULE)EqInstances'          >> $@
        @echo ''                                             >> $@
        DrIFT -r -g Ord $<                                   >> $@

ShowInstances.hs: $(SYNTAX).hs
        @echo 'module $(HASKELL_MODULE)ShowInstances where'   > $@
        @echo ''                                             >> $@
        @echo 'import $(HASKELL_MODULE)$(SYNTAX)'            >> $@
        @echo ''                                             >> $@
        DrIFT -r -g Show $<                                  >> $@

ReadInstances.hs: $(SYNTAX).hs
        @echo 'module $(HASKELL_MODULE)ReadInstances where'   > $@
        @echo ''                                             >> $@
        @echo 'import $(HASKELL_MODULE)$(SYNTAX)'            >> $@
        @echo ''                                             >> $@
        DrIFT -r -g Read $<                                  >> $@

TermInstances.hs: $(SYNTAX).hs
        @echo 'module $(HASKELL_MODULE)TermInstances where'   > $@
        @echo ''                                             >> $@
        @echo 'import $(HASKELL_MODULE)$(SYNTAX)'            >> $@
        @echo 'import TermRep'                               >> $@
        @echo ''                                             >> $@
        DrIFT -r -g Term -g Typeable $< | \
          sed s/mkAppTy/mkTyConApp/g                         >> $@

ATermInstances.hs: $(SYNTAX).hs
        @echo 'module $(HASKELL_MODULE)ATermInstances where'  > $@
        @echo ''                                             >> $@
        @echo 'import $(HASKELL_MODULE)$(SYNTAX)'            >> $@
        @echo 'import ATermLib'                              >> $@
        @echo ''                                             >> $@
        DrIFT -r -g ATermConvertible $<                      >> $@


###########################################################################
#
# Cleaning

hiModules       = hidir #$(shell find $(top) -name "*.hi")
oModules        = odir #$(shell find $(top) -name "*.o")

clean:
        $(RM) $(distName)-*.zip $(distName)-*.tgz
        $(RM) -rf $(hiModules) $(oModules)
        $(RM) $(shell find $(top) -name "*.lhs2hs")
        $(RM) session.* *.log hugsin

###########################################################################
#
# Debugging this Makefile

echo-%:
        @echo $($(*))

###########################################################################

Theme by Vikram Singh | Powered by WebSVN v2.3.3