]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: propagate DEPENDENCIES to libs in single binary mode
authorPádraig Brady <P@draigBrady.com>
Sun, 14 Mar 2021 22:43:42 +0000 (22:43 +0000)
committerPádraig Brady <P@draigBrady.com>
Sun, 14 Mar 2021 23:45:46 +0000 (23:45 +0000)
build-aux/gen-single-binary.sh (override_single): A new function
to refactor the existing mappings for dir, vdir, and arch.
This function now also sets the DEPENDENCIES variable so that these
dependencies can be maintained later in the script, where
we now propagate the automake generated $(src_$cmd_DEPENDENCIES)
to our equivalent src_libsinglebin_$cmd_a_DEPENDENCIES.
This will ensure that any required libs are built,
which we require in a following change to cksum that
builds part of it as a separate library.

build-aux/gen-single-binary.sh

index 4e07cfdaa38348dfd0b1a11b171c2d314bd08ea3..657061535517908b7ad77b809c9a329eee79f9e7 100755 (executable)
@@ -58,19 +58,19 @@ done < $LOCAL_MK
 me=`echo "$0" | sed 's,.*/,,'`
 echo "## Automatically generated by $me.  DO NOT EDIT BY HAND!"
 
-# Override the sources for dir and vdir. We use a smaller version of dir and
-# vdir that relies on the ls main.
-src_dir_SOURCES="src/coreutils-dir.c"
-src_dir_LDADD="$src_dir_LDADD src/libsinglebin_ls.a"
-echo src_libsinglebin_dir_a_DEPENDENCIES = src/libsinglebin_ls.a
-src_vdir_SOURCES="src/coreutils-vdir.c"
-src_vdir_LDADD="$src_vdir_LDADD src/libsinglebin_ls.a"
-echo src_libsinglebin_vdir_a_DEPENDENCIES = src/libsinglebin_ls.a
-
-# Override the sources for arch likewise, using the main from uname.
-src_arch_SOURCES="src/coreutils-arch.c"
-src_arch_LDADD="$src_arch_LDADD src/libsinglebin_uname.a"
-echo src_libsinglebin_arch_a_DEPENDENCIES = src/libsinglebin_uname.a
+# Override the sources for some tools, to use smaller variants
+override_single() {
+  from="$1"; to="$2";
+
+  eval "src_${from}_SOURCES='src/coreutils-${from}.c'"
+  eval "src_from_LDADD=\$src_${from}_LDADD"
+  eval "src_${from}_LDADD='$src_from_LDADD src/libsinglebin_${to}.a'"
+  eval "src_libsinglebin_${from}_a_DEPENDENCIES='src/libsinglebin_${to}.a'"
+  echo "src_libsinglebin_${from}_a_DEPENDENCIES = src/libsinglebin_${to}.a"
+}
+override_single dir ls
+override_single vdir ls
+override_single arch uname
 
 for cmd in $ALL_PROGRAMS; do
   echo "# Command $cmd"
@@ -88,6 +88,13 @@ for cmd in $ALL_PROGRAMS; do
     echo "${base}_ldadd = $value"
   fi
 
+  # DEPENDENCIES
+  var=src_libsinglebin_${cmd}_a_DEPENDENCIES
+  eval "value=\$$var"
+  if [ "x$value" = "x" ]; then
+    echo "$var = \$(src_${cmd}_DEPENDENCIES)"
+  fi
+
   # CFLAGS
   # Hack any other program defining a main() replacing its main by
   # single_binary_main_$PROGRAM_NAME.