Add SRC_[CH]C_WARNING_OPTS
authorIan Lynagh <igloo@earth.li>
Thu, 26 Apr 2012 18:28:39 +0000 (19:28 +0100)
committerIan Lynagh <igloo@earth.li>
Thu, 26 Apr 2012 18:28:39 +0000 (19:28 +0100)
This allows you to say things like
    SRC_HC_WARNING_OPTS += -fno-warn-unsupported-calling-conventions
in mk/validate.mk.

Unfortunately, we can't just use SRC_HC_OPTS, as that gets put before
the more specific options (e.g. ghc-options in a .cabal file), many of
which include -Wall. So now we have:
    ghc $(SRC_HC_OPTS) ... options from .cabal etc ... $(SRC_HC_WARNING_OPTS)

mk/validate-settings.mk
rules/build-package-data.mk
rules/distdir-way-opts.mk
utils/ghc-pkg/ghc.mk

index 119dce1..fa5add5 100644 (file)
@@ -1,20 +1,22 @@
 # DO NOT EDIT!  Instead, create a file mk/validate.mk, whose settings will
 # override these.  See also mk/custom-settings.mk.
 
-WERROR          = -Werror
+WERROR              = -Werror
+SRC_CC_WARNING_OPTS =
+SRC_HC_WARNING_OPTS =
 
 HADDOCK_DOCS    = YES
 
-SRC_CC_OPTS     += -Wall $(WERROR)
 # Debian doesn't turn -Werror=unused-but-set-variable on by default, so
 # we turn it on explicitly for consistency with other users
 ifeq "$(GccLT46)" "NO"
-SRC_CC_OPTS     += -Werror=unused-but-set-variable
+SRC_CC_WARNING_OPTS += -Werror=unused-but-set-variable
 # gcc 4.6 gives 3 warning for giveCapabilityToTask not being inlined
-SRC_CC_OPTS     += -Wno-error=inline
+SRC_CC_WARNING_OPTS += -Wno-error=inline
 endif
 
-SRC_HC_OPTS     += -Wall $(WERROR) -H64m -O0
+SRC_CC_OPTS     += $(WERROR) -Wall
+SRC_HC_OPTS     += $(WERROR) -Wall -H64m -O0
 
 GhcStage1HcOpts += -O -fwarn-tabs
 
index d535e34..047efcb 100644 (file)
@@ -39,7 +39,7 @@ endif
 # We filter out -Werror from SRC_CC_OPTS, because when configure tests
 # for a feature it may not generate warning-free C code, and thus may
 # think that the feature doesn't exist if -Werror is on.
-$1_$2_CONFIGURE_OPTS += --configure-option=CFLAGS="$$(filter-out -Werror,$$(SRC_CC_OPTS)) $$(CONF_CC_OPTS_STAGE$3) $$($1_CC_OPTS) $$($1_$2_CC_OPTS)"
+$1_$2_CONFIGURE_OPTS += --configure-option=CFLAGS="$$(filter-out -Werror,$$(SRC_CC_OPTS)) $$(CONF_CC_OPTS_STAGE$3) $$($1_CC_OPTS) $$($1_$2_CC_OPTS) $$(SRC_CC_WARNING_OPTS)"
 $1_$2_CONFIGURE_OPTS += --configure-option=LDFLAGS="$$(SRC_LD_OPTS) $$(CONF_GCC_LINKER_OPTS_STAGE$3) $$($1_LD_OPTS) $$($1_$2_LD_OPTS)"
 $1_$2_CONFIGURE_OPTS += --configure-option=CPPFLAGS="$$(SRC_CPP_OPTS) $$(CONF_CPP_OPTS_STAGE$3) $$($1_CPP_OPTS) $$($1_$2_CPP_OPTS)"
 
index 2e5f764..c26bbc7 100644 (file)
@@ -41,6 +41,10 @@ define distdir-way-opts # args: $1 = dir, $2 = distdir, $3 = way, $4 = stage
 #                                                          mk/build.mk
 #                                                          mk/validate.mk
 #   
+#  SRC_HC_WARNING_OPTS   source-tree-wide GHC warning      mk/config.mk.in
+#                        options                           mk/build.mk
+#                                                          mk/validate.mk
+#   
 #  EXTRA_HC_OPTS         for supplying extra options on    make EXTRA_HC_OPTS=...
 #                        the command line   
 #   
@@ -102,6 +106,7 @@ $1_$2_$3_MOST_HC_OPTS = \
  $$($1_$2_EXTRA_HC_OPTS) \
  $$($1_$2_$3_HC_OPTS) \
  $$($$(basename $$<)_HC_OPTS) \
+ $$(SRC_HC_WARNING_OPTS) \
  $$(EXTRA_HC_OPTS)
 
 # NB. CONF_HC_OPTS_STAGE$4 has to be late enough to override $1_$2_HC_OPTS, so
@@ -151,7 +156,8 @@ $1_$2_DIST_CC_OPTS = \
  $$($1_$2_CC_OPTS) \
  $$($1_$2_CPP_OPTS) \
  $$($1_$2_CC_INC_FLAGS) \
- $$($1_$2_DEP_CC_OPTS)
+ $$($1_$2_DEP_CC_OPTS) \
+ $$(SRC_CC_WARNING_OPTS)
 
 ifneq ($$(strip $$($1_$2_DEP_LIB_DIRS_SINGLE_QUOTED)),)
 $1_$2_DIST_LD_LIB_DIRS := $$(subst $$(space)',$$(space)-L',$$(space)$$($1_$2_DEP_LIB_DIRS_SINGLE_QUOTED))
index 11b7c8f..4f4967e 100644 (file)
@@ -55,6 +55,7 @@ utils/ghc-pkg/dist/build/tmp/$(utils/ghc-pkg_dist_PROG)$(exeext): utils/ghc-pkg/
        "$(GHC)" $(SRC_HC_OPTS) --make utils/ghc-pkg/Main.hs -o $@ \
               -no-user-package-conf \
               -Wall -fno-warn-unused-imports -fno-warn-warnings-deprecations \
+              $(SRC_HC_WARNING_OPTS) \
               -DCABAL_VERSION=$(CABAL_VERSION) \
               -DBOOTSTRAPPING \
               -odir  bootstrapping \