blob: b9e12604d5c298d9e5ecc04904787eaff84b51a2 [file] [log] [blame]
Bart De Schuymer1abc55d2002-06-01 19:23:47 +00001# ebtables Makefile
2
Bart De Schuymer1abc55d2002-06-01 19:23:47 +00003PROGNAME:=ebtables
Bart De Schuymer64182a32004-01-21 20:39:54 +00004PROGVERSION:=2.0.7
Bart De Schuymer50441e92005-08-30 21:20:55 +00005PROGDATE:=September\ 2005
Bart De Schuymer1abc55d2002-06-01 19:23:47 +00006
Bart De Schuymer3749f302004-02-11 21:23:38 +00007# default paths
Bart De Schuymer38561e92004-02-23 09:20:42 +00008LIBDIR:=/usr/lib
Bart De Schuymer3749f302004-02-11 21:23:38 +00009MANDIR:=/usr/local/man
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000010BINDIR:=/usr/local/sbin
Bart De Schuymer3749f302004-02-11 21:23:38 +000011ETCDIR:=/etc
Bart De Schuymer50441e92005-08-30 21:20:55 +000012INITDIR:=/etc/rc.d/init.d
13SYSCONFIGDIR:=/etc/sysconfig
Bart De Schuymer38561e92004-02-23 09:20:42 +000014DESTDIR:=
Bart De Schuymer3749f302004-02-11 21:23:38 +000015
16# include DESTDIR param
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000017override LIBDIR:=$(DESTDIR)$(LIBDIR)/$(PROGNAME)
Bart De Schuymer3749f302004-02-11 21:23:38 +000018override MANDIR:=$(DESTDIR)$(MANDIR)
19override BINDIR:=$(DESTDIR)$(BINDIR)
20override ETCDIR:=$(DESTDIR)$(ETCDIR)
Bart De Schuymer50441e92005-08-30 21:20:55 +000021override INITDIR:=$(DESTDIR)$(INITDIR)
22override SYSCONFIGDIR:=$(DESTDIR)$(SYSCONFIGDIR)
Bart De Schuymer3749f302004-02-11 21:23:38 +000023
24
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000025CFLAGS:=-Wall -Wunused
Bart De Schuymer06a1b462002-09-07 11:51:13 +000026CC:=gcc
Bart De Schuymer64182a32004-01-21 20:39:54 +000027LD:=ld
Bart De Schuymer3c1e00c2002-12-07 11:18:57 +000028
Bart De Schuymer60c20092003-07-23 21:34:21 +000029ifeq ($(shell uname -m),sparc64)
30CFLAGS+=-DEBT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
31endif
32
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000033include extensions/Makefile
34
Bart De Schuymer64182a32004-01-21 20:39:54 +000035OBJECTS2:=getethertype.o communication.o libebtc.o \
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000036useful_functions.o ebtables.o
Bart De Schuymer64182a32004-01-21 20:39:54 +000037
38OBJECTS:=$(OBJECTS2) ebtables.o $(EXT_OBJS) $(EXT_LIBS)
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000039
Bart De Schuymer06a96822003-02-19 20:09:51 +000040KERNEL_INCLUDES?=include/
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000041
Bart De Schuymer3749f302004-02-11 21:23:38 +000042ETHERTYPESPATH?=$(ETCDIR)
Bart De Schuymera2960382003-04-01 17:29:13 +000043ETHERTYPESFILE:=$(ETHERTYPESPATH)/ethertypes
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000044
Bart De Schuymer50441e92005-08-30 21:20:55 +000045PIPE_DIR?=$(DESTDIR)/tmp/$(PROGNAME)-v$(PROGVERSION)
Bart De Schuymer6622a012005-01-19 21:09:05 +000046PIPE=$(PIPE_DIR)/ebtablesd_pipe
47EBTD_CMDLINE_MAXLN?=2048
48EBTD_ARGC_MAX?=50
49
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000050PROGSPECS:=-DPROGVERSION=\"$(PROGVERSION)\" \
51 -DPROGNAME=\"$(PROGNAME)\" \
52 -DPROGDATE=\"$(PROGDATE)\" \
Bart De Schuymer9d680cc2005-10-01 09:16:51 +000053 -D_PATH_ETHERTYPES=\"$(ETHERTYPESFILE)\" \
54 -DEBTD_ARGC_MAX=$(EBTD_ARGC_MAX) \
55 -DEBTD_CMDLINE_MAXLN=$(EBTD_CMDLINE_MAXLN)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000056
Bart De Schuymer6622a012005-01-19 21:09:05 +000057PROGSPECSD:=-DPROGVERSION=\"$(PROGVERSION)\" \
58 -DPROGNAME=\"$(PROGNAME)\" \
59 -DPROGDATE=\"$(PROGDATE)\" \
60 -D_PATH_ETHERTYPES=\"$(ETHERTYPESFILE)\" \
61 -DEBTD_CMDLINE_MAXLN=$(EBTD_CMDLINE_MAXLN) \
62 -DEBTD_ARGC_MAX=$(EBTD_ARGC_MAX) \
63 -DEBTD_PIPE=\"$(PIPE)\" \
64 -DEBTD_PIPE_DIR=\"$(PIPE_DIR)\"
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000065
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000066# Uncomment for debugging (slower)
67#PROGSPECS+=-DEBT_DEBUG
68#PROGSPECSD+=-DEBT_DEBUG
69
Bart De Schuymer6622a012005-01-19 21:09:05 +000070all: ebtables daemon
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000071
72communication.o: communication.c include/ebtables_u.h
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000073 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
74
Bart De Schuymer8339ff12004-01-14 20:05:27 +000075libebtc.o: libebtc.c include/ebtables_u.h
76 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
77
78useful_functions.o: useful_functions.c include/ebtables_u.h
79 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
80
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000081getethertype.o: getethertype.c include/ethernetdb.h
fnm39bb3d0a2002-11-21 10:42:56 +000082 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -Iinclude/
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000083
84ebtables.o: ebtables.c include/ebtables_u.h
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000085 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000086
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000087ebtables-standalone.o: ebtables-standalone.c include/ebtables_u.h
88 $(CC) $(CFLAGS) $(PROGSPECS) -c $< -o $@ -I$(KERNEL_INCLUDES)
Bart De Schuymer6622a012005-01-19 21:09:05 +000089
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000090.PHONY: libebtc
91libebtc: $(OBJECTS2)
Bart De Schuymere1c15882004-05-24 19:57:58 +000092 $(LD) -shared -soname libebtc.so -o libebtc.so -lc $(OBJECTS2)
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000093
94ebtables: $(OBJECTS) ebtables-standalone.o libebtc
95 $(CC) $(CFLAGS) -o $@ ebtables-standalone.o -I$(KERNEL_INCLUDES) -L. -Lextensions -lebtc $(EXT_LIBSI) \
96 -Wl,-rpath,$(LIBDIR)
Bart De Schuymer6622a012005-01-19 21:09:05 +000097
98ebtablesu: ebtablesu.c
99 $(CC) $(CFLAGS) $(PROGSPECSD) $< -o $@
100
Bart De Schuymer838fa5b2005-06-18 14:43:32 +0000101ebtablesd.o: ebtablesd.c include/ebtables_u.h
102 $(CC) $(CFLAGS) $(PROGSPECSD) -c $< -o $@ -I$(KERNEL_INCLUDES)
Bart De Schuymer6622a012005-01-19 21:09:05 +0000103
Bart De Schuymer838fa5b2005-06-18 14:43:32 +0000104ebtablesd: $(OBJECTS) ebtablesd.o libebtc
105 $(CC) $(CFLAGS) -o $@ ebtablesd.o -I$(KERNEL_INCLUDES) -L. -Lextensions -lebtc $(EXT_LIBSI) \
106 -Wl,-rpath,$(LIBDIR)
Bart De Schuymer6622a012005-01-19 21:09:05 +0000107
Bart De Schuymer90db00b2005-09-28 19:36:34 +0000108ebtables-restore.o: ebtables-restore.c include/ebtables_u.h
Bart De Schuymer9d680cc2005-10-01 09:16:51 +0000109 $(CC) $(CFLAGS) $(PROGSPECS) -c $< -o $@ -I$(KERNEL_INCLUDES)
Bart De Schuymer90db00b2005-09-28 19:36:34 +0000110
111ebtables-restore: $(OBJECTS) ebtables-restore.o libebtc
112 $(CC) $(CFLAGS) -o $@ ebtables-restore.o -I$(KERNEL_INCLUDES) -L. -Lextensions -lebtc $(EXT_LIBSI) \
113 -Wl,-rpath,$(LIBDIR)
114
Bart De Schuymer6622a012005-01-19 21:09:05 +0000115.PHONY: daemon
116daemon: ebtablesd ebtablesu
117
Bart De Schuymer50441e92005-08-30 21:20:55 +0000118tmp1:=$(shell printf $(BINDIR) | sed 's/\//\\\//g')
119tmp2:=$(shell printf $(SYSCONFIGDIR) | sed 's/\//\\\//g')
Bart De Schuymerdb97ab22005-09-01 20:37:07 +0000120tmp3:=$(shell printf $(PIPE) | sed 's/\//\\\//g')
Bart De Schuymer50441e92005-08-30 21:20:55 +0000121.PHONY: scripts
Bart De Schuymer90db00b2005-09-28 19:36:34 +0000122scripts: ebtables-save ebtables.sysv ebtables-config
Bart De Schuymer50441e92005-08-30 21:20:55 +0000123 cat ebtables-save | sed 's/__EXEC_PATH__/$(tmp1)/g' > ebtables-save_
124 install -m 0755 -o root -g root ebtables-save_ $(BINDIR)/ebtables-save
Bart De Schuymerdb97ab22005-09-01 20:37:07 +0000125 cat ebtables.sysv | sed 's/__EXEC_PATH__/$(tmp1)/g' | sed 's/__SYSCONFIG__/$(tmp2)/g' > ebtables.sysv_
Bart De Schuymer50441e92005-08-30 21:20:55 +0000126 install -m 0755 -o root -g root ebtables.sysv_ $(INITDIR)/ebtables
127 cat ebtables-config | sed 's/__SYSCONFIG__/$(tmp1)/g' > ebtables-config_
128 install -m 0600 -o root -g root ebtables-config_ $(SYSCONFIGDIR)/ebtables-config
Bart De Schuymer90db00b2005-09-28 19:36:34 +0000129 rm -f ebtables-save_ ebtables.sysv_ ebtables-config_
Bart De Schuymer50441e92005-08-30 21:20:55 +0000130
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000131$(MANDIR)/man8/ebtables.8: ebtables.8
132 mkdir -p $(@D)
133 install -m 0644 -o root -g root $< $@
134
Bart De Schuymer2eb1f922002-11-22 18:55:55 +0000135$(ETHERTYPESFILE): ethertypes
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000136 mkdir -p $(@D)
137 install -m 0644 -o root -g root $< $@
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000138
Bart De Schuymer32890542002-07-10 20:09:56 +0000139.PHONY: exec
Bart De Schuymer90db00b2005-09-28 19:36:34 +0000140exec: ebtables ebtables-restore
Bart De Schuymer3749f302004-02-11 21:23:38 +0000141 mkdir -p $(BINDIR)
Bart De Schuymer90db00b2005-09-28 19:36:34 +0000142 install -m 0755 -o root -g root $(PROGNAME) $(BINDIR)/$(PROGNAME)
143 install -m 0755 -o root -g root ebtables-restore $(BINDIR)/ebtables-restore
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000144
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000145.PHONY: install
Bart De Schuymer50441e92005-08-30 21:20:55 +0000146install: $(MANDIR)/man8/ebtables.8 $(ETHERTYPESFILE) exec scripts
Bart De Schuymer0f5e3fe2004-02-10 18:08:00 +0000147 mkdir -p $(LIBDIR)
Bart De Schuymer64182a32004-01-21 20:39:54 +0000148 install -m 0755 extensions/*.so $(LIBDIR)
149 install -m 0755 *.so $(LIBDIR)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000150
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000151.PHONY: clean
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000152clean:
Bart De Schuymer6622a012005-01-19 21:09:05 +0000153 rm -f ebtables ebtablesd ebtablesu
Bart De Schuymer90db00b2005-09-28 19:36:34 +0000154 rm -f *.o *~ *.so
Bart De Schuymer64182a32004-01-21 20:39:54 +0000155 rm -f extensions/*.o extensions/*.c~ extensions/*.so
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000156
157DIR:=$(PROGNAME)-v$(PROGVERSION)
158# This is used to make a new userspace release
159.PHONY: release
160release:
161 mkdir -p include/linux/netfilter_bridge
162 install -m 0644 -o root -g root \
163 $(KERNEL_INCLUDES)/linux/netfilter_bridge.h include/linux/
164# To keep possible compile error complaints about undefined ETH_P_8021Q
165# off my back
166 install -m 0644 -o root -g root \
167 $(KERNEL_INCLUDES)/linux/if_ether.h include/linux/
168 install -m 0644 -o root -g root \
169 $(KERNEL_INCLUDES)/linux/netfilter_bridge/*.h \
170 include/linux/netfilter_bridge/
Bart De Schuymer60c20092003-07-23 21:34:21 +0000171 install -m 0644 -o root -g root \
172 include/ebtables.h include/linux/netfilter_bridge/
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000173 make clean
Bart De Schuymere29506d2003-07-26 11:53:32 +0000174 touch *
175 touch extensions/*
176 touch include/*
177 touch include/linux/*
178 touch include/linux/netfilter_bridge/*
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000179 cd ..;tar -c $(DIR) | gzip >$(DIR).tar.gz
Bart De Schuymer8bde1012004-11-20 13:00:52 +0000180
181.PHONY: test_ulog
182test_ulog: examples/ulog/test_ulog.c getethertype.o
183 $(CC) $(CFLAGS) $< -o test_ulog -I$(KERNEL_INCLUDES) -lc \
184 getethertype.o
185 mv test_ulog examples/ulog/
186
187.PHONY: examples
188examples: test_ulog