From: Baptiste Daroussin Date: Sun, 31 May 2026 08:33:00 +0000 (+0200) Subject: Sync with latest bbuild X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=e372beab05ececc4d623c87a7b5dcc166d718c97;p=thirdparty%2Fmlmmj.git Sync with latest bbuild - Replace configure with latest bbuild version (adds write_if_changed, HAVE_DECL_* handling, --includedir, --libdir, pkgconfigdir default) - Update mk/defs.mk.in with PACKAGE_NAME and VERSION - Update mk/prog.mk and mk/common.mk to latest bbuild --- diff --git a/configure b/configure index bb8da5c2..fe174b2e 100755 --- a/configure +++ b/configure @@ -63,6 +63,26 @@ user_notice() { printf 'Notice: %s\n' "$*" } +# ================================================================== +# Write-if-changed helper +# ================================================================== +# Usage: write_if_changed target tmpfile +# Replaces target with tmpfile only if the content differs. +# Preserves timestamps on unchanged files to avoid unnecessary rebuilds. + +write_if_changed() { + _wic_target="$1" + _wic_tmpfile="$2" + _wic_msg="${3:-Creating $_wic_target}" + if [ -f "$_wic_target" ] && cmp -s "$_wic_target" "$_wic_tmpfile"; then + msg "$_wic_target is unchanged" + rm -f "$_wic_tmpfile" + else + msg "$_wic_msg" + mv "$_wic_tmpfile" "$_wic_target" + fi +} + # ================================================================== # Variable store (define / get_define) # ================================================================== @@ -176,6 +196,8 @@ Usage: configure [options] Standard options: --prefix=DIR Installation prefix [/usr/local] --exec-prefix=DIR Executable prefix [PREFIX] + --includedir=DIR Headers [PREFIX/include] + --libdir=DIR Libraries [PREFIX/lib] --bindir=DIR User executables [PREFIX/bin] --sbindir=DIR System executables [PREFIX/sbin] --mandir=DIR Man pages [PREFIX/man] @@ -224,6 +246,8 @@ apply_args() { case "$_arg" in --prefix=*) define prefix "${_arg#--prefix=}" ;; --exec-prefix=*) define exec_prefix "${_arg#--exec-prefix=}" ;; + --includedir=*) define includedir "${_arg#--includedir=}" ;; + --libdir=*) define libdir "${_arg#--libdir=}" ;; --bindir=*) define bindir "${_arg#--bindir=}" ;; --sbindir=*) define sbindir "${_arg#--sbindir=}" ;; --mandir=*) define mandir "${_arg#--mandir=}" ;; @@ -705,12 +729,12 @@ make_config_header() { _guard=$(echo "$_outfile" | tr '[:lower:]/.' '[:upper:]__' | sed 's/^_*//') _guard="_${_guard}_" - msg "Creating $_outfile" - case "$_outfile" in */*) [ -d "${_outfile%/*}" ] || mkdir -p "${_outfile%/*}" ;; esac + _mch_tmp="$_tmpdir/config_header.tmp" + { echo "/* Auto-generated by configure - do not edit */" echo "#ifndef $_guard" @@ -733,7 +757,14 @@ make_config_header() { esac done + case "$_key" in + HAVE_DECL_*) _emit="decl" ;; + esac + case "$_emit" in + decl) + echo "#define $_key $_val" + ;; bare) case "$_val" in 0) echo "/* #undef $_key */" ;; @@ -758,7 +789,9 @@ make_config_header() { echo "" echo "#endif /* $_guard */" - } > "$_outfile" + } > "$_mch_tmp" + + write_if_changed "$_outfile" "$_mch_tmp" "Creating $_outfile" } # ================================================================== @@ -793,8 +826,6 @@ make_template() { */*) [ -d "${_outfile%/*}" ] || mkdir -p "${_outfile%/*}" ;; esac - msg "Creating $_outfile from $1" - _sedscript="$_tmpdir/template.sed" : > "$_sedscript" while IFS=' ' read -r _key _val; do @@ -802,6 +833,8 @@ make_template() { printf 's|@%s@|%s|g\n' "$_key" "$_escaped_val" >> "$_sedscript" done < "$_defines" + _mt_tmp="$_tmpdir/template.tmp" + awk -v deffile="$_defines" ' BEGIN { while ((getline line < deffile) > 0) { @@ -847,7 +880,9 @@ BEGIN { { if (stack[depth] == 1) print } -' "$_infile" | sed -f "$_sedscript" > "$_outfile" +' "$_infile" | sed -f "$_sedscript" > "$_mt_tmp" + + write_if_changed "$_outfile" "$_mt_tmp" "Creating $_outfile from $1" } # ================================================================== @@ -904,12 +939,15 @@ _configure_apply() { define prefix "$_prefix" is_defined exec_prefix || define exec_prefix "$_prefix" + is_defined includedir || define includedir "$_prefix/include" + is_defined libdir || define libdir "$_prefix/lib" is_defined bindir || define bindir "$_prefix/bin" is_defined sbindir || define sbindir "$_prefix/sbin" is_defined mandir || define mandir "$_prefix/man" is_defined sysconfdir || define sysconfdir "$_prefix/etc" is_defined datarootdir || define datarootdir "$_prefix/share" is_defined datadir || define datadir "$_prefix/share" + is_defined pkgconfigdir|| define pkgconfigdir "$_prefix/libdata/pkgconfig" if [ "$_want_help" -eq 1 ]; then show_help diff --git a/mk/prog.mk b/mk/prog.mk index 63231dce..9ee23b18 100644 --- a/mk/prog.mk +++ b/mk/prog.mk @@ -4,15 +4,17 @@ PROGNAME= $(PROG)$(EXEEXT) CLEAN_FILES+= $(PROGNAME) $(OBJS) $(DEPFILES) +.PHONY: all install install-prog distclean + all: $(PROGNAME) $(PROGNAME): $(OBJS) $(CC) -o $@ $(OBJS) $(LDFLAGS) $(LOCAL_LDFLAGS) -install: $(PROGNAME) +install: install-prog + +install-prog: $(PROGNAME) install -d -m 755 $(DESTDIR)$(bindir) install -m 755 $(PROGNAME) $(DESTDIR)$(bindir)/ -check: - distclean: clean