From 7965f1b455144220c137bcb25c4967283a6b7ff3 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 16 Feb 2022 18:12:21 +0100 Subject: improve the build system --- write_makefile.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'write_makefile.sh') diff --git a/write_makefile.sh b/write_makefile.sh index 4011fe8..c9b107b 100755 --- a/write_makefile.sh +++ b/write_makefile.sh @@ -13,18 +13,24 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # CC0 1.0 Universal License for more details. +set -e + if [ ! -e record.conf ]; then printf "Record of configuration 'record.conf' does not exist.\n" >&2 exit 1 -elif [ "$(head -n 1 record.conf | cut -c -9)x" != "srcdir = x" ]; then +elif ! grep '^srcdir = ' record.conf >/dev/null 2>&1; then printf "Record of configuration 'record.conf' is invalid.\n" >&2 - exit 2 + exit 1 fi -SRCDIR="$(head -n 1 record.conf | cut -c 10-)" -. "$SRCDIR"/shell_utils.sh -VERSION=$(get_json_key version "$(cat "$SRCDIR"/manifest.json)") +SRCDIR="$(grep '^srcdir = ' record.conf)" +SRCDIR="${SRCDIR#'srcdir = '}" + +DEFAULT_TARGET="$(grep '^default_target = ' record.conf)" +DEFAULT_TARGET="${DEFAULT_TARGET#'default_target = '}" + +eval VERSION=$(cat "$SRCDIR/version") -sed '/^# Configuration goes here$/r record.conf +sed '/^# Configuration gets included here by write_makefile\.sh$/r record.conf s|<>|'"$SRCDIR"'| -s/<>/'$VERSION/ < "$SRCDIR"/Makefile.in > Makefile +s/<>/'"$VERSION"/ < "$SRCDIR"/Makefile.in > Makefile -- cgit v1.2.3