blob: 8917eaf46833fb8682c3db732bba35fba79aea4a [file] [log] [blame]
Daniel Borkmann4bd62442015-04-16 21:20:06 +02001TCOBJ= 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
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +00004
osdl.net!shemmingeradff36d2004-06-25 21:14:22 +00005include ../Config
Vadim Kochan67e1d732014-12-24 23:04:11 +02006
7ifeq ($(IP_CONFIG_SETNS),y)
8 CFLAGS += -DHAVE_SETNS
9endif
10
Mike Frysingerf2e27cf2009-11-06 06:09:22 -050011SHARED_LIBS ?= y
osdl.net!shemmingeradff36d2004-06-25 21:14:22 +000012
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +000013TCMODULES :=
14TCMODULES += q_fifo.o
15TCMODULES += q_sfq.o
16TCMODULES += q_red.o
17TCMODULES += q_prio.o
18TCMODULES += q_tbf.o
19TCMODULES += q_cbq.o
Stephen Hemminger45305c22007-10-16 14:27:42 -070020TCMODULES += q_rr.o
Alexander Duyckfe1a34f2008-12-05 14:16:42 -080021TCMODULES += q_multiq.o
Stephen Hemminger954df8c2007-06-25 09:42:30 -070022TCMODULES += q_netem.o
Stephen Hemmingera4eca972011-01-13 09:23:17 -080023TCMODULES += q_choke.o
Juliusz Chroboczekd7f32992011-03-24 18:44:09 +010024TCMODULES += q_sfb.o
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +000025TCMODULES += f_rsvp.o
26TCMODULES += f_u32.o
27TCMODULES += f_route.o
28TCMODULES += f_fw.o
shemminger9ddbb022005-06-23 17:21:46 +000029TCMODULES += f_basic.o
Daniel Borkmannd05df682013-10-28 12:35:33 +010030TCMODULES += f_bpf.o
Patrick McHardy9932abb2008-01-31 18:58:59 +010031TCMODULES += f_flow.o
Thomas Grafff213c42009-04-09 07:01:51 -040032TCMODULES += f_cgroup.o
Jiri Pirko30eb3042015-05-15 13:34:04 +020033TCMODULES += f_flower.o
osdl.org!shemmingercda17fc2004-06-09 21:31:01 +000034TCMODULES += q_dsmark.o
35TCMODULES += q_gred.o
36TCMODULES += f_tcindex.o
37TCMODULES += q_ingress.o
osdl.net!shemminger4b1bbd92004-08-09 16:35:28 +000038TCMODULES += q_hfsc.o
39TCMODULES += q_htb.o
Patrick McHardyc86f3492008-11-19 16:08:05 +010040TCMODULES += q_drr.o
Stephen Hemmingerc441bd42011-01-07 09:43:27 -080041TCMODULES += q_qfq.o
osdl.net!shemminger9bf19a82004-08-30 21:20:10 +000042TCMODULES += m_gact.o
net[shemminger]!shemminger00fa8482004-12-08 20:13:56 +000043TCMODULES += m_mirred.o
Herbert Xufc2d0202007-10-12 17:08:40 +080044TCMODULES += m_nat.o
net[shemminger]!shemminger7e7c7372005-01-17 23:32:51 +000045TCMODULES += m_pedit.o
Jamal Hadi Salimd3e51122016-05-07 09:35:23 -040046TCMODULES += m_ife.o
Alexander Duyckf72a7aa2009-01-06 19:27:03 -080047TCMODULES += m_skbedit.o
Gregoire Baron3822cc92010-12-01 11:17:46 -080048TCMODULES += m_csum.o
Jamal Hadi Salim087f46e2013-09-29 07:33:42 -040049TCMODULES += m_simple.o
Jiri Pirko8b1c0212014-11-21 12:31:30 +010050TCMODULES += m_vlan.o
Felix Fietkaub8d5c9a2015-02-15 11:57:19 -050051TCMODULES += m_connmark.o
Jiri Pirko86ab59a2015-01-19 16:56:30 +010052TCMODULES += m_bpf.o
net[shemminger]!shemminger7e7c7372005-01-17 23:32:51 +000053TCMODULES += p_ip.o
54TCMODULES += p_icmp.o
55TCMODULES += p_tcp.o
56TCMODULES += p_udp.o
shemminger9ddbb022005-06-23 17:21:46 +000057TCMODULES += em_nbyte.o
58TCMODULES += em_cmp.o
59TCMODULES += em_u32.o
Rostislav Lisovy7b5f30e2012-08-20 13:11:55 -070060TCMODULES += em_canid.o
shemminger9ddbb022005-06-23 17:21:46 +000061TCMODULES += em_meta.o
John Fastabend91495302011-04-12 08:57:27 -070062TCMODULES += q_mqprio.o
Eric Dumazet185d88f2012-05-10 20:22:35 +000063TCMODULES += q_codel.o
Eric Dumazetc3524ef2012-05-11 09:49:50 +000064TCMODULES += q_fq_codel.o
Eric Dumazetbc113e42013-08-29 19:30:36 -070065TCMODULES += q_fq.o
Vijay Subramanian80dd8802014-01-07 22:00:39 -080066TCMODULES += q_pie.o
Terry Lamac74bd22014-05-09 12:10:47 -070067TCMODULES += q_hhf.o
Daniel Borkmann8f9afdd2016-01-12 01:42:20 +010068TCMODULES += q_clsact.o
Daniel Borkmann4bd62442015-04-16 21:20:06 +020069TCMODULES += e_bpf.o
Yotam Gigid5cbf3f2016-08-31 09:28:26 +020070TCMODULES += f_matchall.o
net[shemminger]!shemminger7e7c7372005-01-17 23:32:51 +000071
Florian Westphal81944112012-08-09 09:18:50 +000072ifeq ($(TC_CONFIG_IPSET), y)
Matt Burgess92905c62012-10-02 19:01:32 +010073 ifeq ($(TC_CONFIG_XT), y)
74 TCMODULES += em_ipset.o
75 endif
Florian Westphal81944112012-08-09 09:18:50 +000076endif
77
Andreas Henrikssonab814d62010-04-12 20:24:23 +020078TCSO :=
79ifeq ($(TC_CONFIG_ATM),y)
80 TCSO += q_atm.so
81endif
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050082
83ifeq ($(TC_CONFIG_XT),y)
Andreas Henrikssonab814d62010-04-12 20:24:23 +020084 TCSO += m_xt.so
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050085else
Andreas Henriksson80d689d2009-12-02 16:11:21 +010086 ifeq ($(TC_CONFIG_XT_OLD),y)
Andreas Henrikssonab814d62010-04-12 20:24:23 +020087 TCSO += m_xt_old.so
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050088 else
Andreas Henriksson80d689d2009-12-02 16:11:21 +010089 ifeq ($(TC_CONFIG_XT_OLD_H),y)
90 CFLAGS += -DTC_CONFIG_XT_H
Andreas Henrikssonab814d62010-04-12 20:24:23 +020091 TCSO += m_xt_old.so
Andreas Henriksson80d689d2009-12-02 16:11:21 +010092 else
93 TCMODULES += m_ipt.o
94 endif
Jamal Hadi Salim63c7d262009-02-07 08:19:20 -050095 endif
96endif
97
Daniel Borkmann11c39b52015-03-16 19:37:41 +010098ifeq ($(TC_CONFIG_ELF),y)
99 CFLAGS += -DHAVE_ELF
100 LDLIBS += -lelf
101endif
102
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000103TCOBJ += $(TCMODULES)
Mike Frysingerf2e27cf2009-11-06 06:09:22 -0500104LDLIBS += -L. -ltc -lm
105
106ifeq ($(SHARED_LIBS),y)
107LDLIBS += -ldl
108LDFLAGS += -Wl,-export-dynamic
109endif
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000110
111TCLIB := tc_core.o
112TCLIB += tc_red.o
113TCLIB += tc_cbq.o
114TCLIB += tc_estimator.o
Jussi Kivilinna839c8452008-07-25 16:19:09 +0300115TCLIB += tc_stab.o
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000116
osdl.net!shemminger9bf19a82004-08-30 21:20:10 +0000117CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PROB
Andreas Henriksson12ddfff2010-03-11 10:54:31 +0000118ifneq ($(IPT_LIB_DIR),)
119 CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\"
120endif
osdl.net!shemminger9bf19a82004-08-30 21:20:10 +0000121
shemmingerc0fc3ab2005-06-23 20:16:43 +0000122YACC := bison
123LEX := flex
Stephen Hemminger155ad802012-01-03 13:55:59 -0800124CFLAGS += -DYY_NO_INPUT
shemmingerc0fc3ab2005-06-23 20:16:43 +0000125
Christoph J. Thompson5c434a92012-03-01 17:46:26 +0100126MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
Andreas Henrikssonab814d62010-04-12 20:24:23 +0200127
osdl.net!shemmingerd3ea2e82004-07-02 17:47:53 +0000128%.so: %.c
David Ahern57bdf8b2016-05-24 15:04:49 -0700129 $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic $< -o $@
osdl.net!shemmingerd3ea2e82004-07-02 17:47:53 +0000130
osdl.net!shemmingera2218e82004-08-23 20:21:21 +0000131
osdl.net!shemminger6cc2f072005-02-09 22:05:41 +0000132all: libtc.a tc $(TCSO)
site!shemmingerd5b48552005-02-07 18:01:21 +0000133
Yegor Yefremov8ced4fc2012-02-27 15:21:15 +0100134tc: $(TCOBJ) $(TCLIB)
David Ahern57bdf8b2016-05-24 15:04:49 -0700135 $(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
net[shemminger]!shemminger8e64f6f2004-08-30 21:07:09 +0000136
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000137libtc.a: $(TCLIB)
David Ahern57bdf8b2016-05-24 15:04:49 -0700138 $(QUIET_AR)$(AR) rcs $@ $(TCLIB)
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000139
140install: all
Mike Frysingerbf512682010-06-09 14:52:03 +0000141 mkdir -p $(MODDESTDIR)
142 install -m 0755 tc $(DESTDIR)$(SBINDIR)
osdl.net!shemminger69286fe2004-08-30 20:54:46 +0000143 for i in $(TCSO); \
Mike Frysingerbf512682010-06-09 14:52:03 +0000144 do install -m 755 $$i $(MODDESTDIR); \
osdl.net!shemmingera2218e82004-08-23 20:21:21 +0000145 done
Andreas Henrikssonab814d62010-04-12 20:24:23 +0200146 if [ ! -f $(MODDESTDIR)/m_ipt.so ]; then \
147 if [ -f $(MODDESTDIR)/m_xt.so ]; \
148 then ln -s m_xt.so $(MODDESTDIR)/m_ipt.so ; \
149 elif [ -f $(MODDESTDIR)/m_xt_old.so ]; \
150 then ln -s m_xt_old.so $(MODDESTDIR)/m_ipt.so ; \
151 fi; \
152 fi
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000153
154clean:
shemminger87773db2005-06-23 17:23:53 +0000155 rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.yacc.h; \
Stephen Hemminger93ba4812011-11-02 16:39:36 -0700156 rm -f emp_ematch.yacc.*
osdl.org!shemmingeraba5acd2004-04-15 20:56:59 +0000157
osdl.net!shemmingerd3ea2e82004-07-02 17:47:53 +0000158q_atm.so: q_atm.c
David Ahern57bdf8b2016-05-24 15:04:49 -0700159 $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm
osdl.net!shemmingerd3ea2e82004-07-02 17:47:53 +0000160
Andreas Henrikssonab814d62010-04-12 20:24:23 +0200161m_xt.so: m_xt.c
David Ahern57bdf8b2016-05-24 15:04:49 -0700162 $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o m_xt.so m_xt.c $$($(PKG_CONFIG) xtables --cflags --libs)
Andreas Henrikssonab814d62010-04-12 20:24:23 +0200163
164m_xt_old.so: m_xt_old.c
David Ahern57bdf8b2016-05-24 15:04:49 -0700165 $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -shared -fpic -o m_xt_old.so m_xt_old.c $$($(PKG_CONFIG) xtables --cflags --libs)
Andreas Henrikssonab814d62010-04-12 20:24:23 +0200166
Benjamin Poirier5ab3a4d2013-02-06 11:19:24 +0000167em_ipset.o: CFLAGS += $$($(PKG_CONFIG) xtables --cflags)
168
shemminger9ddbb022005-06-23 17:21:46 +0000169%.yacc.c: %.y
David Ahern57bdf8b2016-05-24 15:04:49 -0700170 $(QUIET_YACC)$(YACC) $(YACCFLAGS) -o $@ $<
shemminger9ddbb022005-06-23 17:21:46 +0000171
172%.lex.c: %.l
David Ahern57bdf8b2016-05-24 15:04:49 -0700173 $(QUIET_LEX)$(LEX) $(LEXFLAGS) -o$@ $<
Mike Frysingerf2e27cf2009-11-06 06:09:22 -0500174
Mike Frysingeraa48b592011-10-18 17:38:08 -0400175# our lexer includes the header from yacc, so make sure
176# we don't attempt to compile it before the header has
177# been generated as part of the yacc step.
178emp_ematch.lex.o: emp_ematch.yacc.c
179
Mike Frysingerf2e27cf2009-11-06 06:09:22 -0500180ifneq ($(SHARED_LIBS),y)
181
182tc: static-syms.o
183static-syms.o: static-syms.h
184static-syms.h: $(wildcard *.c)
185 files="$^" ; \
186 for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
187 sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
188 done > $@
189
190endif