blob: 9ce96ce44318d750298f08e603ff3b6d2aa84cc1 [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
10BINDIR:=/sbin
11ETCDIR:=/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 Schuymer3749f302004-02-11 21:23:38 +000041BINFILE:=$(BINDIR)/ebtables
Bart De Schuymerf43456b2003-02-15 11:12:01 +000042
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000043PROGSPECS:=-DPROGVERSION=\"$(PROGVERSION)\" \
44 -DPROGNAME=\"$(PROGNAME)\" \
45 -DPROGDATE=\"$(PROGDATE)\" \
fnm39bb3d0a2002-11-21 10:42:56 +000046 -D_PATH_ETHERTYPES=\"$(ETHERTYPESFILE)\"
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000047
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000048
49all: ebtables
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000050
51communication.o: communication.c include/ebtables_u.h
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000052 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
53
Bart De Schuymer8339ff12004-01-14 20:05:27 +000054libebtc.o: libebtc.c include/ebtables_u.h
55 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
56
57useful_functions.o: useful_functions.c include/ebtables_u.h
58 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
59
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000060getethertype.o: getethertype.c include/ethernetdb.h
fnm39bb3d0a2002-11-21 10:42:56 +000061 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -Iinclude/
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000062
63ebtables.o: ebtables.c include/ebtables_u.h
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000064 $(CC) $(CFLAGS) $(PROGSPECS) -c -o $@ $< -I$(KERNEL_INCLUDES)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000065
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000066ebtables: $(OBJECTS)
Bart De Schuymer64182a32004-01-21 20:39:54 +000067 ld -shared -soname libebtc.so -o libebtc.so -lc $(OBJECTS2)
68 $(CC) $(CFLAGS) -o $@ ebtables.o -I$(KERNEL_INCLUDES) -L/root/ \
69 -L. -Lextensions/ -lebtc $(EXT_LIBSI)
70
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000071
72$(MANDIR)/man8/ebtables.8: ebtables.8
73 mkdir -p $(@D)
74 install -m 0644 -o root -g root $< $@
75
Bart De Schuymer2eb1f922002-11-22 18:55:55 +000076$(ETHERTYPESFILE): ethertypes
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000077 mkdir -p $(@D)
78 install -m 0644 -o root -g root $< $@
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000079
Bart De Schuymer32890542002-07-10 20:09:56 +000080.PHONY: exec
81exec: ebtables
Bart De Schuymer3749f302004-02-11 21:23:38 +000082 mkdir -p $(BINDIR)
Bart De Schuymerf43456b2003-02-15 11:12:01 +000083 install -m 0755 -o root -g root $< $(BINFILE)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000084
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000085.PHONY: install
Bart De Schuymerf43456b2003-02-15 11:12:01 +000086install: $(MANDIR)/man8/ebtables.8 $(ETHERTYPESFILE) exec
Bart De Schuymer0f5e3fe2004-02-10 18:08:00 +000087 mkdir -p $(LIBDIR)
Bart De Schuymer64182a32004-01-21 20:39:54 +000088 install -m 0755 extensions/*.so $(LIBDIR)
89 install -m 0755 *.so $(LIBDIR)
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000090
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000091.PHONY: clean
Bart De Schuymer1abc55d2002-06-01 19:23:47 +000092clean:
Bart De Schuymer7ddc0e62002-06-01 21:34:16 +000093 rm -f ebtables
Bart De Schuymer64182a32004-01-21 20:39:54 +000094 rm -f *.o *.c~ *.so
95 rm -f extensions/*.o extensions/*.c~ extensions/*.so
Bart De Schuymer0f8c4992002-11-20 19:41:02 +000096
97DIR:=$(PROGNAME)-v$(PROGVERSION)
98# This is used to make a new userspace release
99.PHONY: release
100release:
101 mkdir -p include/linux/netfilter_bridge
102 install -m 0644 -o root -g root \
103 $(KERNEL_INCLUDES)/linux/netfilter_bridge.h include/linux/
104# To keep possible compile error complaints about undefined ETH_P_8021Q
105# off my back
106 install -m 0644 -o root -g root \
107 $(KERNEL_INCLUDES)/linux/if_ether.h include/linux/
108 install -m 0644 -o root -g root \
109 $(KERNEL_INCLUDES)/linux/netfilter_bridge/*.h \
110 include/linux/netfilter_bridge/
Bart De Schuymer60c20092003-07-23 21:34:21 +0000111 install -m 0644 -o root -g root \
112 include/ebtables.h include/linux/netfilter_bridge/
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000113 make clean
Bart De Schuymere29506d2003-07-26 11:53:32 +0000114 touch *
115 touch extensions/*
116 touch include/*
117 touch include/linux/*
118 touch include/linux/netfilter_bridge/*
Bart De Schuymer0f8c4992002-11-20 19:41:02 +0000119 cd ..;tar -c $(DIR) | gzip >$(DIR).tar.gz