File: bump-magic-numbers

package info (click to toggle)
ocaml 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,372 kB
  • sloc: ml: 370,196; ansic: 52,820; sh: 27,419; asm: 5,462; makefile: 3,684; python: 974; awk: 278; javascript: 273; perl: 59; fortran: 21; cs: 9
file content (68 lines) | stat: -rwxr-xr-x 3,127 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
#**************************************************************************
#*                                                                        *
#*                                 OCaml                                  *
#*                                                                        *
#*                   Sebastien Hinderer, Tarides, Paris                   *
#*                                                                        *
#*   Copyright 2023 Institut National de Recherche en Informatique et     *
#*     en Automatique.                                                    *
#*                                                                        *
#*   All rights reserved.  This file is distributed under the terms of    *
#*   the GNU Lesser General Public License version 2.1, with the          *
#*   special exception on linking described in the file LICENSE.          *
#*                                                                        *
#**************************************************************************

# Bump magic numbers of the OCaml compiler
# The script takes only one argument, the version part of the magic numbers
# This version is a 3-digits string, e.g. 034
# The script makes sure all the necessary files are updated and fails
# if a file that it needs to update does not exist, leaving the repository
# in a partially updated (likely inconsistent) state.

# Also, the script updates both build-aux/ocaml_version.m4 (whose update
# is intended to be committed) and a few other *generated* files which are
# ignored by git but which need to be updated here so that the script
# can be used as part of the bootstrap procedure.
# So the update of build-aux/ocaml_version.m4 (as well as the one this
# implies to configure) are not strictly speaking needed for the
# on-going bootstrap, but rather for future builds. The update of
# generated files, in contrast, *is* required by the on-going bootstrap.

# Fail on error
set -e

if [ ${#1} != 3 ]; then
  echo 'Version number must be 3 bytes' +  exit 2
fi

new_num=$1

# Bump magic numbers in runtime/caml/exec.h

sed -e s/'define MAGIC_NUMBER_VERSION "..."'/"define MAGIC_NUMBER_VERSION \"$new_num\""/ \
  runtime/caml/exec.h > runtime/caml/exec.h.tmp
mv runtime/caml/exec.h.tmp runtime/caml/exec.h

# Bump magic numbers in utils/config.common.ml

sed -e s/'...|magic}'/"$new_num|magic}"/ \
  utils/config.common.ml > utils/config.common.ml.tmp
mv utils/config.common.ml.tmp utils/config.common.ml

# Bump magic numbers in otherlibs/dynlink/dynlink_config.ml

sed -e s/'...|magic}'/"$new_num|magic}"/ \
  otherlibs/dynlink/dynlink_config.ml > otherlibs/dynlink/dynlink_config.ml.tmp
mv otherlibs/dynlink/dynlink_config.ml.tmp otherlibs/dynlink/dynlink_config.ml

# Bump magic numbers in build-aux/ocaml_version.m4

sed -e s/'m4_define(\[MAGIC_NUMBER__VERSION\], \[...\])'/"m4_define([MAGIC_NUMBER__VERSION], [$new_num])"/ \
  build-aux/ocaml_version.m4 > build-aux/ocaml_version.m4.tmp
mv build-aux/ocaml_version.m4.tmp build-aux/ocaml_version.m4

# Regenerate the configure script

tools/autogen