diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-10-05 22:35:22 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-10-05 22:36:18 +0200 |
commit | 3549c952b535803270872adaf87262f2df0295a4 (patch) | |
tree | 6352a317b7999b8544e68a7acdc2e190339215d6 /includes | |
parent | 2a8ea4745d6ff79d6ce17961a64d9013243fc3c6 (diff) | |
download | haskell-3549c952b535803270872adaf87262f2df0295a4.tar.gz |
Implement `MIN_VERSION_GLASGOW_HASKELL()` macro
This exposes the `cProjectPatchLevel{1,2}` value at the CPP level to
allow it to be used in CPP conditionals. Concretely, GHC 7.10.2.20150623
would result in
#define __GLASGOW_HASKELL__ 710
#define __GLASGOW_HASKELL_PATCHLEVEL1__ 2
#define __GLASGOW_HASKELL_PATCHLEVEL2__ 20150623
while GHC 7.10.3 results in
#define __GLASGOW_HASKELL__ 710
#define __GLASGOW_HASKELL_PATCHLEVEL1__ 3
and finally GHC 7.9.20141009 results in
#define __GLASGOW_HASKELL__ 709
#define __GLASGOW_HASKELL_PATCHLEVEL1__ 20141009
As it's error-prone to properly express CPP conditionals for testing GHC
multi-component versions, a new macro `MIN_VERSION_GLASGOW_HASKELL()` is
provided (also via the new CPP include file `ghcversion.h`)
Finally, in order to make it easier to define the new CPP macro
`MIN_VERSION_GLASGOW_HASKELL()`, a new default-included
`include/ghcversion.h` is used for the new CPP definitions.
Reviewed By: ekmett, austin, #ghc
Differential Revision: https://phabricator.haskell.org/D66
Diffstat (limited to 'includes')
-rw-r--r-- | includes/ghc.mk | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/includes/ghc.mk b/includes/ghc.mk index 5342cc8c02..f0bfbec0da 100644 --- a/includes/ghc.mk +++ b/includes/ghc.mk @@ -16,6 +16,7 @@ # XXX: these should go in includes/dist/build? includes_H_CONFIG = includes/ghcautoconf.h includes_H_PLATFORM = includes/ghcplatform.h +includes_H_VERSION = includes/ghcversion.h # # All header files are in includes/{one of these subdirectories} @@ -53,6 +54,34 @@ ifeq "$(DYNAMIC_BY_DEFAULT)" "YES" includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT endif + +$(includes_H_VERSION) : mk/project.mk | $$(dir $$@)/. + @echo "Creating $@..." + @echo "#ifndef __GHCVERSION_H__" > $@ + @echo "#define __GHCVERSION_H__" >> $@ + @echo >> $@ + @echo "#ifndef __GLASGOW_HASKELL__" >> $@ + @echo "# define __GLASGOW_HASKELL__ $(ProjectVersionInt)" >> $@ + @echo "#endif" >> $@ + @echo >> $@ + @if [ -n "$(ProjectPatchLevel1)" ]; then \ + echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ $(ProjectPatchLevel1)" >> $@; \ + fi + @if [ -n "$(ProjectPatchLevel2)" ]; then \ + echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ $(ProjectPatchLevel2)" >> $@; \ + fi + @echo >> $@ + @echo '#define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) (\\' >> $@ + @echo ' ((ma)*100+(mi)) < __GLASGOW_HASKELL__ || \\' >> $@ + @echo ' ((ma)*100+(mi)) == __GLASGOW_HASKELL__ \\' >> $@ + @echo ' && (pl1) < __GLASGOW_HASKELL_PATCHLEVEL1__ || \\'>> $@ + @echo ' ((ma)*100+(mi)) == __GLASGOW_HASKELL__ \\' >> $@ + @echo ' && (pl1) == __GLASGOW_HASKELL_PATCHLEVEL1__ \\' >> $@ + @echo ' && (pl2) <= __GLASGOW_HASKELL_PATCHLEVEL2__ )' >> $@ + @echo >> $@ + @echo "#endif /* __GHCVERSION_H__ */" >> $@ + @echo "Done." + ifneq "$(BINDIST)" "YES" ifeq "$(PORTING_HOST)" "YES" @@ -160,8 +189,8 @@ DERIVE_CONSTANTS_FLAGS += $(addprefix --gcc-flag$(space),$(includes_CC_OPTS) -fc DERIVE_CONSTANTS_FLAGS += --nm-program "$(NM)" ifneq "$(BINDIST)" "YES" -$(includes_DERIVEDCONSTANTS): $$(includes_H_CONFIG) $$(includes_H_PLATFORM) $$(includes_H_FILES) $$(rts_H_FILES) -$(includes_GHCCONSTANTS_HASKELL_VALUE): $$(includes_H_CONFIG) $$(includes_H_PLATFORM) $$(includes_H_FILES) $$(rts_H_FILES) +$(includes_DERIVEDCONSTANTS): $$(includes_H_CONFIG) $$(includes_H_PLATFORM) $$(includes_H_VERSION) $$(includes_H_FILES) $$(rts_H_FILES) +$(includes_GHCCONSTANTS_HASKELL_VALUE): $$(includes_H_CONFIG) $$(includes_H_PLATFORM) $$(includes_H_VERSION) $$(includes_H_FILES) $$(rts_H_FILES) $(includes_DERIVEDCONSTANTS): $(deriveConstants_INPLACE) | $$(dir $$@)/. $< --gen-header -o $@ --tmpdir $(dir $@) $(DERIVE_CONSTANTS_FLAGS) @@ -183,10 +212,10 @@ endif # Install all header files $(eval $(call clean-target,includes,,\ - $(includes_H_CONFIG) $(includes_H_PLATFORM))) + $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_VERSION))) $(eval $(call all-target,includes,\ - $(includes_H_CONFIG) $(includes_H_PLATFORM) \ + $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_VERSION) \ $(includes_GHCCONSTANTS_HASKELL_TYPE) \ $(includes_GHCCONSTANTS_HASKELL_VALUE) \ $(includes_GHCCONSTANTS_HASKELL_WRAPPERS) \ @@ -202,5 +231,5 @@ install_includes : $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)/$d") && \ $(call INSTALL_HEADER,$(INSTALL_OPTS),includes/$d/*.h,"$(DESTDIR)$(ghcheaderdir)/$d/") && \ ) true - $(call INSTALL_HEADER,$(INSTALL_OPTS),$(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_DERIVEDCONSTANTS),"$(DESTDIR)$(ghcheaderdir)/") + $(call INSTALL_HEADER,$(INSTALL_OPTS),$(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_VERSION) $(includes_DERIVEDCONSTANTS),"$(DESTDIR)$(ghcheaderdir)/") |