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 | 7bffc70 | 2001-03-14 12:51:24 +0000 | [diff] [blame] | 7 | NETFILTER_VERSION:=1.2.1 |
Rusty Russell | 8e07bd7 | 2000-12-19 03:11:00 +0000 | [diff] [blame] | 8 | OLD_NETFILTER_VERSION:=1.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 | cf878e9 | 2001-02-19 22:04:33 +0000 | [diff] [blame] | 11 | PENDING_PATCHES:=tos-fix.patch 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. |
| 13 | PENDING_PATCHES+=ipv6-fixes.patch.ipv6 masquerade+fwmark.patch nat-overlap.patch ppc-sparc-mangle.patch |
| 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 |
| 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 |
| 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 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 51 | ifndef IPT_LIBDIR |
| 52 | IPT_LIBDIR:=$(LIBDIR)/iptables |
| 53 | endif |
| 54 | |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 55 | default: print-extensions all |
| 56 | |
| 57 | print-extensions: |
Rusty Russell | c8d7d89 | 2000-09-19 07:01:00 +0000 | [diff] [blame] | 58 | @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 59 | |
Rusty Russell | 50a8efe | 2001-02-03 10:50:04 +0000 | [diff] [blame] | 60 | pending-patches: |
| 61 | @cd patch-o-matic && KERNEL_DIR=$(KERNEL_DIR) ./runme $(PENDING_PATCHES) |
| 62 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 63 | iptables.o: iptables.c |
| 64 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $< |
| 65 | |
| 66 | iptables: iptables-standalone.c iptables.o libiptc/libiptc.a |
| 67 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 68 | |
| 69 | $(DESTDIR)$(BINDIR)/iptables: iptables |
| 70 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 71 | cp $< $@ |
| 72 | |
| 73 | iptables-save: iptables-save.c iptables.o libiptc/libiptc.a |
| 74 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 75 | |
| 76 | $(DESTDIR)$(BINDIR)/iptables-save: iptables-save |
| 77 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 78 | cp $< $@ |
| 79 | |
| 80 | iptables-restore: iptables-restore.c iptables.o libiptc/libiptc.a |
| 81 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 82 | |
| 83 | $(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore |
| 84 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 85 | cp $< $@ |
| 86 | |
Philip Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 87 | ip6tables.o: ip6tables.c |
| 88 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $< |
| 89 | |
| 90 | ip6tables: ip6tables-standalone.c ip6tables.o libiptc/libiptc.a |
| 91 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 92 | |
| 93 | $(DESTDIR)$(BINDIR)/ip6tables: ip6tables |
| 94 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 95 | cp $< $@ |
| 96 | |
| 97 | ip6tables-save: ip6tables-save.c ip6tables.o libiptc/libiptc.a |
| 98 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 99 | |
| 100 | $(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save |
| 101 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 102 | cp $< $@ |
| 103 | |
| 104 | ip6tables-restore: ip6tables-restore.c ip6tables.o libiptc/libiptc.a |
| 105 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 106 | |
| 107 | $(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore |
| 108 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 109 | cp $< $@ |
| 110 | |
Rusty Russell | 01c4520 | 2001-01-07 06:50:31 +0000 | [diff] [blame] | 111 | $(DESTDIR)$(MANDIR)/man8/%.8: %.8 |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 112 | @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8 |
| 113 | cp $< $@ |
| 114 | |
| 115 | EXTRA_DEPENDS+=iptables-standalone.d iptables.d |
| 116 | |
| 117 | iptables-standalone.d iptables.d: %.d: %.c |
| 118 | @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@ |
| 119 | |
James Morris | c82e9ac | 2000-11-24 14:34:02 +0000 | [diff] [blame] | 120 | |
| 121 | # Development Targets |
| 122 | install-devel-man3: $(DEVEL_MAN3) |
| 123 | @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3 |
| 124 | @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3 |
| 125 | |
| 126 | install-devel-headers: $(DEVEL_HEADERS) |
| 127 | @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR) |
| 128 | @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR) |
| 129 | |
| 130 | install-devel-libs: $(DEVEL_LIBS) |
| 131 | @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR) |
| 132 | @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR) |
| 133 | |
| 134 | install-devel: all install-devel-man3 install-devel-headers install-devel-libs |
| 135 | |
Rusty Russell | 905795c | 2000-04-19 11:22:03 +0000 | [diff] [blame] | 136 | distclean: clean |
Rusty Russell | a470f33 | 2000-11-07 04:08:34 +0000 | [diff] [blame] | 137 | @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] | 138 | |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 139 | .PHONY: patch-o-matic |
Rusty Russell | a470f33 | 2000-11-07 04:08:34 +0000 | [diff] [blame] | 140 | patch-o-matic/ patch-o-matic: |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 141 | @cd $@ && KERNEL_DIR=$(KERNEL_DIR) ./runme |
| 142 | |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 143 | # Rusty's distro magic. |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 144 | 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] | 145 | |
| 146 | # Makefile must not define: |
| 147 | # -g -pg |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 148 | # And must define -NDEBUG |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 149 | check: |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 150 | @if echo $(CFLAGS) | egrep -e '-g|-pg' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi |
| 151 | @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] | 152 | |
| 153 | nowhitespace: |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 154 | @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] | 155 | |
| 156 | delrelease: |
| 157 | rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 158 | |
| 159 | /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2: |
Rusty Russell | 905795c | 2000-04-19 11:22:03 +0000 | [diff] [blame] | 160 | 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] | 161 | |
| 162 | diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 163 | @mkdir /tmp/diffdir |
Rusty Russell | 01c4520 | 2001-01-07 06:50:31 +0000 | [diff] [blame] | 164 | @cd /tmp/diffdir && tar -x --bzip2 -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 165 | @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] | 166 | @rm -rf /tmp/diffdir |
| 167 | |
| 168 | md5sums: |
| 169 | cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2 |
| 170 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 171 | # $(wildcard) fails wierdly with make v.3.78.1. |
| 172 | include $(shell echo */Makefile) |
| 173 | include Rules.make |