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