star-build

Automation tool for project installation
git clone git://git.meso-star.fr/star-build.git
Log | Files | Refs | README | LICENSE

commit 59bb2d66691fe32722c8d06b8861e8e55ab7a4c3
parent b072f7cb73d22fc6c4585d956c355ab5c7acd183
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 10 Nov 2023 12:22:25 +0100

No more automatic detection of build script prerequisites

The prereq.sh script that was supposed to find them was buggy, and
correcting it so that it performed the right task was in fact much more
than a simple fix. This is because prerequisites have to be defined
dynamically according to the configuration. What's more, it's not easy
to determine with certainty which scripts are dotted. Overall, it seems
excessive to add this functionality, so we let the user call "make clean
&& make" to ensure that the correct Makefile is used.

Diffstat:
MMakefile | 31++++++++++---------------------
Mconfig.mk | 2+-
Mlint.mk | 1-
Dsrc/prereq.sh | 52----------------------------------------------------
4 files changed, 11 insertions(+), 75 deletions(-)

diff --git a/Makefile b/Makefile @@ -19,42 +19,31 @@ include config.mk MK = $(BUILD).mk -DEP = $(BUILD).d -install: $(MK) $(DEP) prefix +install: $(MK) prefix @prefix=$$(cat .prefix) && \ LD_LIBRARY_PATH="$${prefix}/lib:$${LD_LIBRARY_PATH}" \ PATH="$${prefix}/bin:$${PATH}" \ PKG_CONFIG_PATH="$${prefix}/lib/pkgconfig:$${PKG_CONFIG_PATH}" \ TEXINPUTS="$${prefix}/share/tex:$${TEXINPUTS}" \ - $(MAKE) -f $(DEP) -f $(MK) -f Makefile install_all + $(MAKE) -f $(MK) -f Makefile install_all -clean: $(MK) $(DEP) - @$(MAKE) -f $(DEP) -f $(MK) -f Makefile clean_all - rm -rf .prefix $(MK) $(DEP) +clean: $(MK) + @$(MAKE) -f $(MK) -f Makefile clean_all + rm -rf .prefix $(MK) -distclean: $(MK) $(DEP) - @$(MAKE) -f $(DEP) -f $(MK) -f Makefile distclean_all - rm -rf .prefix src/*.sh.d src/*.sh.mk +distclean: $(MK) + @$(MAKE) -f $(MK) -f Makefile distclean_all + rm -rf .prefix src/*.sh.mk -uninstall: $(MK) $(DEP) - @$(MAKE) -f $(DEP) -f $(MK) -f Makefile uninstall_all - -# Generate the dependencies target of the build -$(DEP): $(BUILD) src/prereq.sh - @echo "Setup $@" - @PATH="src:$${PATH}" $(SHELL) src/prereq.sh "$(MK) $(DEP)" $(BUILD) > $@ +uninstall: $(MK) + @$(MAKE) -f $(MK) -f Makefile uninstall_all # Generate the Makefile of the build $(MK): $(BUILD) src/build.sh config.mk @echo "Setup $@" @PATH="src:$${PATH}" USE_SIMD=$(USE_SIMD) $(SHELL) $(BUILD) > $@ -# Update the build timestamp to force regeneration of its Makefile when its -# prerequistes are updated -$(BUILD): - @touch $(BUILD) - prefix: @# store in .prefix the absolute prefix path @(p=$$(echo $(PREFIX)) && mkdir -p -- "$${p}" && cd -- "$${p}" && pwd) > .prefix diff --git a/config.mk b/config.mk @@ -23,7 +23,7 @@ REPO_VAPLV = https://gitlab.com/vaplv # Project to build. To see the available projects, list the shell scripts in # the src directory: -# find src/ -name "*.sh" ! -name "prereq.sh" ! -name "build.sh" | sort +# find src/ -name "*.sh" ! -name "build.sh" | sort BUILD = src/sgs.sh # Type of library to build, either SHARED or STATIC diff --git a/lint.mk b/lint.mk @@ -29,7 +29,6 @@ lint: shellcheck -o all -x -P src src/mrumtl_0.2.sh shellcheck -o all -x -P src src/noweb_2.13rc3.sh shellcheck -o all -x -P src src/polygon_0.2.sh - shellcheck -o all -x -P src src/prereq.sh shellcheck -o all -x -P src src/random123_1.14.0.sh shellcheck -o all -x -P src src/rnatm_0.1.sh shellcheck -o all -x -P src src/rngrd_0.1.sh diff --git a/src/prereq.sh b/src/prereq.sh @@ -1,52 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2023 |Méso|Star> (contact@meso-star.com) -# -# 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/>. - -set -e - -# Print the prerequisites of a shell submitted as argument. The scripts -# recursively looks for "dot" files and print their filename to standard -# output. -prereq() -{ - # The input shell is a prerequisite - printf ' %s \\\n' "$1" - - sed -n 's/^[[:space:]]\{0,\}\.[[:space:]]\{1,\}\([^[:space:]#]\)/\1/p' "$1" | \ - tr -d '"' | \ - while read -r i; do - paths=$(echo "${PATH}" | tr -s ":" " ") - - # Search for the "dot" file in PATH directories - # shellcheck disable=SC2086 - file=$(find ${paths} -name "${i}" 2> /dev/null) - if [ -z "${file}" ]; then - >&2 printf "%s: file not found\n" "${i}" - exit 1 - fi - - printf ' %s \\\n' "${file}" - prereq "${file}" - done -} - -# Print the targets and add the shell file as their first prerequisite -printf '%s: \\\n' "$1" - -# Find the "dot" files, print them out once and clean up the unnecessary -# characters on the last line, such as the backslash and the spaces that -# precede it. -prereq "$2" | sort | uniq | sed '$s/[[:space:]]\{1,\}\\$//'