blob: 1a4c5d1a26250a74f9c7a2141abf07aaf2f88760 [file] [log] [blame]
Marc Bouchere6869a82000-03-20 06:03:29 +00001# Standard part of Makefile for topdir.
2TOPLEVEL_INCLUDED=YES
3
4ifndef KERNEL_DIR
5KERNEL_DIR=/usr/src/linux
6endif
Rusty Russell2e5f9532001-01-07 09:37:02 +00007NETFILTER_VERSION:=1.2
Rusty Russell8e07bd72000-12-19 03:11:00 +00008OLD_NETFILTER_VERSION:=1.1.2
Marc Bouchere6869a82000-03-20 06:03:29 +00009
10LIBDIR:=/usr/local/lib
11BINDIR:=/usr/local/bin
12MANDIR:=/usr/local/man
James Morrisc82e9ac2000-11-24 14:34:02 +000013INCDIR:=/usr/local/include
Marc Bouchere6869a82000-03-20 06:03:29 +000014
Rusty Russell8e07bd72000-12-19 03:11:00 +000015# Need libc6 for this. Should covert to autoconf.
Rusty Russell2e5f9532001-01-07 09:37:02 +000016ifneq ($(shell ldd --v | fgrep 2.2),)
Rusty Russell8e07bd72000-12-19 03:11:00 +000017DO_IPV6=1
18endif
19
Rusty Russell8c245b52000-07-14 08:01:22 +000020COPT_FLAGS:=-O2 -DNDEBUG
21CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -Iinclude/ -I$(KERNEL_DIR)/include -DNETFILTER_VERSION=\"$(NETFILTER_VERSION)\" #-g #-pg
Marc Bouchere6869a82000-03-20 06:03:29 +000022
Rusty Russell5622f212000-05-02 16:42:09 +000023DEPFILES = $(SHARED_LIBS:%.so=%.d)
Marc Bouchere6869a82000-03-20 06:03:29 +000024SH_CFLAGS:=$(CFLAGS) -fPIC
Marc Bouchere6869a82000-03-20 06:03:29 +000025
Rusty Russell2e5f9532001-01-07 09:37:02 +000026EXTRAS+=iptables iptables.o
Rusty Russell01c45202001-01-07 06:50:31 +000027EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
28
29# Still experimental.
30EXTRAS_EXP+=iptables-save iptables-restore
31EXTRA_INSTALLS_EXP:=$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8
Rusty Russell8e07bd72000-12-19 03:11:00 +000032
33ifdef DO_IPV6
34EXTRAS+=ip6tables ip6tables.o
Rusty Russell2e5f9532001-01-07 09:37:02 +000035EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables
Rusty Russell8e07bd72000-12-19 03:11:00 +000036endif
Marc Bouchere6869a82000-03-20 06:03:29 +000037
Rusty Russell09b9a412000-04-27 10:16:47 +000038# Sparc64 hack
39ifeq ($(shell uname -m),sparc64)
40# The kernel is 64-bit, even though userspace is 32.
Rusty Russellc8d7d892000-09-19 07:01:00 +000041CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
Rusty Russell09b9a412000-04-27 10:16:47 +000042endif
43
Marc Bouchere6869a82000-03-20 06:03:29 +000044ifndef IPT_LIBDIR
45IPT_LIBDIR:=$(LIBDIR)/iptables
46endif
47
Rusty Russell52451822000-08-27 07:47:46 +000048default: print-extensions all
49
50print-extensions:
Rusty Russellc8d7d892000-09-19 07:01:00 +000051 @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)
Marc Bouchere6869a82000-03-20 06:03:29 +000052
53iptables.o: iptables.c
54 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
55
56iptables: iptables-standalone.c iptables.o libiptc/libiptc.a
57 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
58
59$(DESTDIR)$(BINDIR)/iptables: iptables
60 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
61 cp $< $@
62
63iptables-save: iptables-save.c iptables.o libiptc/libiptc.a
64 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
65
66$(DESTDIR)$(BINDIR)/iptables-save: iptables-save
67 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
68 cp $< $@
69
70iptables-restore: iptables-restore.c iptables.o libiptc/libiptc.a
71 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
72
73$(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
74 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
75 cp $< $@
76
Philip Blundell8c700902000-05-15 02:17:52 +000077ip6tables.o: ip6tables.c
78 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
79
80ip6tables: ip6tables-standalone.c ip6tables.o libiptc/libiptc.a
81 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
82
83$(DESTDIR)$(BINDIR)/ip6tables: ip6tables
84 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
85 cp $< $@
86
87ip6tables-save: ip6tables-save.c ip6tables.o libiptc/libiptc.a
88 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
89
90$(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
91 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
92 cp $< $@
93
94ip6tables-restore: ip6tables-restore.c ip6tables.o libiptc/libiptc.a
95 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
96
97$(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
98 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
99 cp $< $@
100
Rusty Russell01c45202001-01-07 06:50:31 +0000101$(DESTDIR)$(MANDIR)/man8/%.8: %.8
Marc Bouchere6869a82000-03-20 06:03:29 +0000102 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
103 cp $< $@
104
105EXTRA_DEPENDS+=iptables-standalone.d iptables.d
106
107iptables-standalone.d iptables.d: %.d: %.c
108 @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
109
James Morrisc82e9ac2000-11-24 14:34:02 +0000110
111# Development Targets
112install-devel-man3: $(DEVEL_MAN3)
113 @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
114 @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3
115
116install-devel-headers: $(DEVEL_HEADERS)
117 @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
118 @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)
119
120install-devel-libs: $(DEVEL_LIBS)
121 @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
122 @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)
123
124install-devel: all install-devel-man3 install-devel-headers install-devel-libs
125
Rusty Russell905795c2000-04-19 11:22:03 +0000126distclean: clean
Rusty Russella470f332000-11-07 04:08:34 +0000127 @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
Rusty Russell175f6412000-03-24 09:32:20 +0000128
Rusty Russell52451822000-08-27 07:47:46 +0000129.PHONY: patch-o-matic
Rusty Russella470f332000-11-07 04:08:34 +0000130patch-o-matic/ patch-o-matic:
Rusty Russell52451822000-08-27 07:47:46 +0000131 @cd $@ && KERNEL_DIR=$(KERNEL_DIR) ./runme
132
Rusty Russell175f6412000-03-24 09:32:20 +0000133# Rusty's distro magic.
Rusty Russell2e5f9532001-01-07 09:37:02 +0000134distrib: check distclean delrelease /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 diff md5sums # nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000135
136# Makefile must not define:
137# -g -pg
Rusty Russell849779c2000-04-23 15:51:51 +0000138# And must define -NDEBUG
Rusty Russell175f6412000-03-24 09:32:20 +0000139check:
Rusty Russell849779c2000-04-23 15:51:51 +0000140 @if echo $(CFLAGS) | egrep -e '-g|-pg' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
141 @if echo $(CFLAGS) | egrep -e NDEBUG >/dev/null; then exit 0; else echo Define -DNDEBUG; exit 1; fi
Rusty Russell175f6412000-03-24 09:32:20 +0000142
143nowhitespace:
Rusty Russell2e5f9532001-01-07 09:37:02 +0000144 @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
Rusty Russell175f6412000-03-24 09:32:20 +0000145
146delrelease:
147 rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
148
149/home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2:
Rusty Russell905795c2000-04-19 11:22:03 +0000150 cd .. && ln -sf userspace iptables-$(NETFILTER_VERSION) && tar cvf - --exclude CVS iptables-$(NETFILTER_VERSION)/. | bzip2 -9 > $@ && rm iptables-$(NETFILTER_VERSION)
Rusty Russell175f6412000-03-24 09:32:20 +0000151
152diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
153 @mkdir /tmp/diffdir
Rusty Russell01c45202001-01-07 06:50:31 +0000154 @cd /tmp/diffdir && tar -x --bzip2 -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
155 @set -e; cd /tmp/diffdir; tar -x --bzip2 -f /home/public/netfilter/iptables-$(OLD_NETFILTER_VERSION).tar.bz2; echo Creating patch-iptables-$(OLD_NETFILTER_VERSION)-$(NETFILTER_VERSION).bz2; diff -urN iptables-$(OLD_NETFILTER_VERSION) iptables-$(NETFILTER_VERSION) | bzip2 -9 > /home/public/netfilter/patch-iptables-$(OLD_NETFILTER_VERSION)-$(NETFILTER_VERSION).bz2
Rusty Russell175f6412000-03-24 09:32:20 +0000156 @rm -rf /tmp/diffdir
157
158md5sums:
159 cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2
160
Marc Bouchere6869a82000-03-20 06:03:29 +0000161# $(wildcard) fails wierdly with make v.3.78.1.
162include $(shell echo */Makefile)
163include Rules.make