New option variables: HC_PRE and HC_POST; $(SHELL) actions to perform before & after compiling a Haskell source file
# This file defines Make variables for the
# option flags for each utility program
#
# This file defines Make variables for the
# option flags for each utility program
#
-# $Id: opts.mk,v 1.4 1998/01/14 11:22:21 sof Exp $
+# $Id: opts.mk,v 1.5 1998/01/14 16:09:10 sof Exp $
#
#################################################################################
#
#################################################################################
#
# P_OPTS is always defined like this:
#
#
# P_OPTS is always defined like this:
#
-# P_OPTS = SRC_P_OPTS WAY$(_way)_P_OPTS BUILD_P_OPTS EXTRA_P_OPTS
+# P_OPTS = SRC_P_OPTS WAY$(_way)_P_OPTS EXTRA_P_OPTS
#
# where the variables on the right hand side are set by the user or
# some other Makefile. They have the following intended uses:
#
# SRC_P_OPTS Source-tree options for P
# WAY$(_way)_P_OPTS Source-tree options for P specific to $(way)
#
# where the variables on the right hand side are set by the user or
# some other Makefile. They have the following intended uses:
#
# SRC_P_OPTS Source-tree options for P
# WAY$(_way)_P_OPTS Source-tree options for P specific to $(way)
-# BUILD_P_OPTS Build-tree options for P
# EXTRA_P_OPTS Command-line options for P
#
# EXTRA_P_OPTS Command-line options for P
#
+# and for some programs
+#
+# $($*_P_OPTS) Target specific options for P
+#
# All these options should be set with
# thing += extra-options
# in case someone higher up the include hierarchy has already added some
# All these options should be set with
# thing += extra-options
# in case someone higher up the include hierarchy has already added some
# All the standard gluing together, as in the comment right at the front
# All the standard gluing together, as in the comment right at the front
-# For the Haskell compiler and runtests we do something a bit special:
-# we also include target-specific flags
HC_OPTS = $(SRC_HC_OPTS) $(WAY$(_way)_HC_OPTS) $($*_HC_OPTS) $(EXTRA_HC_OPTS)
HC_OPTS = $(SRC_HC_OPTS) $(WAY$(_way)_HC_OPTS) $($*_HC_OPTS) $(EXTRA_HC_OPTS)
+HC_POST = $(SRC_HC_POST_OPTS) $(WAY$(_way)_HC_POST_OPTS) $($*_HC_POST_OPTS) $(EXTRA_HC_POST_OPTS)
+HC_PRE = $(SRC_HC_PRE_OPTS) $(WAY$(_way)_HC_OPTS) $($*_HC_PRE_OPTS) $(EXTRA_HC_PRE_OPTS)
RUNTEST_OPTS = $(SRC_RUNTEST_OPTS) $(WAY$(_way)_RUNTEST_OPTS) \
$($*_RUNTEST_OPTS) $(EXTRA_RUNTEST_OPTS)
RUNTEST_OPTS = $(SRC_RUNTEST_OPTS) $(WAY$(_way)_RUNTEST_OPTS) \
$($*_RUNTEST_OPTS) $(EXTRA_RUNTEST_OPTS)
#-----------------------------------------------------------------------------
# Haskell Suffix Rules
#-----------------------------------------------------------------------------
# Haskell Suffix Rules
$(RM) $@ ; if [ ! -d $(basename $@) ]; then mkdir $(basename $@); else \
find $(basename $@) -name '*.$(way_)o' -print | xargs $(RM) __rm_food ; fi
$(RM) $@ ; if [ ! -d $(basename $@) ]; then mkdir $(basename $@); else \
find $(basename $@) -name '*.$(way_)o' -print | xargs $(RM) __rm_food ; fi
-HASKELL_SPLIT_POST= touch $@
-HASKELL_PRE_COMPILE=$(patsubst %,$(HASKELL_SPLIT_PRE),$(filter -split-objs,$(HC_OPTS)))
-HASKELL_POST_COMPILE=$(patsubst %,$(HASKELL_SPLIT_POST),$(filter -split-objs,$(HC_OPTS)))
+HC_SPLIT_POST = touch $@
+
+HC_PRE__ = $(patsubst %,$(HC_SPLIT_PRE) ; ,$(filter -split-objs,$(HC_OPTS)))
+HC_POST__ = $(patsubst %,$(HC_SPLIT_POST) ; ,$(filter -split-objs,$(HC_OPTS)))
+
+SRC_HC_POST += $(HC_POST__)
+SRC_HC_PRE += $(HC_PRE__)
$(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
$(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
- $(HASKELL_POST_COMPILE)
$(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
$(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
- $(HASKELL_POST_COMPILE)
%.$(way_)hc : %.lhs
$(RM) $@
%.$(way_)hc : %.lhs
$(RM) $@
$(HC) $(HC_OPTS) -C $< -o $@
%.$(way_)o : %.$(way_)hc
$(HC) $(HC_OPTS) -C $< -o $@
%.$(way_)o : %.$(way_)hc
$(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
$(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
- $(HASKELL_POST_COMPILE)
%.$(way_)hc : %.lhc
@$(RM) $@
%.$(way_)hc : %.lhc
@$(RM) $@