diff options
author | Sébastien Hinderer <Sebastien.Hinderer@inria.fr> | 2021-08-31 18:17:03 +0200 |
---|---|---|
committer | Sébastien Hinderer <Sebastien.Hinderer@inria.fr> | 2021-10-08 12:20:06 +0200 |
commit | c71428e7a3c69f3478c92b8c92918e51aafe311d (patch) | |
tree | 8f568d965b1bcfd0f13b8c1a759023ff47c89140 | |
parent | b9ec96722d45dab17dc58f0d037a60d1b3343913 (diff) | |
download | ocaml-c71428e7a3c69f3478c92b8c92918e51aafe311d.tar.gz |
Transform runtime/caml/version.h into a configured header
This means that, before this commit, runtime/caml/version.h was
generated during the build process by a recipe found in runtime/Makefile.
After this commit, runtime/caml/version.h is generated by the configure
script from runtime/caml/version.h.in
This commit makes an effort to guarantee that the version.h file
generated by configure is as similar as possible to the one produced
by the make recipe before, that's why runtime/caml/version.h.in
contains no copyright notice at this stage.
It will be added in the following commit.
At this stage, the only difference between the two versions of version.h
(the one generated by make before and the one generated by configure now)
is the coment line produced by configure as the first line of version.h, namely:
/* runtime/caml/version.h. Generated from version.h.in by configure. */
but this cannot be avoided and is harmless.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | build-aux/ocaml_version.m4 | 11 | ||||
-rwxr-xr-x | configure | 17 | ||||
-rw-r--r-- | configure.ac | 10 | ||||
-rw-r--r-- | runtime/Makefile | 22 | ||||
-rw-r--r-- | runtime/caml/version.h.in | 6 | ||||
-rwxr-xr-x | tools/make-version-header.sh | 55 |
7 files changed, 56 insertions, 67 deletions
@@ -1150,12 +1150,12 @@ distclean: clean boot/flexdll_*.o boot/flexdll_*.obj \ boot/*.cm* boot/libcamlrun.a boot/libcamlrun.lib boot/ocamlc.opt rm -f Makefile.config Makefile.build_config - rm -f runtime/caml/m.h runtime/caml/s.h rm -rf autom4te.cache flexdll-sources rm -f config.log config.status libtool rm -f tools/eventlog_metadata rm -f tools/*.bak rm -f testsuite/_log* + $(MAKE) -C runtime distclean $(MAKE) -C stdlib distclean include .depend diff --git a/build-aux/ocaml_version.m4 b/build-aux/ocaml_version.m4 index 2ed381ef34..04915ae6e9 100644 --- a/build-aux/ocaml_version.m4 +++ b/build-aux/ocaml_version.m4 @@ -29,6 +29,8 @@ m4_define([OCAML__VERSION_MAJOR], [4]) m4_define([OCAML__VERSION_MINOR], [14]) m4_define([OCAML__VERSION_PATCHLEVEL], [0]) +# Note that the OCAML__VERSION_EXTRA string defined below is always empty +# for officially-released versions of OCaml. m4_define([OCAML__VERSION_EXTRA], [dev0-2021-06-03]) # The OCAML__VERSION_EXTRA_PREFIX macro defined below should be a @@ -67,3 +69,12 @@ m4_syscmd([cat > VERSION << END_OF_VERSION_FILE # The version string must be in the format described in stdlib/sys.mli END_OF_VERSION_FILE ]) + +# Other variants of the version needed here and there in the compiler + +m4_define([OCAML__VERSION_NUMBER], + [m4_format( + [%d%02d%02d], + OCAML__VERSION_MAJOR, + OCAML__VERSION_MINOR, + OCAML__VERSION_PATCHLEVEL)]) @@ -2959,6 +2959,22 @@ ac_config_headers="$ac_config_headers runtime/caml/m.h" ac_config_headers="$ac_config_headers runtime/caml/s.h" +ac_config_headers="$ac_config_headers runtime/caml/version.h" + + +# Definitions related to the version of OCaml +$as_echo "#define OCAML_VERSION_MAJOR 4" >>confdefs.h + +$as_echo "#define OCAML_VERSION_MINOR 14" >>confdefs.h + +$as_echo "#define OCAML_VERSION_PATCHLEVEL 0" >>confdefs.h + +$as_echo "#define OCAML_VERSION_ADDITIONAL \"dev0-2021-06-03\"" >>confdefs.h + +$as_echo "#define OCAML_VERSION 41400" >>confdefs.h + +$as_echo "#define OCAML_VERSION_STRING \"4.14.0+dev0-2021-06-03\"" >>confdefs.h + # Checks for system types @@ -18823,6 +18839,7 @@ do "tools/eventlog_metadata") CONFIG_FILES="$CONFIG_FILES tools/eventlog_metadata" ;; "runtime/caml/m.h") CONFIG_HEADERS="$CONFIG_HEADERS runtime/caml/m.h" ;; "runtime/caml/s.h") CONFIG_HEADERS="$CONFIG_HEADERS runtime/caml/s.h" ;; + "runtime/caml/version.h") CONFIG_HEADERS="$CONFIG_HEADERS runtime/caml/version.h" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac index 76ae5b7a6a..fb2f208408 100644 --- a/configure.ac +++ b/configure.ac @@ -179,6 +179,16 @@ AC_CONFIG_FILES([stdlib/sys.ml]) AC_CONFIG_FILES([tools/eventlog_metadata]) AC_CONFIG_HEADERS([runtime/caml/m.h]) AC_CONFIG_HEADERS([runtime/caml/s.h]) +AC_CONFIG_HEADERS([runtime/caml/version.h]) + +# Definitions related to the version of OCaml +AC_DEFINE([OCAML_VERSION_MAJOR], [OCAML__VERSION_MAJOR]) +AC_DEFINE([OCAML_VERSION_MINOR], [OCAML__VERSION_MINOR]) +AC_DEFINE([OCAML_VERSION_PATCHLEVEL], [OCAML__VERSION_PATCHLEVEL]) +m4_if([OCAML__VERSION_EXTRA],[], [], + AC_DEFINE([OCAML_VERSION_ADDITIONAL], ["][OCAML__VERSION_EXTRA]["])) +AC_DEFINE([OCAML_VERSION], [OCAML__VERSION_NUMBER]) +AC_DEFINE([OCAML_VERSION_STRING], ["][OCAML__VERSION]["]) # Checks for system types diff --git a/runtime/Makefile b/runtime/Makefile index 3e40bdc6e9..f5c08d8798 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -37,8 +37,11 @@ NATIVE_C_SOURCES := $(addsuffix .c, \ dynlink clambda_checks afl bigarray \ memprof domain skiplist codefrag) -GENERATED_HEADERS := caml/opnames.h caml/version.h caml/jumptbl.h build_config.h -CONFIG_HEADERS := caml/m.h caml/s.h +# Header files generated by configure +CONFIGURED_HEADERS := caml/m.h caml/s.h caml/version.h + +# Header files generated by make +BUILT_HEADERS := caml/opnames.h caml/jumptbl.h build_config.h ifeq "$(TOOLCHAIN)" "msvc" ASM_EXT := asm @@ -176,12 +179,13 @@ clean: rm -f *.o *.obj *.a *.lib *.so *.dll ld.conf rm -f ocamlrun ocamlrund ocamlruni ocamlruns sak rm -f ocamlrun.exe ocamlrund.exe ocamlruni.exe ocamlruns.exe sak.exe - rm -f primitives primitives.new prims.c $(GENERATED_HEADERS) + rm -f primitives primitives.new prims.c $(BUILT_HEADERS) rm -f domain_state*.inc rm -rf $(DEPDIR) .PHONY: distclean distclean: clean + rm -f $(CONFIGURED_HEADERS) # Generated non-object files @@ -239,10 +243,6 @@ caml/jumptbl.h : caml/instruct.h tr -d '\r' < $< | \ sed -n -e '/^ /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \ -e '/^}/q' > $@ - -caml/version.h : $(ROOTDIR)/tools/make-version-header.sh $(ROOTDIR)/VERSION - $^ > $@ - # These are provided as a temporary shim to allow cross-compilation systems # to supply a host C compiler and different flags and a linking macro. SAK_CC ?= $(CC) @@ -341,18 +341,18 @@ define COMPILE_C_FILE ifneq "$(COMPUTE_DEPS)" "false" ifneq "$(1)" "%" # -MG would ensure that the dependencies are generated even if the files listed -# in $$(GENERATED_HEADERS) haven't been assembled yet. However, this goes subtly +# in $$(BUILT_HEADERS) haven't been assembled yet. However, this goes subtly # wrong if the user has the headers installed, as gcc will pick up a dependency # on those instead and the local ones will not be generated. For this reason, we -# don't use -MG and instead include $(GENERATED_HEADERS) in the order only +# don't use -MG and instead include $(BUILT_HEADERS) in the order only # dependencies to ensure that they exist before dependencies are computed. -$(DEPDIR)/$(1).$(D): %.c | $(DEPDIR) $(GENERATED_HEADERS) +$(DEPDIR)/$(1).$(D): %.c | $(DEPDIR) $(BUILT_HEADERS) $$(DEP_CC) $$(OC_CPPFLAGS) $$(CPPFLAGS) $$< -MT \ '$$*$(subst %,,$(1)).$(O)' -MF $$@ endif # ifneq "$(1)" "%" $(1).$(O): $(2).c else -$(1).$(O): $(2).c $(CONFIG_HEADERS) $(GENERATED_HEADERS) $(RUNTIME_HEADERS) +$(1).$(O): $(2).c $(CONFIGURED_HEADERS) $(BUILT_HEADERS) $(RUNTIME_HEADERS) endif # ifneq "$(COMPUTE_DEPS)" "false" $$(CC) -c $$(OC_CFLAGS) $$(CFLAGS) $$(OC_CPPFLAGS) $$(CPPFLAGS) \ $$(OUTPUTOBJ)$$@ $$< diff --git a/runtime/caml/version.h.in b/runtime/caml/version.h.in new file mode 100644 index 0000000000..a353f10ee0 --- /dev/null +++ b/runtime/caml/version.h.in @@ -0,0 +1,6 @@ +#undef OCAML_VERSION_MAJOR +#undef OCAML_VERSION_MINOR +#undef OCAML_VERSION_PATCHLEVEL +#undef OCAML_VERSION_ADDITIONAL +#undef OCAML_VERSION +#undef OCAML_VERSION_STRING diff --git a/tools/make-version-header.sh b/tools/make-version-header.sh deleted file mode 100755 index b91fba6c2d..0000000000 --- a/tools/make-version-header.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -#************************************************************************** -#* * -#* OCaml * -#* * -#* Damien Doligez, projet Gallium, INRIA Rocquencourt * -#* * -#* Copyright 2003 Institut National de Recherche en Informatique et * -#* en Automatique. * -#* * -#* All rights reserved. As an exception to the licensing rules of * -#* OCaml, this file is freely redistributable, modified or not, * -#* without constraints. * -#* * -#************************************************************************** - -# This script extracts the components from an OCaml version number -# and provides them as C defines: -# OCAML_VERSION_MAJOR: the major version number -# OCAML_VERSION_MAJOR: the minor version number -# OCAML_VERSION_PATCHLEVEL: the patchlevel number if present, or 0 if absent -# OCAML_VERSION_ADDITIONAL: this is defined only if the additional-info -# field is present, and is a string that contains that field. -# Note that additional-info is always absent in officially-released -# versions of OCaml. - -# usage: -# make-version-header.sh [version-file] -# The argument is the VERSION file from the OCaml sources. -# If the argument is not given, the version number from "ocamlc -v" will -# be used. - -case $# in - 0) version="`ocamlc -v | tr -d '\r' | sed -n -e 's/.*version //p'`";; - 1) version="`sed -e 1q "$1" | tr -d '\r'`";; - *) echo "usage: make-version-header.sh [version-file]" >&2 - exit 2;; -esac - -major="`echo "$version" | sed -n -e '1s/^\([0-9]*\)\..*/\1/p'`" -minor="`echo "$version" | sed -n -e '1s/^[0-9]*\.0*\([0-9]*\).*/\1/p'`" -patchlvl="`echo "$version" | sed -n -e '1s/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/p'`" -suffix="`echo "$version" | sed -n -e '1s/^[^+~]*[+~]\(.*\)/\1/p'`" - -echo "#define OCAML_VERSION_MAJOR $major" -printf '#define OCAML_VERSION_MINOR %d\n' "$minor" -case $patchlvl in "") patchlvl=0;; esac -echo "#define OCAML_VERSION_PATCHLEVEL $patchlvl" -case "$suffix" in - "") echo "#undef OCAML_VERSION_ADDITIONAL";; - *) echo "#define OCAML_VERSION_ADDITIONAL \"$suffix\"";; -esac -printf '#define OCAML_VERSION %d%02d%02d\n' "$major" "$minor" "$patchlvl" -echo "#define OCAML_VERSION_STRING \"$version\"" |