Merge pull request #22 from ifupdown-ng/feature/configurable-applets

build: configurable applets
This commit is contained in:
Ariadne Conill 2020-08-12 22:39:38 -06:00 committed by GitHub
commit 0999347dab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 11 deletions

View file

@ -47,11 +47,24 @@ MULTICALL_SRC = \
MULTICALL_OBJ = ${MULTICALL_SRC:.c=.o}
MULTICALL = ifupdown
IFQUERY_SRC = cmd/ifquery.c
IFQUERY_OBJ = ${IFQUERY_SRC:.c=.o}
# enable ifup/ifdown applets (+16 KB)
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
# 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}
EXECUTOR_SCRIPTS_CORE ?= \
dhcp \
@ -66,10 +79,6 @@ EXECUTOR_SCRIPTS ?= ${EXECUTOR_SCRIPTS_CORE} ${EXECUTOR_SCRIPTS_OPT}
EXECUTOR_SCRIPTS_STUB ?=
CMD_OBJ = ${MULTICALL_OBJ} ${IFQUERY_OBJ} ${IFUPDOWN_OBJ}
CMDS = ifup ifdown ifquery
TARGET_LIBS = ${LIBIFUPDOWN_LIB}
LIBS += ${TARGET_LIBS} ${LIBBSD_LIBS}
@ -78,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}

View file

@ -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,
};