blob: 025ce8aac372b323ed5738767e79d502d35422e5 [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
5PROGDATE:=January\ 2004
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 Schuymer598ca8f2004-11-29 22:00:36 +000010BINDIR:=/usr/sbin
Bart De Schuymer3749f302004-02-11 21:23:38 +000011ETCDIR:=/etc
Bart De Schuymer38561e92004-02-23 09:20:42 +000012DESTDIR:=
Bart De Schuymer3749f302004-02-11 21:23:38 +000013
14# include DESTDIR param
15override LIBDIR:=$(DESTDIR)$(LIBDIR)
16override MANDIR:=$(DESTDIR)$(MANDIR)
17override BINDIR:=$(DESTDIR)$(BINDIR)
18override ETCDIR:=$(DESTDIR)$(ETCDIR)
19
20
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000021CFLAGS:=-Wall -Wunused
Bart De Schuymer06a1b462002-09-07 11:51:13 +000022CC:=gcc
Bart De Schuymer64182a32004-01-21 20:39:54 +000023LD:=ld
Bart De Schuymer3c1e00c2002-12-07 11:18:57 +000024
Bart De Schuymer60c20092003-07-23 21:34:21 +000025ifeq ($(shell uname -m),sparc64)
26CFLAGS+=-DEBT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
27endif
28
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000029include extensions/Makefile
30
Bart De Schuymer64182a32004-01-21 20:39:54 +000031OBJECTS2:=getethertype.o communication.o libebtc.o \
32useful_functions.o
33
34OBJECTS:=$(OBJECTS2) ebtables.o $(EXT_OBJS) $(EXT_LIBS)
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000035
Bart De Schuymer06a96822003-02-19 20:09:51 +000036KERNEL_INCLUDES?=include/
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000037
Bart De Schuymer3749f302004-02-11 21:23:38 +000038ETHERTYPESPATH?=$(ETCDIR)
Bart De Schuymera2960382003-04-01 17:29:13 +000039ETHERTYPESFILE:=$(ETHERTYPESPATH)/ethertypes
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000040
Bart De Schuymera43530a2005-01-22 23:08:54 +000041PIPE_DIR?=/tmp/$(PROGNAME)-v$(PROGVERSION)
Bart De Schuymer6622a012005-01-19 21:09:05 +000042PIPE=$(PIPE_DIR)/ebtablesd_pipe
43EBTD_CMDLINE_MAXLN?=2048
44EBTD_ARGC_MAX?=50
45
46BINFILE_EBT:=$(BINDIR)/$(PROGNAME)
47BINFILE_EBTD:=$(BINDIR)/$(PROGNAME)d
48BINFILE_EBTU:=$(BINDIR)/$(PROGNAME)u
Bart De Schuymerf43456b2003-02-15 11:12:01 +000049
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000050PROGSPECS:=-DPROGVERSION=\"$(PROGVERSION)\" \
51 -DPROGNAME=\"$(PROGNAME)\" \
52 -DPROGDATE=\"$(PROGDATE)\" \
fnm39bb3d0a2002-11-21 10:42:56 +000053 -D_PATH_ETHERTYPES=\"$(ETHERTYPESFILE)\"
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000054
Bart De Schuymer6622a012005-01-19 21:09:05 +000055PROGSPECSD:=-DPROGVERSION=\"$(PROGVERSION)\" \
56 -DPROGNAME=\"$(PROGNAME)\" \
57 -DPROGDATE=\"$(PROGDATE)\" \
58 -D_PATH_ETHERTYPES=\"$(ETHERTYPESFILE)\" \
59 -DEBTD_CMDLINE_MAXLN=$(EBTD_CMDLINE_MAXLN) \
60 -DEBTD_ARGC_MAX=$(EBTD_ARGC_MAX) \
61 -DEBTD_PIPE=\"$(PIPE)\" \
62 -DEBTD_PIPE_DIR=\"$(PIPE_DIR)\"
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000063
Bart De Schuymer6622a012005-01-19 21:09:05 +000064all: ebtables daemon
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000065
66communication.o: communication.c include/ebtables_u.h
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000067 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
68
Bart De Schuymer8339ff12004-01-14 20:05:27 +000069libebtc.o: libebtc.c include/ebtables_u.h
70 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
71
72useful_functions.o: useful_functions.c include/ebtables_u.h
73 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
74
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000075getethertype.o: getethertype.c include/ethernetdb.h
fnm39bb3d0a2002-11-21 10:42:56 +000076 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -Iinclude/
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000077
78ebtables.o: ebtables.c include/ebtables_u.h
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000079 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000080
Bart De Schuymer6622a012005-01-19 21:09:05 +000081ebtables-standalone.o: ebtables-standalone.c ebtables.c include/ebtables_u.h
82 $(CC) $(CFLAGS) $(PROGSPECS) -c $< ebtables.c -o $@ -I$(KERNEL_INCLUDES)
83
84ebtables: $(OBJECTS) ebtables-standalone.o
Bart De Schuymere1c15882004-05-24 19:57:58 +000085 $(LD) -shared -soname libebtc.so -o libebtc.so -lc $(OBJECTS2)
Bart De Schuymer6622a012005-01-19 21:09:05 +000086 $(CC) $(CFLAGS) -o $@ ebtables-standalone.o -I$(KERNEL_INCLUDES) -L/root/ \
Bart De Schuymer64182a32004-01-21 20:39:54 +000087 -L. -Lextensions/ -lebtc $(EXT_LIBSI)
Bart De Schuymer6622a012005-01-19 21:09:05 +000088
89ebtablesu: ebtablesu.c
90 $(CC) $(CFLAGS) $(PROGSPECSD) $< -o $@
91
92ebtablesd.o: ebtablesd.c ebtables.c include/ebtables_u.h
93 $(CC) $(CFLAGS) $(PROGSPECSD) -c $< ebtables.c -o $@ -I$(KERNEL_INCLUDES)
94
95ebtablesd: $(OBJECTS) ebtablesd.o
96 $(LD) -shared -soname libebtc.so -o libebtc.so -lc $(OBJECTS2)
97 $(CC) $(CFLAGS) -o $@ ebtablesd.o -I$(KERNEL_INCLUDES) -L/root/ \
98 -L. -Lextensions/ -lebtc $(EXT_LIBSI)
99
100.PHONY: daemon
101daemon: ebtablesd ebtablesu
102
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000103$(MANDIR)/man8/ebtables.8: ebtables.8
104 mkdir -p $(@D)
105 install -m 0644 -o root -g root $< $@
106
Bart De Schuymer2eb1f922002-11-22 18:55:55 +0000107$(ETHERTYPESFILE): ethertypes
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000108 mkdir -p $(@D)
109 install -m 0644 -o root -g root $< $@
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000110
Bart De Schuymer32890542002-07-10 20:09:56 +0000111.PHONY: exec
Bart De Schuymer6622a012005-01-19 21:09:05 +0000112exec: ebtables daemon
Bart De Schuymer3749f302004-02-11 21:23:38 +0000113 mkdir -p $(BINDIR)
Bart De Schuymer6622a012005-01-19 21:09:05 +0000114 install -m 0755 -o root -g root $(PROGNAME) $(BINFILE_EBT)
115 install -m 0755 -o root -g root $(PROGNAME)d $(BINFILE_EBTD)
116 install -m 0755 -o root -g root $(PROGNAME)u $(BINFILE_EBTU)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000117
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000118.PHONY: install
Bart De Schuymerf43456b2003-02-15 11:12:01 +0000119install: $(MANDIR)/man8/ebtables.8 $(ETHERTYPESFILE) exec
Bart De Schuymer0f5e3fe2004-02-10 18:08:00 +0000120 mkdir -p $(LIBDIR)
Bart De Schuymer64182a32004-01-21 20:39:54 +0000121 install -m 0755 extensions/*.so $(LIBDIR)
122 install -m 0755 *.so $(LIBDIR)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000123
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000124.PHONY: clean
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000125clean:
Bart De Schuymer6622a012005-01-19 21:09:05 +0000126 rm -f ebtables ebtablesd ebtablesu
Bart De Schuymer64182a32004-01-21 20:39:54 +0000127 rm -f *.o *.c~ *.so
128 rm -f extensions/*.o extensions/*.c~ extensions/*.so
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000129
130DIR:=$(PROGNAME)-v$(PROGVERSION)
131# This is used to make a new userspace release
132.PHONY: release
133release:
134 mkdir -p include/linux/netfilter_bridge
135 install -m 0644 -o root -g root \
136 $(KERNEL_INCLUDES)/linux/netfilter_bridge.h include/linux/
137# To keep possible compile error complaints about undefined ETH_P_8021Q
138# off my back
139 install -m 0644 -o root -g root \
140 $(KERNEL_INCLUDES)/linux/if_ether.h include/linux/
141 install -m 0644 -o root -g root \
142 $(KERNEL_INCLUDES)/linux/netfilter_bridge/*.h \
143 include/linux/netfilter_bridge/
Bart De Schuymer60c20092003-07-23 21:34:21 +0000144 install -m 0644 -o root -g root \
145 include/ebtables.h include/linux/netfilter_bridge/
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000146 make clean
Bart De Schuymere29506d2003-07-26 11:53:32 +0000147 touch *
148 touch extensions/*
149 touch include/*
150 touch include/linux/*
151 touch include/linux/netfilter_bridge/*
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000152 cd ..;tar -c $(DIR) | gzip >$(DIR).tar.gz
Bart De Schuymer8bde1012004-11-20 13:00:52 +0000153
154.PHONY: test_ulog
155test_ulog: examples/ulog/test_ulog.c getethertype.o
156 $(CC) $(CFLAGS) $< -o test_ulog -I$(KERNEL_INCLUDES) -lc \
157 getethertype.o
158 mv test_ulog examples/ulog/
159
160.PHONY: examples
161examples: test_ulog