Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 1 | # Standard part of Makefile for topdir. |
| 2 | TOPLEVEL_INCLUDED=YES |
| 3 | |
| 4 | ifndef KERNEL_DIR |
| 5 | KERNEL_DIR=/usr/src/linux |
| 6 | endif |
Harald Welte | feb4154 | 2001-03-19 17:41:45 +0000 | [diff] [blame] | 7 | NETFILTER_VERSION:=1.2.1a |
Harald Welte | 10c6888 | 2001-03-16 13:40:51 +0000 | [diff] [blame] | 8 | OLD_NETFILTER_VERSION:=1.2 |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 9 | |
Rusty Russell | 50a8efe | 2001-02-03 10:50:04 +0000 | [diff] [blame] | 10 | # Waiting for inclusions in the kernel tree. |
Harald Welte | feb4154 | 2001-03-19 17:41:45 +0000 | [diff] [blame] | 11 | PENDING_PATCHES:=dropped-table.patch seqoffset.patch irc-conntrack-nat.patch |
Rusty Russell | 50a8efe | 2001-02-03 10:50:04 +0000 | [diff] [blame] | 12 | # These went in previous kernels. |
Svenning Soerensen | 19b6b61 | 2001-04-12 16:06:53 +0000 | [diff] [blame] | 13 | PENDING_PATCHES+=ipv6-fixes.patch.ipv6 masquerade+fwmark.patch nat-overlap.patch ppc-sparc-mangle.patch tos-fix.patch masq-dynaddr.patch |
Rusty Russell | 50a8efe | 2001-02-03 10:50:04 +0000 | [diff] [blame] | 14 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 15 | LIBDIR:=/usr/local/lib |
Rusty Russell | 7fef194 | 2001-01-08 07:44:46 +0000 | [diff] [blame] | 16 | BINDIR:=/usr/local/sbin |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 17 | MANDIR:=/usr/local/man |
James Morris | c82e9ac | 2000-11-24 14:34:02 +0000 | [diff] [blame] | 18 | INCDIR:=/usr/local/include |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 19 | |
Rusty Russell | 209820b | 2001-01-08 08:14:33 +0000 | [diff] [blame] | 20 | # Need libc6 for this. FIXME: Should covert to autoconf. |
| 21 | ifneq ($(shell ldd --version 2>/dev/null | fgrep 2.2),) |
Rusty Russell | 8e07bd7 | 2000-12-19 03:11:00 +0000 | [diff] [blame] | 22 | DO_IPV6=1 |
| 23 | endif |
| 24 | |
Rusty Russell | 8c245b5 | 2000-07-14 08:01:22 +0000 | [diff] [blame] | 25 | COPT_FLAGS:=-O2 -DNDEBUG |
Rusty Russell | 008a83f | 2001-02-28 11:21:53 +0000 | [diff] [blame] | 26 | CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DNETFILTER_VERSION=\"$(NETFILTER_VERSION)\" #-g #-pg |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 27 | |
Rusty Russell | 5622f21 | 2000-05-02 16:42:09 +0000 | [diff] [blame] | 28 | DEPFILES = $(SHARED_LIBS:%.so=%.d) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 29 | SH_CFLAGS:=$(CFLAGS) -fPIC |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 30 | |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 31 | EXTRAS+=iptables iptables.o |
Rusty Russell | 01c4520 | 2001-01-07 06:50:31 +0000 | [diff] [blame] | 32 | EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8 |
| 33 | |
| 34 | # Still experimental. |
Harald Welte | 8a6831a | 2001-03-15 15:33:56 +0000 | [diff] [blame] | 35 | EXTRAS_EXP+=iptables-save iptables-restore |
Harald Welte | 46d4d0a | 2001-03-16 15:48:56 +0000 | [diff] [blame] | 36 | EXTRA_INSTALLS_EXP+=$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8 |
Rusty Russell | 8e07bd7 | 2000-12-19 03:11:00 +0000 | [diff] [blame] | 37 | |
| 38 | ifdef DO_IPV6 |
| 39 | EXTRAS+=ip6tables ip6tables.o |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 40 | EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables |
Harald Welte | 8a6831a | 2001-03-15 15:33:56 +0000 | [diff] [blame] | 41 | EXTRAS_EXP+=ip6tables-save ip6tables-restore |
Harald Welte | 46d4d0a | 2001-03-16 15:48:56 +0000 | [diff] [blame] | 42 | EXTRA_INSTALLS_EXP+=$(DESTDIR)$(BINDIR)/ip6tables-save $(DESTDIR)$(BINDIR)/ip6tables-restore # $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-restore.8 |
Rusty Russell | 8e07bd7 | 2000-12-19 03:11:00 +0000 | [diff] [blame] | 43 | endif |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 44 | |
Rusty Russell | 09b9a41 | 2000-04-27 10:16:47 +0000 | [diff] [blame] | 45 | # Sparc64 hack |
| 46 | ifeq ($(shell uname -m),sparc64) |
| 47 | # The kernel is 64-bit, even though userspace is 32. |
Rusty Russell | c8d7d89 | 2000-09-19 07:01:00 +0000 | [diff] [blame] | 48 | CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32 |
Rusty Russell | 09b9a41 | 2000-04-27 10:16:47 +0000 | [diff] [blame] | 49 | endif |
| 50 | |
Rusty Russell | da70715 | 2001-04-21 04:25:09 +0000 | [diff] [blame^] | 51 | # HPPA hack |
| 52 | ifeq ($(shell uname -m),parisc64) |
| 53 | # The kernel is 64-bit, even though userspace is 32. |
| 54 | CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32 |
| 55 | endif |
| 56 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 57 | ifndef IPT_LIBDIR |
| 58 | IPT_LIBDIR:=$(LIBDIR)/iptables |
| 59 | endif |
| 60 | |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 61 | default: print-extensions all |
| 62 | |
| 63 | print-extensions: |
Rusty Russell | c8d7d89 | 2000-09-19 07:01:00 +0000 | [diff] [blame] | 64 | @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 65 | |
Rusty Russell | 50a8efe | 2001-02-03 10:50:04 +0000 | [diff] [blame] | 66 | pending-patches: |
| 67 | @cd patch-o-matic && KERNEL_DIR=$(KERNEL_DIR) ./runme $(PENDING_PATCHES) |
| 68 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 69 | iptables.o: iptables.c |
| 70 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $< |
| 71 | |
| 72 | iptables: iptables-standalone.c iptables.o libiptc/libiptc.a |
| 73 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 74 | |
| 75 | $(DESTDIR)$(BINDIR)/iptables: iptables |
| 76 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 77 | cp $< $@ |
| 78 | |
| 79 | iptables-save: iptables-save.c iptables.o libiptc/libiptc.a |
| 80 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 81 | |
| 82 | $(DESTDIR)$(BINDIR)/iptables-save: iptables-save |
| 83 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 84 | cp $< $@ |
| 85 | |
| 86 | iptables-restore: iptables-restore.c iptables.o libiptc/libiptc.a |
| 87 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 88 | |
| 89 | $(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore |
| 90 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 91 | cp $< $@ |
| 92 | |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 93 | ip6tables.o: ip6tables.c |
| 94 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $< |
| 95 | |
| 96 | ip6tables: ip6tables-standalone.c ip6tables.o libiptc/libiptc.a |
| 97 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 98 | |
| 99 | $(DESTDIR)$(BINDIR)/ip6tables: ip6tables |
| 100 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 101 | cp $< $@ |
| 102 | |
| 103 | ip6tables-save: ip6tables-save.c ip6tables.o libiptc/libiptc.a |
| 104 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 105 | |
| 106 | $(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save |
| 107 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 108 | cp $< $@ |
| 109 | |
| 110 | ip6tables-restore: ip6tables-restore.c ip6tables.o libiptc/libiptc.a |
| 111 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 112 | |
| 113 | $(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore |
| 114 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 115 | cp $< $@ |
| 116 | |
Rusty Russell | 01c4520 | 2001-01-07 06:50:31 +0000 | [diff] [blame] | 117 | $(DESTDIR)$(MANDIR)/man8/%.8: %.8 |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 118 | @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8 |
| 119 | cp $< $@ |
| 120 | |
| 121 | EXTRA_DEPENDS+=iptables-standalone.d iptables.d |
| 122 | |
| 123 | iptables-standalone.d iptables.d: %.d: %.c |
| 124 | @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@ |
| 125 | |
James Morris | c82e9ac | 2000-11-24 14:34:02 +0000 | [diff] [blame] | 126 | |
| 127 | # Development Targets |
| 128 | install-devel-man3: $(DEVEL_MAN3) |
| 129 | @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3 |
| 130 | @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3 |
| 131 | |
| 132 | install-devel-headers: $(DEVEL_HEADERS) |
| 133 | @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR) |
| 134 | @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR) |
| 135 | |
| 136 | install-devel-libs: $(DEVEL_LIBS) |
| 137 | @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR) |
| 138 | @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR) |
| 139 | |
| 140 | install-devel: all install-devel-man3 install-devel-headers install-devel-libs |
| 141 | |
Rusty Russell | 905795c | 2000-04-19 11:22:03 +0000 | [diff] [blame] | 142 | distclean: clean |
Rusty Russell | a470f33 | 2000-11-07 04:08:34 +0000 | [diff] [blame] | 143 | @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 144 | |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 145 | .PHONY: patch-o-matic |
Rusty Russell | a470f33 | 2000-11-07 04:08:34 +0000 | [diff] [blame] | 146 | patch-o-matic/ patch-o-matic: |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 147 | @cd $@ && KERNEL_DIR=$(KERNEL_DIR) ./runme |
| 148 | |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 149 | # Rusty's distro magic. |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 150 | distrib: check distclean delrelease /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 diff md5sums # nowhitespace |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 151 | |
| 152 | # Makefile must not define: |
| 153 | # -g -pg |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 154 | # And must define -NDEBUG |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 155 | check: |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 156 | @if echo $(CFLAGS) | egrep -e '-g|-pg' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi |
| 157 | @if echo $(CFLAGS) | egrep -e NDEBUG >/dev/null; then exit 0; else echo Define -DNDEBUG; exit 1; fi |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 158 | |
| 159 | nowhitespace: |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 160 | @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 161 | |
| 162 | delrelease: |
| 163 | rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 164 | |
| 165 | /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2: |
Rusty Russell | 905795c | 2000-04-19 11:22:03 +0000 | [diff] [blame] | 166 | cd .. && ln -sf userspace iptables-$(NETFILTER_VERSION) && tar cvf - --exclude CVS iptables-$(NETFILTER_VERSION)/. | bzip2 -9 > $@ && rm iptables-$(NETFILTER_VERSION) |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 167 | |
| 168 | diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 169 | @mkdir /tmp/diffdir |
Rusty Russell | 01c4520 | 2001-01-07 06:50:31 +0000 | [diff] [blame] | 170 | @cd /tmp/diffdir && tar -x --bzip2 -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 171 | @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 Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 172 | @rm -rf /tmp/diffdir |
| 173 | |
| 174 | md5sums: |
| 175 | cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2 |
| 176 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 177 | # $(wildcard) fails wierdly with make v.3.78.1. |
| 178 | include $(shell echo */Makefile) |
| 179 | include Rules.make |