binutils-gdb/gdb/make-init-c
Lancelot SIX 9e8dfa0523 Use /bin/sh as shebang in gdb/make-init-c
While testing the NixOS[1] packaging for gdb-11.0.90.tar.xz, I got the
following error:

  [...]
  CXX    aarch32-tdep.o
  CXX    gdb.o
  GEN    init.c
  /nix/store/26a78ync552m8j4sbjavhvkmnqir8c9y-bash-4.4-p23/bin/bash: ./make-init-c: /usr/bin/env: bad interpreter: No such file or directory
  make[2]: *** [Makefile:1866: stamp-init] Error 126
  make[2]: *** Waiting for unfinished jobs....
  make[2]: Leaving directory '/build/gdb-11.0.90/gdb'
  make[1]: *** [Makefile:9814: all-gdb] Error 2
  make[1]: Leaving directory '/build/gdb-11.0.90'
  make: *** [Makefile:903: all] Error 2
  builder for '/nix/store/xs8my3rrc3l4kdlbpx0azh6q0v0jxphr-gdb-gdb-11.0.90.drv' failed with exit code 2
  error: build of '/nix/store/xs8my3rrc3l4kdlbpx0azh6q0v0jxphr-gdb-gdb-11.0.90.drv' failed

In the nix build environment, /usr/bin/env is not present, only /bin/sh
is.  This patch makes sure that gdb/make-init-c uses '/bin/sh' as
interpreter as this is the only one available on this platform.

I do not think this change will cause regressions on any other
configuration.

[1] https://nixos.org/

gdb/Changelog

	* make-init-c: Use /bin/sh as shebang.
2021-07-13 23:06:30 +01:00

71 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
# Copyright (C) 2013-2021 Free Software Foundation, Inc.
#
# This file is part of GDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Generate the init.c source file.
#
# Usage:
#
# ./make-init-c source-files > init.c-tmp
#
# Where SOURCE-FILES is the list of source files to extract init functions from.
#
# Formatting conventions: The name of the initialization routines must begin
# with `_initialize_`, must start in column zero, and be followed with exactly
# ` ()`. For example:
#
# void
# _initialize_foo ()
# {
# ...
# }
#
# Abort on command error.
set -e
echo "/* Do not modify this file. */"
echo "/* It is created automatically by the Makefile. */"
echo "#include \"defs.h\" /* For initialize_file_ftype. */"
echo "#include <algorithm>"
echo ""
sed -n -e 's/^\(_initialize_[a-zA-Z0-9_]*\) ()$/\1/p' "$@" | while read -r name; do
echo "extern initialize_file_ftype $name;"
done
echo ""
echo "void initialize_all_files ();"
echo "void"
echo "initialize_all_files ()"
echo "{"
echo " std::vector<initialize_file_ftype *> functions ="
echo " {"
sed -n -e 's/^\(_initialize_[a-zA-Z0-9_]*\) ()$/\1/p' "$@" | while read -r name; do
echo " $name,"
done
echo " };"
echo ""
echo " /* If GDB_REVERSE_INIT_FUNCTIONS is set (any value), reverse the"
echo " order in which initialization functions are called. This is"
echo " used by the testsuite. */"
echo " if (getenv (\"GDB_REVERSE_INIT_FUNCTIONS\") != nullptr)"
echo " std::reverse (functions.begin (), functions.end ());"
echo ""
echo " for (initialize_file_ftype *function : functions)"
echo " function ();"
echo "}"