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