summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile24
-rw-r--r--futility/cmd_foo.c1
-rw-r--r--futility/cmd_hey.c20
-rw-r--r--futility/futility.c19
4 files changed, 48 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index ec22984a..7ad926d8 100644
--- a/Makefile
+++ b/Makefile
@@ -451,17 +451,24 @@ SIGNING_COMMON = scripts/image_signing/common_minimal.sh
# The unified firmware utility will eventually replace all the others
FUTIL_BIN = ${BUILD}/futility/futility
+# But we still need both static (tiny) and dynamic (with openssl) versions.
+FUTIL_STATIC_BIN = ${FUTIL_BIN}_s
# These are the others it will replace.
FUTIL_OLD = $(notdir ${CGPT} ${UTIL_BINS} ${UTIL_SCRIPTS} \
${SIGNING_SCRIPTS} ${SIGNING_SCRIPTS_DEV})
-FUTIL_SRCS = \
+FUTIL_STATIC_SRCS = \
futility/futility.c \
futility/cmd_foo.c
+FUTIL_SRCS = \
+ $(FUTIL_STATIC_SRCS) \
+ futility/cmd_hey.c
+
FUTIL_LDS = futility/futility.lds
+FUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o}
FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o}
ALL_OBJS += ${FUTIL_OBJS}
@@ -701,7 +708,7 @@ ${CGPT}: LDLIBS += -luuid
${CGPT}: ${CGPT_OBJS} ${HOSTLIB}
@$(PRINTF) " LDcgpt $(subst ${BUILD}/,,$@)\n"
- ${Q}${LD} -o ${CGPT} ${CFLAGS} $^ ${LDFLAGS} ${LDLIBS}
+ ${Q}${LD} -o ${CGPT} ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
.PHONY: cgpt_install
cgpt_install: ${CGPT}
@@ -754,17 +761,21 @@ endif
# new Firmware Utility
.PHONY: futil
-futil: ${FUTIL_BIN}
+futil: ${FUTIL_STATIC_BIN} ${FUTIL_BIN}
+
+${FUTIL_STATIC_BIN}: ${FUTIL_LDS} ${FUTIL_STATIC_OBJS}
+ @$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
+ ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} -static $^ ${LDLIBS}
${FUTIL_BIN}: ${FUTIL_LDS} ${FUTIL_OBJS}
@$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
- ${Q}${LD} -o $@ ${CFLAGS} $^ ${LDFLAGS} ${LDLIBS}
+ ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $^ ${LDLIBS}
.PHONY: futil_install
futil_install: ${FUTIL_BIN}
@$(PRINTF) " INSTALL futility\n"
${Q}mkdir -p ${F_DIR}
- ${Q}${INSTALL} -t ${F_DIR} ${FUTIL_BIN}
+ ${Q}${INSTALL} -t ${F_DIR} ${FUTIL_BIN} ${FUTIL_STATIC_BIN}
${Q}for prog in ${FUTIL_OLD}; do \
ln -sf futility "${F_DIR}/$$prog"; done
@@ -807,7 +818,7 @@ ${TESTLIB}: ${TESTLIB_OBJS}
${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
@$(PRINTF) " LD $(subst ${BUILD}/,,$@)\n"
- ${Q}${LD} -o $@ ${CFLAGS} $< ${OBJS} ${LIBS} ${LDFLAGS} ${LDLIBS}
+ ${Q}${LD} -o $@ ${CFLAGS} ${LDFLAGS} $< ${OBJS} ${LIBS} ${LDLIBS}
${BUILD}/%.o: %.c
@$(PRINTF) " CC $(subst ${BUILD}/,,$@)\n"
@@ -839,6 +850,7 @@ ${BUILD}/utility/gbb_utility: LD = ${CXX}
# Because we play some clever linker script games to add new commands without
# changing any header files, futility must be linked with ld.bfd, not gold.
${FUTIL_BIN}: LDFLAGS += -fuse-ld=bfd
+${FUTIL_STATIC_BIN}: LDFLAGS += -fuse-ld=bfd
# Some utilities need external crypto functions
${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
diff --git a/futility/cmd_foo.c b/futility/cmd_foo.c
index e02a9ffb..e008b3a0 100644
--- a/futility/cmd_foo.c
+++ b/futility/cmd_foo.c
@@ -19,4 +19,3 @@ static int do_something(int argc, char *argv[])
DECLARE_FUTIL_COMMAND(foo, do_something, "invoke a foo");
DECLARE_FUTIL_COMMAND(bar, do_something, "go to bar");
-DECLARE_FUTIL_COMMAND(hey, do_something, "shout");
diff --git a/futility/cmd_hey.c b/futility/cmd_hey.c
new file mode 100644
index 00000000..efd47d39
--- /dev/null
+++ b/futility/cmd_hey.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <stdio.h>
+
+#include "futility.h"
+
+static int do_something(int argc, char *argv[])
+{
+ int i;
+ printf("this is %s\n", __func__);
+ for (i = 0; i < argc; i++)
+ printf("argv[%d] = %s\n", i, argv[i]);
+ return 0;
+}
+
+DECLARE_FUTIL_COMMAND(hey, do_something, "shout");
diff --git a/futility/futility.c b/futility/futility.c
index 69ce57f4..54921d1a 100644
--- a/futility/futility.c
+++ b/futility/futility.c
@@ -17,6 +17,7 @@
#include "futility.h"
#define MYNAME "futility"
+#define MYNAME_S MYNAME "_s"
#ifdef OLDDIR
#define XSTR(A) STR(A)
#define STR(A) #A
@@ -65,18 +66,18 @@ static int help(int argc, char *argv[])
printf("The following commands are built-in:\n");
for (cmd = futil_cmds_start(); cmd < futil_cmds_end(); cmd++)
- printf(" %-20s %s\n",
- cmd->name, cmd->shorthelp);
-
+ printf(" %-20s %s\n", cmd->name, cmd->shorthelp);
printf("\n");
- printf("FYI, you added these args that I'm ignoring:\n");
- for (i = 0; i < argc; i++)
- printf("argv[%d] = %s\n", i, argv[i]);
+ if (argc) {
+ printf("FYI, you added these args that I'm ignoring:\n");
+ for (i = 0; i < argc; i++)
+ printf("argv[%d] = %s\n", i, argv[i]);
+ }
return 0;
}
-DECLARE_FUTIL_COMMAND(help, help, "Show a bit of help");
+DECLARE_FUTIL_COMMAND(help, help, "show a bit of help");
/******************************************************************************/
@@ -219,9 +220,9 @@ int main(int argc, char *argv[], char *envp[])
progname = argv[0];
/* Invoked directly by name */
- if (0 == strcmp(progname, MYNAME)) {
+ if (0 == strcmp(progname, MYNAME) || 0 == strcmp(progname, MYNAME_S)) {
if (argc < 2) { /* must have an argument */
- fputs(usage, stderr);
+ help(0, 0);
exit(1);
}