Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 1 | # ebtables Makefile |
| 2 | |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 3 | PROGNAME:=ebtables |
Bart De Schuymer | 64182a3 | 2004-01-21 20:39:54 +0000 | [diff] [blame] | 4 | PROGVERSION:=2.0.7 |
| 5 | PROGDATE:=January\ 2004 |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 6 | |
Bart De Schuymer | 3749f30 | 2004-02-11 21:23:38 +0000 | [diff] [blame] | 7 | # default paths |
Bart De Schuymer | 38561e9 | 2004-02-23 09:20:42 +0000 | [diff] [blame] | 8 | LIBDIR:=/usr/lib |
Bart De Schuymer | 3749f30 | 2004-02-11 21:23:38 +0000 | [diff] [blame] | 9 | MANDIR:=/usr/local/man |
Bart De Schuymer | 598ca8f | 2004-11-29 22:00:36 +0000 | [diff] [blame] | 10 | BINDIR:=/usr/sbin |
Bart De Schuymer | 3749f30 | 2004-02-11 21:23:38 +0000 | [diff] [blame] | 11 | ETCDIR:=/etc |
Bart De Schuymer | 38561e9 | 2004-02-23 09:20:42 +0000 | [diff] [blame] | 12 | DESTDIR:= |
Bart De Schuymer | 3749f30 | 2004-02-11 21:23:38 +0000 | [diff] [blame] | 13 | |
| 14 | # include DESTDIR param |
| 15 | override LIBDIR:=$(DESTDIR)$(LIBDIR) |
| 16 | override MANDIR:=$(DESTDIR)$(MANDIR) |
| 17 | override BINDIR:=$(DESTDIR)$(BINDIR) |
| 18 | override ETCDIR:=$(DESTDIR)$(ETCDIR) |
| 19 | |
| 20 | |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 21 | CFLAGS:=-Wall -Wunused |
Bart De Schuymer | 06a1b46 | 2002-09-07 11:51:13 +0000 | [diff] [blame] | 22 | CC:=gcc |
Bart De Schuymer | 64182a3 | 2004-01-21 20:39:54 +0000 | [diff] [blame] | 23 | LD:=ld |
Bart De Schuymer | 3c1e00c | 2002-12-07 11:18:57 +0000 | [diff] [blame] | 24 | |
Bart De Schuymer | 60c2009 | 2003-07-23 21:34:21 +0000 | [diff] [blame] | 25 | ifeq ($(shell uname -m),sparc64) |
| 26 | CFLAGS+=-DEBT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32 |
| 27 | endif |
| 28 | |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 29 | include extensions/Makefile |
| 30 | |
Bart De Schuymer | 64182a3 | 2004-01-21 20:39:54 +0000 | [diff] [blame] | 31 | OBJECTS2:=getethertype.o communication.o libebtc.o \ |
| 32 | useful_functions.o |
| 33 | |
| 34 | OBJECTS:=$(OBJECTS2) ebtables.o $(EXT_OBJS) $(EXT_LIBS) |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 35 | |
Bart De Schuymer | 06a9682 | 2003-02-19 20:09:51 +0000 | [diff] [blame] | 36 | KERNEL_INCLUDES?=include/ |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 37 | |
Bart De Schuymer | 3749f30 | 2004-02-11 21:23:38 +0000 | [diff] [blame] | 38 | ETHERTYPESPATH?=$(ETCDIR) |
Bart De Schuymer | a296038 | 2003-04-01 17:29:13 +0000 | [diff] [blame] | 39 | ETHERTYPESFILE:=$(ETHERTYPESPATH)/ethertypes |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 40 | |
Bart De Schuymer | a43530a | 2005-01-22 23:08:54 +0000 | [diff] [blame] | 41 | PIPE_DIR?=/tmp/$(PROGNAME)-v$(PROGVERSION) |
Bart De Schuymer | 6622a01 | 2005-01-19 21:09:05 +0000 | [diff] [blame] | 42 | PIPE=$(PIPE_DIR)/ebtablesd_pipe |
| 43 | EBTD_CMDLINE_MAXLN?=2048 |
| 44 | EBTD_ARGC_MAX?=50 |
| 45 | |
| 46 | BINFILE_EBT:=$(BINDIR)/$(PROGNAME) |
| 47 | BINFILE_EBTD:=$(BINDIR)/$(PROGNAME)d |
| 48 | BINFILE_EBTU:=$(BINDIR)/$(PROGNAME)u |
Bart De Schuymer | f43456b | 2003-02-15 11:12:01 +0000 | [diff] [blame] | 49 | |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 50 | PROGSPECS:=-DPROGVERSION=\"$(PROGVERSION)\" \ |
| 51 | -DPROGNAME=\"$(PROGNAME)\" \ |
| 52 | -DPROGDATE=\"$(PROGDATE)\" \ |
fnm3 | 9bb3d0a | 2002-11-21 10:42:56 +0000 | [diff] [blame] | 53 | -D_PATH_ETHERTYPES=\"$(ETHERTYPESFILE)\" |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 54 | |
Bart De Schuymer | 6622a01 | 2005-01-19 21:09:05 +0000 | [diff] [blame] | 55 | PROGSPECSD:=-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 Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 63 | |
Bart De Schuymer | 6622a01 | 2005-01-19 21:09:05 +0000 | [diff] [blame] | 64 | all: ebtables daemon |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 65 | |
| 66 | communication.o: communication.c include/ebtables_u.h |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 67 | $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES) |
| 68 | |
Bart De Schuymer | 8339ff1 | 2004-01-14 20:05:27 +0000 | [diff] [blame] | 69 | libebtc.o: libebtc.c include/ebtables_u.h |
| 70 | $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES) |
| 71 | |
| 72 | useful_functions.o: useful_functions.c include/ebtables_u.h |
| 73 | $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES) |
| 74 | |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 75 | getethertype.o: getethertype.c include/ethernetdb.h |
fnm3 | 9bb3d0a | 2002-11-21 10:42:56 +0000 | [diff] [blame] | 76 | $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -Iinclude/ |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 77 | |
| 78 | ebtables.o: ebtables.c include/ebtables_u.h |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 79 | $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES) |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 80 | |
Bart De Schuymer | 6622a01 | 2005-01-19 21:09:05 +0000 | [diff] [blame] | 81 | ebtables-standalone.o: ebtables-standalone.c ebtables.c include/ebtables_u.h |
| 82 | $(CC) $(CFLAGS) $(PROGSPECS) -c $< ebtables.c -o $@ -I$(KERNEL_INCLUDES) |
| 83 | |
| 84 | ebtables: $(OBJECTS) ebtables-standalone.o |
Bart De Schuymer | e1c1588 | 2004-05-24 19:57:58 +0000 | [diff] [blame] | 85 | $(LD) -shared -soname libebtc.so -o libebtc.so -lc $(OBJECTS2) |
Bart De Schuymer | 6622a01 | 2005-01-19 21:09:05 +0000 | [diff] [blame] | 86 | $(CC) $(CFLAGS) -o $@ ebtables-standalone.o -I$(KERNEL_INCLUDES) -L/root/ \ |
Bart De Schuymer | 64182a3 | 2004-01-21 20:39:54 +0000 | [diff] [blame] | 87 | -L. -Lextensions/ -lebtc $(EXT_LIBSI) |
Bart De Schuymer | 6622a01 | 2005-01-19 21:09:05 +0000 | [diff] [blame] | 88 | |
| 89 | ebtablesu: ebtablesu.c |
| 90 | $(CC) $(CFLAGS) $(PROGSPECSD) $< -o $@ |
| 91 | |
| 92 | ebtablesd.o: ebtablesd.c ebtables.c include/ebtables_u.h |
| 93 | $(CC) $(CFLAGS) $(PROGSPECSD) -c $< ebtables.c -o $@ -I$(KERNEL_INCLUDES) |
| 94 | |
| 95 | ebtablesd: $(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 |
| 101 | daemon: ebtablesd ebtablesu |
| 102 | |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 103 | $(MANDIR)/man8/ebtables.8: ebtables.8 |
| 104 | mkdir -p $(@D) |
| 105 | install -m 0644 -o root -g root $< $@ |
| 106 | |
Bart De Schuymer | 2eb1f92 | 2002-11-22 18:55:55 +0000 | [diff] [blame] | 107 | $(ETHERTYPESFILE): ethertypes |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 108 | mkdir -p $(@D) |
| 109 | install -m 0644 -o root -g root $< $@ |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 110 | |
Bart De Schuymer | 3289054 | 2002-07-10 20:09:56 +0000 | [diff] [blame] | 111 | .PHONY: exec |
Bart De Schuymer | 6622a01 | 2005-01-19 21:09:05 +0000 | [diff] [blame] | 112 | exec: ebtables daemon |
Bart De Schuymer | 3749f30 | 2004-02-11 21:23:38 +0000 | [diff] [blame] | 113 | mkdir -p $(BINDIR) |
Bart De Schuymer | 6622a01 | 2005-01-19 21:09:05 +0000 | [diff] [blame] | 114 | 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 Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 117 | |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 118 | .PHONY: install |
Bart De Schuymer | f43456b | 2003-02-15 11:12:01 +0000 | [diff] [blame] | 119 | install: $(MANDIR)/man8/ebtables.8 $(ETHERTYPESFILE) exec |
Bart De Schuymer | 0f5e3fe | 2004-02-10 18:08:00 +0000 | [diff] [blame] | 120 | mkdir -p $(LIBDIR) |
Bart De Schuymer | 64182a3 | 2004-01-21 20:39:54 +0000 | [diff] [blame] | 121 | install -m 0755 extensions/*.so $(LIBDIR) |
| 122 | install -m 0755 *.so $(LIBDIR) |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 123 | |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 124 | .PHONY: clean |
Bart De Schuymer | 1abc55d | 2002-06-01 19:23:47 +0000 | [diff] [blame] | 125 | clean: |
Bart De Schuymer | 6622a01 | 2005-01-19 21:09:05 +0000 | [diff] [blame] | 126 | rm -f ebtables ebtablesd ebtablesu |
Bart De Schuymer | 64182a3 | 2004-01-21 20:39:54 +0000 | [diff] [blame] | 127 | rm -f *.o *.c~ *.so |
| 128 | rm -f extensions/*.o extensions/*.c~ extensions/*.so |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 129 | |
| 130 | DIR:=$(PROGNAME)-v$(PROGVERSION) |
| 131 | # This is used to make a new userspace release |
| 132 | .PHONY: release |
| 133 | release: |
| 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 Schuymer | 60c2009 | 2003-07-23 21:34:21 +0000 | [diff] [blame] | 144 | install -m 0644 -o root -g root \ |
| 145 | include/ebtables.h include/linux/netfilter_bridge/ |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 146 | make clean |
Bart De Schuymer | e29506d | 2003-07-26 11:53:32 +0000 | [diff] [blame] | 147 | touch * |
| 148 | touch extensions/* |
| 149 | touch include/* |
| 150 | touch include/linux/* |
| 151 | touch include/linux/netfilter_bridge/* |
Bart De Schuymer | 0f8c499 | 2002-11-20 19:41:02 +0000 | [diff] [blame] | 152 | cd ..;tar -c $(DIR) | gzip >$(DIR).tar.gz |
Bart De Schuymer | 8bde101 | 2004-11-20 13:00:52 +0000 | [diff] [blame] | 153 | |
| 154 | .PHONY: test_ulog |
| 155 | test_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 |
| 161 | examples: test_ulog |