From ff4822cf0563776137d87df914cbe7a9e557a81c Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Wed, 12 Aug 2020 16:53:53 -0600 Subject: [PATCH 1/3] build: allow for applets to be customized --- Makefile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6762eec..bf50999 100644 --- a/Makefile +++ b/Makefile @@ -47,11 +47,21 @@ MULTICALL_SRC = \ MULTICALL_OBJ = ${MULTICALL_SRC:.c=.o} MULTICALL = ifupdown +CONFIG_IFQUERY ?= Y IFQUERY_SRC = cmd/ifquery.c -IFQUERY_OBJ = ${IFQUERY_SRC:.c=.o} +MULTICALL_${CONFIG_IFQUERY}_OBJ += ${IFQUERY_SRC:.c=.o} +CMDS_${CONFIG_IFQUERY} += ifquery +CPPFLAGS_${CONFIG_IFQUERY} += -DCONFIG_IFQUERY +CONFIG_IFUPDOWN ?= Y IFUPDOWN_SRC = cmd/ifupdown.c -IFUPDOWN_OBJ = ${IFUPDOWN_SRC:.c=.o} +MULTICALL_${CONFIG_IFUPDOWN}_OBJ += ${IFUPDOWN_SRC:.c=.o} +CMDS_${CONFIG_IFUPDOWN} += ifup ifdown +CPPFLAGS_${CONFIG_IFUPDOWN} += -DCONFIG_IFUPDOWN + +MULTICALL_OBJ += ${MULTICALL_Y_OBJ} +CMDS += ${CMDS_Y} +CPPFLAGS += ${CPPFLAGS_Y} EXECUTOR_SCRIPTS_CORE ?= \ dhcp \ @@ -68,8 +78,6 @@ EXECUTOR_SCRIPTS_STUB ?= CMD_OBJ = ${MULTICALL_OBJ} ${IFQUERY_OBJ} ${IFUPDOWN_OBJ} -CMDS = ifup ifdown ifquery - TARGET_LIBS = ${LIBIFUPDOWN_LIB} LIBS += ${TARGET_LIBS} ${LIBBSD_LIBS} From b30e0223d03f989c2625633f5d91a707162a9d83 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Wed, 12 Aug 2020 16:56:51 -0600 Subject: [PATCH 2/3] multicall: only enable applets actually compiled in --- cmd/multicall.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/multicall.c b/cmd/multicall.c index ccb7688..8f18f81 100644 --- a/cmd/multicall.c +++ b/cmd/multicall.c @@ -23,16 +23,28 @@ char *argv0; +#ifdef CONFIG_IFQUERY extern struct if_applet ifquery_applet; +#endif + +#ifdef CONFIG_IFUPDOWN extern struct if_applet ifup_applet; extern struct if_applet ifdown_applet; +#endif + struct if_applet ifupdown_applet; const struct if_applet *self_applet = NULL; struct if_applet *applet_table[] = { +#ifdef CONFIG_IFUPDOWN &ifdown_applet, +#endif +#ifdef CONFIG_IFQUERY &ifquery_applet, +#endif +#ifdef CONFIG_IFUPDOWN &ifup_applet, +#endif &ifupdown_applet, }; From 196c000161c0118715d473c8a4fafdb0fd15fa64 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Wed, 12 Aug 2020 17:09:14 -0600 Subject: [PATCH 3/3] build: further cleanup --- Makefile | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index bf50999..91aee84 100644 --- a/Makefile +++ b/Makefile @@ -47,18 +47,21 @@ MULTICALL_SRC = \ MULTICALL_OBJ = ${MULTICALL_SRC:.c=.o} MULTICALL = ifupdown -CONFIG_IFQUERY ?= Y -IFQUERY_SRC = cmd/ifquery.c -MULTICALL_${CONFIG_IFQUERY}_OBJ += ${IFQUERY_SRC:.c=.o} -CMDS_${CONFIG_IFQUERY} += ifquery -CPPFLAGS_${CONFIG_IFQUERY} += -DCONFIG_IFQUERY - +# enable ifup/ifdown applets (+16 KB) CONFIG_IFUPDOWN ?= Y IFUPDOWN_SRC = cmd/ifupdown.c MULTICALL_${CONFIG_IFUPDOWN}_OBJ += ${IFUPDOWN_SRC:.c=.o} CMDS_${CONFIG_IFUPDOWN} += ifup ifdown CPPFLAGS_${CONFIG_IFUPDOWN} += -DCONFIG_IFUPDOWN +# enable ifquery applet (+4 KB) +# [+20 KB without ifup/ifdown] +CONFIG_IFQUERY ?= Y +IFQUERY_SRC = cmd/ifquery.c +MULTICALL_${CONFIG_IFQUERY}_OBJ += ${IFQUERY_SRC:.c=.o} +CMDS_${CONFIG_IFQUERY} += ifquery +CPPFLAGS_${CONFIG_IFQUERY} += -DCONFIG_IFQUERY + MULTICALL_OBJ += ${MULTICALL_Y_OBJ} CMDS += ${CMDS_Y} CPPFLAGS += ${CPPFLAGS_Y} @@ -76,8 +79,6 @@ EXECUTOR_SCRIPTS ?= ${EXECUTOR_SCRIPTS_CORE} ${EXECUTOR_SCRIPTS_OPT} EXECUTOR_SCRIPTS_STUB ?= -CMD_OBJ = ${MULTICALL_OBJ} ${IFQUERY_OBJ} ${IFUPDOWN_OBJ} - TARGET_LIBS = ${LIBIFUPDOWN_LIB} LIBS += ${TARGET_LIBS} ${LIBBSD_LIBS} @@ -86,14 +87,14 @@ all: ${MULTICALL} ${CMDS} ${CMDS}: ${MULTICALL} ln -sf ifupdown $@ -${MULTICALL}: ${TARGET_LIBS} ${CMD_OBJ} - ${CC} -o $@ ${CMD_OBJ} ${LIBS} +${MULTICALL}: ${TARGET_LIBS} ${MULTICALL_OBJ} + ${CC} -o $@ ${MULTICALL_OBJ} ${LIBS} ${LIBIFUPDOWN_LIB}: ${LIBIFUPDOWN_OBJ} ${AR} -rcs $@ ${LIBIFUPDOWN_OBJ} clean: - rm -f ${LIBIFUPDOWN_OBJ} ${CMD_OBJ} + rm -f ${LIBIFUPDOWN_OBJ} ${MULTICALL_OBJ} rm -f ${LIBIFUPDOWN_LIB} rm -f ${CMDS} ${MULTICALL} rm -f ${MANPAGES}