blob: ac3e9fa92f9dd961605c0f417184447e6c95a1bf [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 Schuymer838fa5b2005-06-18 14:43:32 +00005PROGDATE:=June\ 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 Schuymer38561e92004-02-23 09:20:42 +000012DESTDIR:=
Bart De Schuymer3749f302004-02-11 21:23:38 +000013
14# include DESTDIR param
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000015override LIBDIR:=$(DESTDIR)$(LIBDIR)/$(PROGNAME)
Bart De Schuymer3749f302004-02-11 21:23:38 +000016override 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 \
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000032useful_functions.o ebtables.o
Bart De Schuymer64182a32004-01-21 20:39:54 +000033
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 Schuymer838fa5b2005-06-18 14:43:32 +000064# Uncomment for debugging (slower)
65#PROGSPECS+=-DEBT_DEBUG
66#PROGSPECSD+=-DEBT_DEBUG
67
Bart De Schuymer6622a012005-01-19 21:09:05 +000068all: ebtables daemon
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000069
70communication.o: communication.c include/ebtables_u.h
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000071 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
72
Bart De Schuymer8339ff12004-01-14 20:05:27 +000073libebtc.o: libebtc.c include/ebtables_u.h
74 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
75
76useful_functions.o: useful_functions.c include/ebtables_u.h
77 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
78
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000079getethertype.o: getethertype.c include/ethernetdb.h
fnm39bb3d0a2002-11-21 10:42:56 +000080 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -Iinclude/
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000081
82ebtables.o: ebtables.c include/ebtables_u.h
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000083 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000084
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000085ebtables-standalone.o: ebtables-standalone.c include/ebtables_u.h
86 $(CC) $(CFLAGS) $(PROGSPECS) -c $< -o $@ -I$(KERNEL_INCLUDES)
Bart De Schuymer6622a012005-01-19 21:09:05 +000087
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000088.PHONY: libebtc
89libebtc: $(OBJECTS2)
Bart De Schuymere1c15882004-05-24 19:57:58 +000090 $(LD) -shared -soname libebtc.so -o libebtc.so -lc $(OBJECTS2)
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000091
92ebtables: $(OBJECTS) ebtables-standalone.o libebtc
93 $(CC) $(CFLAGS) -o $@ ebtables-standalone.o -I$(KERNEL_INCLUDES) -L. -Lextensions -lebtc $(EXT_LIBSI) \
94 -Wl,-rpath,$(LIBDIR)
Bart De Schuymer6622a012005-01-19 21:09:05 +000095
96ebtablesu: ebtablesu.c
97 $(CC) $(CFLAGS) $(PROGSPECSD) $< -o $@
98
Bart De Schuymer838fa5b2005-06-18 14:43:32 +000099ebtablesd.o: ebtablesd.c include/ebtables_u.h
100 $(CC) $(CFLAGS) $(PROGSPECSD) -c $< -o $@ -I$(KERNEL_INCLUDES)
Bart De Schuymer6622a012005-01-19 21:09:05 +0000101
Bart De Schuymer838fa5b2005-06-18 14:43:32 +0000102ebtablesd: $(OBJECTS) ebtablesd.o libebtc
103 $(CC) $(CFLAGS) -o $@ ebtablesd.o -I$(KERNEL_INCLUDES) -L. -Lextensions -lebtc $(EXT_LIBSI) \
104 -Wl,-rpath,$(LIBDIR)
Bart De Schuymer6622a012005-01-19 21:09:05 +0000105
106.PHONY: daemon
107daemon: ebtablesd ebtablesu
108
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000109$(MANDIR)/man8/ebtables.8: ebtables.8
110 mkdir -p $(@D)
111 install -m 0644 -o root -g root $< $@
112
Bart De Schuymer2eb1f922002-11-22 18:55:55 +0000113$(ETHERTYPESFILE): ethertypes
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000114 mkdir -p $(@D)
115 install -m 0644 -o root -g root $< $@
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000116
Bart De Schuymer32890542002-07-10 20:09:56 +0000117.PHONY: exec
Bart De Schuymer6622a012005-01-19 21:09:05 +0000118exec: ebtables daemon
Bart De Schuymer3749f302004-02-11 21:23:38 +0000119 mkdir -p $(BINDIR)
Bart De Schuymer6622a012005-01-19 21:09:05 +0000120 install -m 0755 -o root -g root $(PROGNAME) $(BINFILE_EBT)
121 install -m 0755 -o root -g root $(PROGNAME)d $(BINFILE_EBTD)
122 install -m 0755 -o root -g root $(PROGNAME)u $(BINFILE_EBTU)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000123
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000124.PHONY: install
Bart De Schuymerf43456b2003-02-15 11:12:01 +0000125install: $(MANDIR)/man8/ebtables.8 $(ETHERTYPESFILE) exec
Bart De Schuymer0f5e3fe2004-02-10 18:08:00 +0000126 mkdir -p $(LIBDIR)
Bart De Schuymer64182a32004-01-21 20:39:54 +0000127 install -m 0755 extensions/*.so $(LIBDIR)
128 install -m 0755 *.so $(LIBDIR)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000129
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000130.PHONY: clean
Bart De Schuymer1abc55d2002-06-01 19:23:47 +0000131clean:
Bart De Schuymer6622a012005-01-19 21:09:05 +0000132 rm -f ebtables ebtablesd ebtablesu
Bart De Schuymer64182a32004-01-21 20:39:54 +0000133 rm -f *.o *.c~ *.so
134 rm -f extensions/*.o extensions/*.c~ extensions/*.so
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000135
136DIR:=$(PROGNAME)-v$(PROGVERSION)
137# This is used to make a new userspace release
138.PHONY: release
139release:
140 mkdir -p include/linux/netfilter_bridge
141 install -m 0644 -o root -g root \
142 $(KERNEL_INCLUDES)/linux/netfilter_bridge.h include/linux/
143# To keep possible compile error complaints about undefined ETH_P_8021Q
144# off my back
145 install -m 0644 -o root -g root \
146 $(KERNEL_INCLUDES)/linux/if_ether.h include/linux/
147 install -m 0644 -o root -g root \
148 $(KERNEL_INCLUDES)/linux/netfilter_bridge/*.h \
149 include/linux/netfilter_bridge/
Bart De Schuymer60c20092003-07-23 21:34:21 +0000150 install -m 0644 -o root -g root \
151 include/ebtables.h include/linux/netfilter_bridge/
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000152 make clean
Bart De Schuymere29506d2003-07-26 11:53:32 +0000153 touch *
154 touch extensions/*
155 touch include/*
156 touch include/linux/*
157 touch include/linux/netfilter_bridge/*
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000158 cd ..;tar -c $(DIR) | gzip >$(DIR).tar.gz
Bart De Schuymer8bde1012004-11-20 13:00:52 +0000159
160.PHONY: test_ulog
161test_ulog: examples/ulog/test_ulog.c getethertype.o
162 $(CC) $(CFLAGS) $< -o test_ulog -I$(KERNEL_INCLUDES) -lc \
163 getethertype.o
164 mv test_ulog examples/ulog/
165
166.PHONY: examples
167examples: test_ulog