]> git.ozlabs.org Git - petitboot/commitdiff
Allow host programs to be configured
authorJeremy Kerr <jk@ozlabs.org>
Tue, 5 Mar 2013 05:54:55 +0000 (13:54 +0800)
committerGeoff Levand <geoff@infradead.org>
Tue, 5 Mar 2013 14:08:20 +0000 (06:08 -0800)
Rather than hard-coding in lib/system/system.c, this change adds a set
of #defines for host programs, through the autoheader config.h

These host programs can then be set through configure:

 ./configure HOST_PROG_MOUNT=/usr/bin/mount

Because we need to define nine host programs, we add an autoconf macro
to avoid repeating the definition code.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>
configure.ac.in
lib/system/system.c

index 1f4a4199193d24b0b9dd3a1d0facc61716547991..0121579b508bb4ba406bdf669f648624773c453b 100644 (file)
@@ -163,6 +163,27 @@ AC_ARG_ENABLE(
 )
 #AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
 
+# host program paths
+AC_DEFUN([DEFINE_HOST_PROG],
+       [
+               AC_ARG_VAR([HOST_PROG_$1], [Path to "$2" on the host [default $3]])
+               if test "x$HOST_PROG_$1" = "x"; then
+                       HOST_PROG_$1="$3"
+               fi
+               AC_DEFINE_UNQUOTED(HOST_PROG_$1, ["$HOST_PROG_$1"],
+                               [Path to "$2" on the host])
+       ])
+
+DEFINE_HOST_PROG(CP, cp, [/bin/cp])
+DEFINE_HOST_PROG(KEXEC, kexec, [/sbin/kexec])
+DEFINE_HOST_PROG(MOUNT, mount, [/bin/mount])
+DEFINE_HOST_PROG(SHUTDOWN, shutdown, [/sbin/shutdown])
+DEFINE_HOST_PROG(SFTP, sftp, [/usr/bin/sftp])
+DEFINE_HOST_PROG(TFTP, tftp, [/usr/bin/tftp])
+DEFINE_HOST_PROG(UDEVADM, udevadm, [/sbin/udevadm])
+DEFINE_HOST_PROG(UMOUNT, umount, [/bin/umount])
+DEFINE_HOST_PROG(WGET, wget, [/usr/bin/wget])
+
 default_cflags="--std=gnu99 -g \
        -Wall -W -Wunused -Wstrict-prototypes -Wmissing-prototypes \
        -Wmissing-declarations -Wredundant-decls -Winline"
index 3b30f04519fe34f2c89321b4977edc678991e839..cbf6b9fc5a8b43472dc5c4ea7b823e83b196ee8a 100644 (file)
 #include "system.h"
 
 const struct pb_system_apps pb_system_apps = {
-       .prefix = PREFIX,
-       .cp = "/bin/cp",
-       .kexec = "/sbin/kexec",
-       .mount = "/bin/mount",
-       .shutdown = "/sbin/shutdown",
-       .sftp = "/usr/bin/sftp",
-       .tftp = "/usr/bin/tftp",
-       .udevadm = "/sbin/udevadm",
-       .umount = "/bin/umount",
-       .wget = "/usr/bin/wget",
+       .prefix         = PREFIX,
+       .cp             = HOST_PROG_CP,
+       .kexec          = HOST_PROG_KEXEC,
+       .mount          = HOST_PROG_MOUNT,
+       .shutdown       = HOST_PROG_SHUTDOWN,
+       .sftp           = HOST_PROG_SFTP,
+       .tftp           = HOST_PROG_TFTP,
+       .udevadm        = HOST_PROG_UDEVADM,
+       .umount         = HOST_PROG_UMOUNT,
+       .wget           = HOST_PROG_WGET,
 };
 
 int pb_mkdir_recursive(const char *dir)