Commit ab814d63 authored by Andreas Henriksson's avatar Andreas Henriksson Committed by Stephen Hemminger

iproute2: add option to build m_xt as a tc module (v3)

This will build the xt module (action ipt) of tc as a
shared object that is linked at runtime by tc if used,
rather then built into tc.

This is similar to how the atm qdisc support
is handled (q_atm.so).
Signed-off-by: default avatarAndreas Henriksson <andreas@xxxxxxxx>
parent edaaa11e
...@@ -43,19 +43,20 @@ TCMODULES += em_cmp.o ...@@ -43,19 +43,20 @@ TCMODULES += em_cmp.o
TCMODULES += em_u32.o TCMODULES += em_u32.o
TCMODULES += em_meta.o TCMODULES += em_meta.o
TCSO :=
ifeq ($(TC_CONFIG_ATM),y)
TCSO += q_atm.so
endif
ifeq ($(TC_CONFIG_XT),y) ifeq ($(TC_CONFIG_XT),y)
TCMODULES += m_xt.o TCSO += m_xt.so
LDLIBS += -lxtables
else else
ifeq ($(TC_CONFIG_XT_OLD),y) ifeq ($(TC_CONFIG_XT_OLD),y)
TCMODULES += m_xt_old.o TCSO += m_xt_old.so
LDLIBS += -lxtables
else else
ifeq ($(TC_CONFIG_XT_OLD_H),y) ifeq ($(TC_CONFIG_XT_OLD_H),y)
CFLAGS += -DTC_CONFIG_XT_H CFLAGS += -DTC_CONFIG_XT_H
TCMODULES += m_xt_old.o TCSO += m_xt_old.so
LDLIBS += -lxtables
else else
TCMODULES += m_ipt.o TCMODULES += m_ipt.o
endif endif
...@@ -81,14 +82,11 @@ ifneq ($(IPT_LIB_DIR),) ...@@ -81,14 +82,11 @@ ifneq ($(IPT_LIB_DIR),)
CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\" CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\"
endif endif
TCSO :=
ifeq ($(TC_CONFIG_ATM),y)
TCSO += q_atm.so
endif
YACC := bison YACC := bison
LEX := flex LEX := flex
MODDESTDIR := $(DESTDIR)$(patsubst /usr%,%,$(LIBDIR))/tc
%.so: %.c %.so: %.c
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic $< -o $@ $(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic $< -o $@
...@@ -101,11 +99,18 @@ libtc.a: $(TCLIB) ...@@ -101,11 +99,18 @@ libtc.a: $(TCLIB)
$(AR) rcs $@ $(TCLIB) $(AR) rcs $@ $(TCLIB)
install: all install: all
mkdir -p $(DESTDIR)$(LIBDIR)/tc echo mkdir -p $(MODDESTDIR)
install -m 0755 tc $(DESTDIR)$(SBINDIR) echo install -m 0755 tc $(DESTDIR)$(SBINDIR)
for i in $(TCSO); \ for i in $(TCSO); \
do install -m 755 $$i $(DESTDIR)$(LIBDIR)/tc; \ do echo install -m 755 $$i $(MODDESTDIR); \
done done
if [ ! -f $(MODDESTDIR)/m_ipt.so ]; then \
if [ -f $(MODDESTDIR)/m_xt.so ]; \
then ln -s m_xt.so $(MODDESTDIR)/m_ipt.so ; \
elif [ -f $(MODDESTDIR)/m_xt_old.so ]; \
then ln -s m_xt_old.so $(MODDESTDIR)/m_ipt.so ; \
fi; \
fi
clean: clean:
rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.yacc.h; \ rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.yacc.h; \
...@@ -114,6 +119,12 @@ clean: ...@@ -114,6 +119,12 @@ clean:
q_atm.so: q_atm.c q_atm.so: q_atm.c
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm $(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm
m_xt.so: m_xt.c
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o m_xt.so m_xt.c -lxtables
m_xt_old.so: m_xt_old.c
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o m_xt_old.so m_xt_old.c -lxtables
%.yacc.c: %.y %.yacc.c: %.y
$(YACC) $(YACCFLAGS) -o $@ $< $(YACC) $(YACCFLAGS) -o $@ $<
......
...@@ -98,7 +98,7 @@ restart_s: ...@@ -98,7 +98,7 @@ restart_s:
return a; return a;
} }
snprintf(buf, sizeof(buf), "m_%s.so", str); snprintf(buf, sizeof(buf), "%s/m_%s.so", get_tc_lib(), str);
dlh = dlopen(buf, RTLD_LAZY); dlh = dlopen(buf, RTLD_LAZY);
if (dlh == NULL) { if (dlh == NULL) {
dlh = aBODY; dlh = aBODY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment