6 PROGVERSION
:=$(PROGVERSION_
)-$(PROGRELEASE
)
8 LOCKFILE?
=/var
/lib
/ebtables
/lock
9 LOCKDIR
:=$(shell echo
$(LOCKFILE
) | sed
's/\(.*\)\/.*/\1/')/
13 MANDIR
:=/usr
/local
/man
14 BINDIR
:=/usr
/local
/sbin
16 INITDIR
:=/etc
/rc.d
/init.d
17 SYSCONFIGDIR
:=/etc
/sysconfig
20 CFLAGS
:=-Wall
-Wunused
-Werror
21 CFLAGS_SH_LIB
:=-fPIC
-O3
24 ifeq ($(shell uname
-m
),sparc64
)
25 CFLAGS
+=-DEBT_MIN_ALIGN
=8 -DKERNEL_64_USERSPACE_32
28 include extensions
/Makefile
30 OBJECTS2
:=getethertype.o communication.o libebtc.o \
31 useful_functions.o ebtables.o
33 OBJECTS
:=$(OBJECTS2
) $(EXT_OBJS
) $(EXT_LIBS
)
35 KERNEL_INCLUDES?
=include/
37 ETHERTYPESPATH?
=$(ETCDIR
)
38 ETHERTYPESFILE
:=$(ETHERTYPESPATH
)/ethertypes
40 PIPE_DIR?
=/tmp
/$(PROGNAME
)-v
$(PROGVERSION
)
41 PIPE
=$(PIPE_DIR
)/ebtablesd_pipe
42 EBTD_CMDLINE_MAXLN?
=2048
45 PROGSPECS
:=-DPROGVERSION
=\"$(PROGVERSION
)\" \
46 -DPROGNAME
=\"$(PROGNAME
)\" \
47 -DPROGDATE
=\"$(PROGDATE
)\" \
48 -D_PATH_ETHERTYPES
=\"$(ETHERTYPESFILE
)\" \
49 -DEBTD_ARGC_MAX
=$(EBTD_ARGC_MAX
) \
50 -DEBTD_CMDLINE_MAXLN
=$(EBTD_CMDLINE_MAXLN
) \
51 -DLOCKFILE
=\"$(LOCKFILE
)\" \
52 -DLOCKDIR
=\"$(LOCKDIR
)\"
54 # You can probably ignore this, ebtables{u,d} are normally not used
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
)\"
64 # Uncomment for debugging (slower)
65 #PROGSPECS+=-DEBT_DEBUG
66 #PROGSPECSD+=-DEBT_DEBUG
69 all: ebtables ebtables-restore
71 communication.o
: communication.c
include/ebtables_u.h
72 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -I
$(KERNEL_INCLUDES
)
74 libebtc.o
: libebtc.c
include/ebtables_u.h
75 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -I
$(KERNEL_INCLUDES
)
77 useful_functions.o
: useful_functions.c
include/ebtables_u.h
78 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -I
$(KERNEL_INCLUDES
)
80 getethertype.o
: getethertype.c
include/ethernetdb.h
81 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -Iinclude
/
83 ebtables.o
: ebtables.c
include/ebtables_u.h
84 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
-o
$@
$< -I
$(KERNEL_INCLUDES
)
86 ebtables-standalone.o
: ebtables-standalone.c
include/ebtables_u.h
87 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(PROGSPECS
) -c
$< -o
$@
-I
$(KERNEL_INCLUDES
)
89 libebtc.so
: $(OBJECTS2
)
90 $(CC
) -shared
$(LDFLAGS
) -Wl
,-soname
,libebtc.so
-o libebtc.so
-lc
$(OBJECTS2
)
92 ebtables
: $(OBJECTS
) ebtables-standalone.o libebtc.so
93 $(CC
) $(CFLAGS
) $(CFLAGS_SH_LIB
) $(LDFLAGS
) -o
$@ ebtables-standalone.o
-I
$(KERNEL_INCLUDES
) -L.
-Lextensions
-lebtc
$(EXT_LIBSI
) \
96 ebtablesu
: ebtablesu.c
97 $(CC
) $(CFLAGS
) $(PROGSPECSD
) $< -o
$@
99 ebtablesd.o
: ebtablesd.c
include/ebtables_u.h
100 $(CC
) $(CFLAGS
) $(PROGSPECSD
) -c
$< -o
$@
-I
$(KERNEL_INCLUDES
)
102 ebtablesd
: $(OBJECTS
) ebtablesd.o libebtc.so
103 $(CC
) $(CFLAGS
) -o
$@ ebtablesd.o
-I
$(KERNEL_INCLUDES
) -L.
-Lextensions
-lebtc
$(EXT_LIBSI
) \
106 ebtables-restore.o
: ebtables-restore.c
include/ebtables_u.h
107 $(CC
) $(CFLAGS
) $(PROGSPECS
) -c
$< -o
$@
-I
$(KERNEL_INCLUDES
)
109 ebtables-restore
: $(OBJECTS
) ebtables-restore.o libebtc.so
110 $(CC
) $(CFLAGS
) $(LDFLAGS
) -o
$@ ebtables-restore.o
-I
$(KERNEL_INCLUDES
) -L.
-Lextensions
-lebtc
$(EXT_LIBSI
) \
114 daemon
: ebtablesd ebtablesu
116 # a little scripting for a static binary, making one for ebtables-restore
117 # should be completely analogous
118 static
: extensions
/ebt_
*.c extensions
/ebtable_
*.c ebtables.c communication.c ebtables-standalone.c getethertype.c libebtc.c useful_functions.c
119 cp ebtables-standalone.c ebtables-standalone.c_
; \
120 cp
include/ebtables_u.h
include/ebtables_u.h_
; \
121 sed
"s/ main(/ pseudomain(/" ebtables-standalone.c
> ebtables-standalone.c__
; \
122 mv ebtables-standalone.c__ ebtables-standalone.c
; \
123 printf
"\nint main(int argc, char *argv[])\n{\n " >> ebtables-standalone.c
; \
124 for arg in
$(EXT_FUNC
) \
126 sed s
/_init
/_
$${arg}_init
/ extensions
/ebt_
$${arg}.c
> extensions
/ebt_
$${arg}.c_
; \
127 mv extensions
/ebt_
$${arg}.c_ extensions
/ebt_
$${arg}.c
; \
128 printf
"\t%s();\n" _
$${arg}_init
>> ebtables-standalone.c
; \
129 printf
"extern void %s();\n" _
$${arg}_init
>> include/ebtables_u.h
; \
131 for arg in
$(EXT_TABLES
) \
133 sed s
/_init
/_t_
$${arg}_init
/ extensions
/ebtable_
$${arg}.c
> extensions
/ebtable_
$${arg}.c_
; \
134 mv extensions
/ebtable_
$${arg}.c_ extensions
/ebtable_
$${arg}.c
; \
135 printf
"\t%s();\n" _t_
$${arg}_init
>> ebtables-standalone.c
; \
136 printf
"extern void %s();\n" _t_
$${arg}_init
>> include/ebtables_u.h
; \
138 printf
"\n\tpseudomain(argc, argv);\n\treturn 0;\n}\n" >> ebtables-standalone.c
;\
139 $(CC
) $(CFLAGS
) $(LDFLAGS
) $(PROGSPECS
) -o
$@
$^
-I
$(KERNEL_INCLUDES
) -Iinclude
; \
140 for arg in
$(EXT_FUNC
) \
142 sed
"s/ .*_init/ _init/" extensions
/ebt_
$${arg}.c
> extensions
/ebt_
$${arg}.c_
; \
143 mv extensions
/ebt_
$${arg}.c_ extensions
/ebt_
$${arg}.c
; \
145 for arg in
$(EXT_TABLES
) \
147 sed
"s/ .*_init/ _init/" extensions
/ebtable_
$${arg}.c
> extensions
/ebtable_
$${arg}.c_
; \
148 mv extensions
/ebtable_
$${arg}.c_ extensions
/ebtable_
$${arg}.c
; \
150 mv ebtables-standalone.c_ ebtables-standalone.c
; \
151 mv
include/ebtables_u.h_
include/ebtables_u.h
153 tmp1
:=$(shell printf
$(BINDIR
) | sed
's/\//\\\//g')
154 tmp2
:=$(shell printf
$(SYSCONFIGDIR
) | sed
's/\//\\\//g')
155 tmp3
:=$(shell printf
$(PIPE
) | sed
's/\//\\\//g')
157 scripts
: ebtables-save ebtables.sysv ebtables-config
158 cat ebtables-save | sed
's/__EXEC_PATH__/$(tmp1)/g' > ebtables-save_
159 mkdir
-p
$(DESTDIR
)$(BINDIR
)
160 install -m
0755 -o root
-g root ebtables-save_
$(DESTDIR
)$(BINDIR
)/ebtables-save
161 cat ebtables.sysv | sed
's/__EXEC_PATH__/$(tmp1)/g' | sed
's/__SYSCONFIG__/$(tmp2)/g' > ebtables.sysv_
162 if
[ "$(DESTDIR)" != "" ]; then mkdir
-p
$(DESTDIR
)$(INITDIR
); fi
163 if
test -d
$(DESTDIR
)$(INITDIR
); then
install -m
0755 -o root
-g root ebtables.sysv_
$(DESTDIR
)$(INITDIR
)/ebtables
; fi
164 cat ebtables-config | sed
's/__SYSCONFIG__/$(tmp2)/g' > ebtables-config_
165 if
[ "$(DESTDIR)" != "" ]; then mkdir
-p
$(DESTDIR
)$(SYSCONFIGDIR
); fi
166 if
test -d
$(DESTDIR
)$(SYSCONFIGDIR
); then
install -m
0600 -o root
-g root ebtables-config_
$(DESTDIR
)$(SYSCONFIGDIR
)/ebtables-config
; fi
167 rm -f ebtables-save_ ebtables.sysv_ ebtables-config_
169 tmp4
:=$(shell printf
$(LOCKFILE
) | sed
's/\//\\\//g')
170 $(MANDIR
)/man8
/ebtables
.8: ebtables
.8
171 mkdir
-p
$(DESTDIR
)$(@D
)
172 sed
-e
's/$$(VERSION)/$(PROGVERSION)/' -e
's/$$(DATE)/$(PROGDATE)/' -e
's/$$(LOCKFILE)/$(tmp4)/' ebtables
.8 > ebtables
.8_
173 install -m
0644 -o root
-g root ebtables
.8_
$(DESTDIR
)$@
176 $(DESTDIR
)$(ETHERTYPESFILE
): ethertypes
178 install -m
0644 -o root
-g root
$< $@
181 exec
: ebtables ebtables-restore
182 mkdir
-p
$(DESTDIR
)$(BINDIR
)
183 install -m
0755 -o root
-g root
$(PROGNAME
) $(DESTDIR
)$(BINDIR
)/$(PROGNAME
)
184 install -m
0755 -o root
-g root ebtables-restore
$(DESTDIR
)$(BINDIR
)/ebtables-restore
187 install: $(MANDIR
)/man8
/ebtables
.8 $(DESTDIR
)$(ETHERTYPESFILE
) exec scripts
188 mkdir
-p
$(DESTDIR
)$(LIBDIR
)
189 install -m
0755 extensions
/*.so
$(DESTDIR
)$(LIBDIR
)
190 install -m
0755 *.so
$(DESTDIR
)$(LIBDIR
)
194 rm -f ebtables ebtables-restore ebtablesd ebtablesu static
196 rm -f extensions
/*.o extensions
/*.c~ extensions
/*.so
include/*~
198 DIR
:=$(PROGNAME
)-v
$(PROGVERSION
)
199 CVSDIRS
:=CVS extensions
/CVS examples
/CVS examples
/perf_test
/CVS \
200 examples
/ulog
/CVS
include/CVS
201 # This is used to make a new userspace release, some files are altered so
202 # do this on a temporary version
205 rm -f extensions
/ebt_inat.c
207 mkdir
-p
include/linux
/netfilter_bridge
208 install -m
0644 -o root
-g root \
209 $(KERNEL_INCLUDES
)/linux
/netfilter_bridge.h
include/linux
/
210 # To keep possible compile error complaints about undefined ETH_P_8021Q
212 install -m
0644 -o root
-g root \
213 $(KERNEL_INCLUDES
)/linux
/if_ether.h
include/linux
/
214 install -m
0644 -o root
-g root \
215 $(KERNEL_INCLUDES
)/linux
/types.h
include/linux
/
216 install -m
0644 -o root
-g root \
217 $(KERNEL_INCLUDES
)/linux
/netfilter_bridge
/*.h \
218 include/linux
/netfilter_bridge
/
219 install -m
0644 -o root
-g root \
220 include/ebtables.h
include/linux
/netfilter_bridge
/
225 touch
include/linux
/*
226 touch
include/linux
/netfilter_bridge
/*
227 sed
-i
-e
's/$$(VERSION)/$(PROGVERSION)/' -e
's/$$(DATE)/$(PROGDATE)/' -e
's/$$(LOCKFILE)/$(tmp4)/' ebtables
.8
228 sed
-i
-e
's/$$(VERSION)/$(PROGVERSION_)/' -e
's/$$(RELEASE)/$(PROGRELEASE)/' ebtables.spec
229 cd ..
;tar -c
$(DIR
) | gzip
>$(DIR
).
tar.gz
; cd
-
232 # This will make the rpm and put it in /usr/src/redhat/RPMS
233 # (do this as root after make release)
236 cp ..
/$(DIR
).
tar.gz
/usr
/src
/redhat
/SOURCES
/
237 rpmbuild
--buildroot
$(shell mktemp
-td
$(DIR
)-XXXXX
) -bb ebtables.spec
240 test_ulog
: examples
/ulog
/test_ulog.c getethertype.o
241 $(CC
) $(CFLAGS
) $< -o test_ulog
-I
$(KERNEL_INCLUDES
) -lc \
243 mv test_ulog examples
/ulog
/