1 TCOBJ= tc.o tc_qdisc.o tc_class.o tc_filter.o tc_util.o tc_monitor.o \ 2 tc_exec.o tc_bpf.o m_police.o m_estimator.o m_action.o m_ematch.o \ 3 emp_ematch.yacc.o emp_ematch.lex.o 4 5 include ../Config 6 7 ifeq ($(IP_CONFIG_SETNS),y) 8 CFLAGS += -DHAVE_SETNS 9 endif 10 11 SHARED_LIBS ?= y 12 13 TCMODULES := 14 TCMODULES += q_fifo.o 15 TCMODULES += q_sfq.o 16 TCMODULES += q_red.o 17 TCMODULES += q_prio.o 18 TCMODULES += q_tbf.o 19 TCMODULES += q_cbq.o 20 TCMODULES += q_rr.o 21 TCMODULES += q_multiq.o 22 TCMODULES += q_netem.o 23 TCMODULES += q_choke.o 24 TCMODULES += q_sfb.o 25 TCMODULES += f_rsvp.o 26 TCMODULES += f_u32.o 27 TCMODULES += f_route.o 28 TCMODULES += f_fw.o 29 TCMODULES += f_basic.o 30 TCMODULES += f_bpf.o 31 TCMODULES += f_flow.o 32 TCMODULES += f_cgroup.o 33 TCMODULES += f_flower.o 34 TCMODULES += q_dsmark.o 35 TCMODULES += q_gred.o 36 TCMODULES += f_tcindex.o 37 TCMODULES += q_ingress.o 38 TCMODULES += q_hfsc.o 39 TCMODULES += q_htb.o 40 TCMODULES += q_drr.o 41 TCMODULES += q_qfq.o 42 TCMODULES += m_gact.o 43 TCMODULES += m_mirred.o 44 TCMODULES += m_nat.o 45 TCMODULES += m_pedit.o 46 TCMODULES += m_skbedit.o 47 TCMODULES += m_csum.o 48 TCMODULES += m_simple.o 49 TCMODULES += m_vlan.o 50 TCMODULES += m_connmark.o 51 TCMODULES += m_bpf.o 52 TCMODULES += p_ip.o 53 TCMODULES += p_icmp.o 54 TCMODULES += p_tcp.o 55 TCMODULES += p_udp.o 56 TCMODULES += em_nbyte.o 57 TCMODULES += em_cmp.o 58 TCMODULES += em_u32.o 59 TCMODULES += em_canid.o 60 TCMODULES += em_meta.o 61 TCMODULES += q_mqprio.o 62 TCMODULES += q_codel.o 63 TCMODULES += q_fq_codel.o 64 TCMODULES += q_fq.o 65 TCMODULES += q_pie.o 66 TCMODULES += q_hhf.o 67 TCMODULES += q_clsact.o 68 TCMODULES += e_bpf.o 69 70 ifeq ($(TC_CONFIG_IPSET), y) 71 ifeq ($(TC_CONFIG_XT), y) 72 TCMODULES += em_ipset.o 73 endif 74 endif 75 76 TCSO := 77 ifeq ($(TC_CONFIG_ATM),y) 78 TCSO += q_atm.so 79 endif 80 81 ifeq ($(TC_CONFIG_XT),y) 82 TCSO += m_xt.so 83 else 84 ifeq ($(TC_CONFIG_XT_OLD),y) 85 TCSO += m_xt_old.so 86 else 87 ifeq ($(TC_CONFIG_XT_OLD_H),y) 88 CFLAGS += -DTC_CONFIG_XT_H 89 TCSO += m_xt_old.so 90 else 91 TCMODULES += m_ipt.o 92 endif 93 endif 94 endif 95 96 ifeq ($(TC_CONFIG_ELF),y) 97 CFLAGS += -DHAVE_ELF 98 LDLIBS += -lelf 99 endif 100 101 TCOBJ += $(TCMODULES) 102 LDLIBS += -L. -ltc -lm 103 104 ifeq ($(SHARED_LIBS),y) 105 LDLIBS += -ldl 106 LDFLAGS += -Wl,-export-dynamic 107 endif 108 109 TCLIB := tc_core.o 110 TCLIB += tc_red.o 111 TCLIB += tc_cbq.o 112 TCLIB += tc_estimator.o 113 TCLIB += tc_stab.o 114 115 CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PROB 116 ifneq ($(IPT_LIB_DIR),) 117 CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\" 118 endif 119 120 YACC := bison 121 LEX := flex 122 CFLAGS += -DYY_NO_INPUT 123 124 MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc 125 126 %.so: %.c 127 $(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic $< -o $@ 128 129 130 all: libtc.a tc $(TCSO) 131 132 tc: $(TCOBJ) $(TCLIB) 133 134 libtc.a: $(TCLIB) 135 $(AR) rcs $@ $(TCLIB) 136 137 install: all 138 mkdir -p $(MODDESTDIR) 139 install -m 0755 tc $(DESTDIR)$(SBINDIR) 140 for i in $(TCSO); \ 141 do install -m 755 $$i $(MODDESTDIR); \ 142 done 143 if [ ! -f $(MODDESTDIR)/m_ipt.so ]; then \ 144 if [ -f $(MODDESTDIR)/m_xt.so ]; \ 145 then ln -s m_xt.so $(MODDESTDIR)/m_ipt.so ; \ 146 elif [ -f $(MODDESTDIR)/m_xt_old.so ]; \ 147 then ln -s m_xt_old.so $(MODDESTDIR)/m_ipt.so ; \ 148 fi; \ 149 fi 150 151 clean: 152 rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.yacc.h; \ 153 rm -f emp_ematch.yacc.* 154 155 q_atm.so: q_atm.c 156 $(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm 157 158 m_xt.so: m_xt.c 159 $(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o m_xt.so m_xt.c $$($(PKG_CONFIG) xtables --cflags --libs) 160 161 m_xt_old.so: m_xt_old.c 162 $(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o m_xt_old.so m_xt_old.c $$($(PKG_CONFIG) xtables --cflags --libs) 163 164 em_ipset.o: CFLAGS += $$($(PKG_CONFIG) xtables --cflags) 165 166 %.yacc.c: %.y 167 $(YACC) $(YACCFLAGS) -o $@ $< 168 169 %.lex.c: %.l 170 $(LEX) $(LEXFLAGS) -o$@ $< 171 172 # our lexer includes the header from yacc, so make sure 173 # we don't attempt to compile it before the header has 174 # been generated as part of the yacc step. 175 emp_ematch.lex.o: emp_ematch.yacc.c 176 177 ifneq ($(SHARED_LIBS),y) 178 179 tc: static-syms.o 180 static-syms.o: static-syms.h 181 static-syms.h: $(wildcard *.c) 182 files="$^" ; \ 183 for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \ 184 sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \ 185 done > $@ 186 187 endif 188