6 PROGVERSION
:=$(PROGVERSION_
)-$(PROGRELEASE
)
11 MANDIR
:=/usr
/local
/man
12 BINDIR
:=/usr
/local
/sbin
14 INITDIR
:=/etc
/rc.d
/init.d
15 SYSCONFIGDIR
:=/etc
/sysconfig
18 CFLAGS
:=-Wall
-Wunused
23 ifeq ($(shell uname
-m
),sparc64
)
24 CFLAGS
+=-DEBT_MIN_ALIGN
=8 -DKERNEL_64_USERSPACE_32
27 include extensions
/Makefile
29 OBJECTS2
:=getethertype.o communication.o libebtc.o \
30 useful_functions.o ebtables.o
32 OBJECTS
:=$(OBJECTS2
) $(EXT_OBJS
) $(EXT_LIBS
)
34 KERNEL_INCLUDES?
=include/
36 ETHERTYPESPATH?
=$(ETCDIR
)
37 ETHERTYPESFILE
:=$(ETHERTYPESPATH
)/ethertypes
39 PIPE_DIR?
=/tmp
/$(PROGNAME
)-v
$(PROGVERSION
)
40 PIPE
=$(PIPE_DIR
)/ebtablesd_pipe
41 EBTD_CMDLINE_MAXLN?
=2048
44 PROGSPECS
:=-DPROGVERSION
=\"$(PROGVERSION
)\" \
45 -DPROGNAME
=\"$(PROGNAME
)\" \
46 -DPROGDATE
=\"$(PROGDATE
)\" \
47 -D_PATH_ETHERTYPES
=\"$(ETHERTYPESFILE
)\" \
48 -DEBTD_ARGC_MAX
=$(EBTD_ARGC_MAX
) \
49 -DEBTD_CMDLINE_MAXLN
=$(EBTD_CMDLINE_MAXLN
)
51 # You can probably ignore this, ebtables{u,d} are normally not used
52 PROGSPECSD
:=-DPROGVERSION
=\"$(PROGVERSION
)\" \
53 -DPROGNAME
=\"$(PROGNAME
)\" \
54 -DPROGDATE
=\"$(PROGDATE
)\" \
55 -D_PATH_ETHERTYPES
=\"$(ETHERTYPESFILE
)\" \
56 -DEBTD_CMDLINE_MAXLN
=$(EBTD_CMDLINE_MAXLN
) \
57 -DEBTD_ARGC_MAX
=$(EBTD_ARGC_MAX
) \
58 -DEBTD_PIPE
=\"$(PIPE
)\" \
59 -DEBTD_PIPE_DIR
=\"$(PIPE_DIR
)\"
61 # Uncomment for debugging (slower)
62 #PROGSPECS+=-DEBT_DEBUG
63 #PROGSPECSD+=-DEBT_DEBUG
66 all: ebtables ebtables-restore
68 communication.o
: communication.c
include/ebtables_u.h
69 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -I
$(KERNEL_INCLUDES
)
71 libebtc.o
: libebtc.c
include/ebtables_u.h
72 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -I
$(KERNEL_INCLUDES
)
74 useful_functions.o
: useful_functions.c
include/ebtables_u.h
75 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -I
$(KERNEL_INCLUDES
)
77 getethertype.o
: getethertype.c
include/ethernetdb.h
78 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -Iinclude
/
80 ebtables.o
: ebtables.c
include/ebtables_u.h
81 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -I
$(KERNEL_INCLUDES
)
83 ebtables-standalone.o
: ebtables-standalone.c
include/ebtables_u.h
84 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
$< -o
$@
-I
$(KERNEL_INCLUDES
)
88 $(LD
) -shared
-soname libebtc.so
-o libebtc.so
-lc
$(OBJECTS2
)
90 ebtables
: $(OBJECTS
) ebtables-standalone.o libebtc
91 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) -o
$@ ebtables-standalone.o
-I
$(KERNEL_INCLUDES
) -L.
-Lextensions
-lebtc
$(EXT_LIBSI
) \
94 ebtablesu
: ebtablesu.c
95 $(CC
) $(CFLAGS
) $(PROGSPECSD
) $< -o
$@
97 ebtablesd.o
: ebtablesd.c
include/ebtables_u.h
98 $(CC
) $(CFLAGS
) $(PROGSPECSD
) -c
$< -o
$@
-I
$(KERNEL_INCLUDES
)
100 ebtablesd
: $(OBJECTS
) ebtablesd.o libebtc
101 $(CC
) $(CFLAGS
) -o
$@ ebtablesd.o
-I
$(KERNEL_INCLUDES
) -L.
-Lextensions
-lebtc
$(EXT_LIBSI
) \
104 ebtables-restore.o
: ebtables-restore.c
include/ebtables_u.h
105 $(CC
) $(CFLAGS
) $(PROGSPECS
) -c
$< -o
$@
-I
$(KERNEL_INCLUDES
)
107 ebtables-restore
: $(OBJECTS
) ebtables-restore.o libebtc
108 $(CC
) $(CFLAGS
) -o
$@ ebtables-restore.o
-I
$(KERNEL_INCLUDES
) -L.
-Lextensions
-lebtc
$(EXT_LIBSI
) \
112 daemon
: ebtablesd ebtablesu
114 # a little scripting for a static binary, making one for ebtables-restore
115 # should be completely analogous
116 static
: extensions
/ebt_
*.c extensions
/ebtable_
*.c ebtables.c communication.c ebtables-standalone.c getethertype.c libebtc.c useful_functions.c
117 cp ebtables-standalone.c ebtables-standalone.c_
; \
118 cp
include/ebtables_u.h
include/ebtables_u.h_
; \
119 sed
"s/ main(/ pseudomain(/" ebtables-standalone.c
> ebtables-standalone.c__
; \
120 mv ebtables-standalone.c__ ebtables-standalone.c
; \
121 printf
"\nint main(int argc, char *argv[])\n{\n " >> ebtables-standalone.c
; \
122 for arg in
$(EXT_FUNC
) \
124 sed s
/_init
/_
$${arg}_init
/ extensions
/ebt_
$${arg}.c
> extensions
/ebt_
$${arg}.c_
; \
125 mv extensions
/ebt_
$${arg}.c_ extensions
/ebt_
$${arg}.c
; \
126 printf
"\t%s();\n" _
$${arg}_init
>> ebtables-standalone.c
; \
127 printf
"extern void %s();\n" _
$${arg}_init
>> include/ebtables_u.h
; \
129 for arg in
$(EXT_TABLES
) \
131 sed s
/_init
/_t_
$${arg}_init
/ extensions
/ebtable_
$${arg}.c
> extensions
/ebtable_
$${arg}.c_
; \
132 mv extensions
/ebtable_
$${arg}.c_ extensions
/ebtable_
$${arg}.c
; \
133 printf
"\t%s();\n" _t_
$${arg}_init
>> ebtables-standalone.c
; \
134 printf
"extern void %s();\n" _t_
$${arg}_init
>> include/ebtables_u.h
; \
136 printf
"\n\tpseudomain(argc, argv);\n\treturn 0;\n}\n" >> ebtables-standalone.c
;\
137 $(CC
) $(CFLAGS
) $(PROGSPECS
) -o
$@
$^
-I
$(KERNEL_INCLUDES
) -Iinclude
; \
138 for arg in
$(EXT_FUNC
) \
140 sed
"s/ .*_init/ _init/" extensions
/ebt_
$${arg}.c
> extensions
/ebt_
$${arg}.c_
; \
141 mv extensions
/ebt_
$${arg}.c_ extensions
/ebt_
$${arg}.c
; \
143 for arg in
$(EXT_TABLES
) \
145 sed
"s/ .*_init/ _init/" extensions
/ebtable_
$${arg}.c
> extensions
/ebtable_
$${arg}.c_
; \
146 mv extensions
/ebtable_
$${arg}.c_ extensions
/ebtable_
$${arg}.c
; \
148 mv ebtables-standalone.c_ ebtables-standalone.c
; \
149 mv
include/ebtables_u.h_
include/ebtables_u.h
151 tmp1
:=$(shell printf
$(BINDIR
) | sed
's/\//\\\//g')
152 tmp2
:=$(shell printf
$(SYSCONFIGDIR
) | sed
's/\//\\\//g')
153 tmp3
:=$(shell printf
$(PIPE
) | sed
's/\//\\\//g')
155 scripts
: ebtables-save ebtables.sysv ebtables-config
156 cat ebtables-save | sed
's/__EXEC_PATH__/$(tmp1)/g' > ebtables-save_
157 install -m
0755 -o root
-g root ebtables-save_
$(DESTDIR
)$(BINDIR
)/ebtables-save
158 cat ebtables.sysv | sed
's/__EXEC_PATH__/$(tmp1)/g' | sed
's/__SYSCONFIG__/$(tmp2)/g' > ebtables.sysv_
159 install -m
0755 -o root
-g root ebtables.sysv_
$(DESTDIR
)$(INITDIR
)/ebtables
160 cat ebtables-config | sed
's/__SYSCONFIG__/$(tmp2)/g' > ebtables-config_
161 install -m
0600 -o root
-g root ebtables-config_
$(DESTDIR
)$(SYSCONFIGDIR
)/ebtables-config
162 rm -f ebtables-save_ ebtables.sysv_ ebtables-config_
164 $(MANDIR
)/man8
/ebtables
.8: ebtables
.8
165 mkdir
-p
$(DESTDIR
)$(@D
)
166 sed
's/$$(VERSION)/$(PROGVERSION)/' ebtables
.8 | sed
's/$$(DATE)/$(PROGDATE)/' > ebtables
.8_
167 install -m
0644 -o root
-g root ebtables
.8_
$(DESTDIR
)$@
170 $(ETHERTYPESFILE
): ethertypes
171 mkdir
-p
$(DESTDIR
)$(@D
)
172 install -m
0644 -o root
-g root
$< $(DESTDIR
)$@
175 exec
: ebtables ebtables-restore
176 mkdir
-p
$(DESTDIR
)$(BINDIR
)
177 install -m
0755 -o root
-g root
$(PROGNAME
) $(DESTDIR
)$(BINDIR
)/$(PROGNAME
)
178 install -m
0755 -o root
-g root ebtables-restore
$(DESTDIR
)$(BINDIR
)/ebtables-restore
181 install: $(MANDIR
)/man8
/ebtables
.8 $(ETHERTYPESFILE
) exec scripts
182 mkdir
-p
$(DESTDIR
)$(LIBDIR
)
183 install -m
0755 extensions
/*.so
$(DESTDIR
)$(LIBDIR
)
184 install -m
0755 *.so
$(DESTDIR
)$(LIBDIR
)
188 rm -f ebtables ebtables-restore ebtablesd ebtablesu static
190 rm -f extensions
/*.o extensions
/*.c~ extensions
/*.so
include/*~
192 DIR
:=$(PROGNAME
)-v
$(PROGVERSION
)
193 CVSDIRS
:=CVS extensions
/CVS examples
/CVS examples
/perf_test
/CVS \
194 examples
/ulog
/CVS
include/CVS
195 # This is used to make a new userspace release, some files are altered so
196 # do this on a temporary version
199 rm -f extensions
/ebt_inat.c
201 mkdir
-p
include/linux
/netfilter_bridge
202 install -m
0644 -o root
-g root \
203 $(KERNEL_INCLUDES
)/linux
/netfilter_bridge.h
include/linux
/
204 # To keep possible compile error complaints about undefined ETH_P_8021Q
206 install -m
0644 -o root
-g root \
207 $(KERNEL_INCLUDES
)/linux
/if_ether.h
include/linux
/
208 install -m
0644 -o root
-g root \
209 $(KERNEL_INCLUDES
)/linux
/types.h
include/linux
/
210 install -m
0644 -o root
-g root \
211 $(KERNEL_INCLUDES
)/linux
/netfilter_bridge
/*.h \
212 include/linux
/netfilter_bridge
/
213 install -m
0644 -o root
-g root \
214 include/ebtables.h
include/linux
/netfilter_bridge
/
219 touch
include/linux
/*
220 touch
include/linux
/netfilter_bridge
/*
221 sed
-i
's/$$(VERSION)/$(PROGVERSION)/' ebtables
.8
222 sed
-i
's/$$(DATE)/$(PROGDATE)/' ebtables
.8
223 sed
-i
's/$$(VERSION)/$(PROGVERSION_)/' ebtables.spec
224 sed
-i
's/$$(RELEASE)/$(PROGRELEASE)/' ebtables.spec
225 cd ..
;tar -c
$(DIR
) | gzip
>$(DIR
).
tar.gz
; cd
-
228 # This will make the rpm and put it in /usr/src/redhat/RPMS
229 # (do this as root after make release)
232 cp ..
/$(DIR
).
tar.gz
/usr
/src
/redhat
/SOURCES
/
233 rpmbuild
--buildroot
$(shell mktemp
-td
$(DIR
)-XXXXX
) -bb ebtables.spec
236 test_ulog
: examples
/ulog
/test_ulog.c getethertype.o
237 $(CC
) $(CFLAGS
) $< -o test_ulog
-I
$(KERNEL_INCLUDES
) -lc \
239 mv test_ulog examples
/ulog
/