public inbox for debugedit@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: debugedit@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [COMMITTED] find-debuginfo: Generate and install as top-level build file.
Date: Wed, 19 May 2021 13:49:53 +0200	[thread overview]
Message-ID: <20210519114953.6772-1-mark@klomp.org> (raw)

find-debuginfo relied on lib_rpm_dir to find other debugedit tools.
But the script itself was generated at configure time in a subdir.
This makes testing the (non-installed) build slightly inconvenient.
Add a automake rule to generate find-debuginfo at build time, instead
of configure time, in the top-level builddir next to the other tools.

	* .gitignore: Move scripts/find-debuginfo to find-debuginfo.
	* configure.ac: Explicitly check we have SED.
	* Makefile.am (bin_SCRIPTS): Drop subdir scripts.
	(CLEANFILES): New.
	(do_subst): New.
	(find-debuginfo): New generate using do_subst.
	(find-debuginfo.1): Adjust location and protect against
	parallel builds.
	(EXTRA_DIST): Add .in suffix to scripts/find-debuginfo.
	* scripts/find-debuginfo.in (lib_rpm_dir): Rename to...
	(install_dir): ...this.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 .gitignore                |  2 +-
 Makefile.am               | 29 +++++++++++++++++++++--------
 configure.ac              |  2 +-
 scripts/find-debuginfo.in | 12 +++++++-----
 4 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/.gitignore b/.gitignore
index ae33e64..9868abc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,7 +31,7 @@ debugedit.1
 sepdebugcrcfix
 sepdebugcrcfix.1
 
-scripts/find-debuginfo
+find-debuginfo
 find-debuginfo.1
 
 atconfig
diff --git a/Makefile.am b/Makefile.am
index 645a502..98b2f20 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,8 +24,19 @@ AM_CFLAGS = -Wall
 # All our programs
 bin_PROGRAMS = debugedit sepdebugcrcfix
 
-# Install find-debuginfo in $(bindir) and distribute it.
-bin_SCRIPTS = $(top_srcdir)/scripts/find-debuginfo
+# Install find-debuginfo in $(bindir)
+bin_SCRIPTS = find-debuginfo
+
+# All our scripts are generated, so need to be explicitly cleaned
+CLEANFILES = $(bin_SCRIPTS)
+
+# Some standard substitutions for scripts
+do_subst = ($(SED) -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
+		   -e 's,[@]VERSION[@],$(VERSION),g')
+
+find-debuginfo: $(top_srcdir)/scripts/find-debuginfo.in Makefile
+	$(do_subst) < "$(top_srcdir)/scripts/$@.in" > "$@"
+	chmod +x "$@"
 
 debugedit_SOURCES = tools/debugedit.c \
 		    tools/hashtab.c \
@@ -63,15 +74,17 @@ sepdebugcrcfix.1: tools/sepdebugcrcfix.c configure.ac sepdebugcrcfix$(EXEEXT)
 	  * ) : ;; \
 	esac
 
-# Since the script isn't generated this doesn't need any special casing.
-find-debuginfo.1: $(top_srcdir)/scripts/find-debuginfo
-	$(HELP2MAN) -N --output=$@ \
-	  --name='finds debuginfo and processes it' \
-	  $(top_srcdir)/scripts/find-debuginfo
+find-debuginfo.1: $(top_srcdir)/scripts/find-debuginfo.in configure.ac find-debuginfo
+	@case '$?' in \
+	  *$<* | *configure.ac* ) $(HELP2MAN) -N --output=$@ \
+		--name='finds debuginfo and processes it' \
+		./find-debuginfo ;;\
+	  * ) : ;; \
+	esac
 
 noinst_HEADERS= tools/ansidecl.h \
 		tools/hashtab.h \
 		tools/md5.h \
 		tools/sha1.h
 
-EXTRA_DIST = README COPYING COPYING3 COPYING.LIB scripts/find-debuginfo
+EXTRA_DIST = README COPYING COPYING3 COPYING.LIB scripts/find-debuginfo.in
diff --git a/configure.ac b/configure.ac
index d1d8969..65cec5e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,7 @@ AC_USE_SYSTEM_EXTENSIONS
 
 # Checks for programs.
 AC_PROG_AWK
+AC_PROG_SED
 AC_PROG_CC_C99
 AC_PROG_LN_S
 AC_CHECK_TOOL([LD], [ld])
@@ -100,5 +101,4 @@ AC_SUBST([GZ_NONE_FLAG])
 
 # And generate the output files.
 AC_CONFIG_FILES([Makefile])
-AC_CONFIG_FILES([scripts/find-debuginfo], [chmod +x scripts/find-debuginfo])
 AC_OUTPUT
diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
index 82fac25..828fd09 100755
--- a/scripts/find-debuginfo.in
+++ b/scripts/find-debuginfo.in
@@ -1,6 +1,8 @@
 #!/bin/bash
-#find-debuginfo - automagically generate debug info and file list
-#for inclusion in an rpm spec file.
+
+# @PACKAGE@ @VERSION@
+# find-debuginfo - automagically generate debug info and file list
+# for inclusion in package file lists.
 
 # Copyright (C) 2002-2021 rpm and debugedit contributors
 #
@@ -97,7 +99,7 @@ EOF
 }
 
 # Figure out where we are installed so we can call other helper scripts.
-lib_rpm_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+install_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
 # With -g arg, pass it to strip on libraries or executables.
 strip_g=false
@@ -436,7 +438,7 @@ do_file()
   if [ "$no_recompute_build_id" = "true" ]; then
     no_recompute="-n"
   fi
-  id=$(${lib_rpm_dir}/debugedit -b "$debug_base_name" -d "$debug_dest_name" \
+  id=$(${install_dir}/debugedit -b "$debug_base_name" -d "$debug_dest_name" \
 			      $no_recompute -i \
 			      ${build_id_seed:+--build-id-seed="$build_id_seed"} \
 			      -l "$SOURCEFILE" "$f") || exit
@@ -594,7 +596,7 @@ if $run_dwz \
     # dwz invalidates .gnu_debuglink CRC32 in the main files.
     cat "$ELFBINSFILE" |
     (cd "$RPM_BUILD_ROOT"; \
-     tr '\n' '\0' | xargs -0 ${lib_rpm_dir}/sepdebugcrcfix usr/lib/debug)
+     tr '\n' '\0' | xargs -0 ${install_dir}/sepdebugcrcfix usr/lib/debug)
   fi
 fi
 
-- 
2.18.4


                 reply	other threads:[~2021-05-19 11:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210519114953.6772-1-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=debugedit@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).