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 |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 7 | NETFILTER_VERSION:=1.2 |
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 | |
| 10 | LIBDIR:=/usr/local/lib |
Rusty Russell | 7fef194 | 2001-01-08 07:44:46 +0000 | [diff] [blame] | 11 | BINDIR:=/usr/local/sbin |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 12 | MANDIR:=/usr/local/man |
James Morris | c82e9ac | 2000-11-24 14:34:02 +0000 | [diff] [blame] | 13 | INCDIR:=/usr/local/include |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 14 | |
Rusty Russell | 209820b | 2001-01-08 08:14:33 +0000 | [diff] [blame] | 15 | # Need libc6 for this. FIXME: Should covert to autoconf. |
| 16 | ifneq ($(shell ldd --version 2>/dev/null | fgrep 2.2),) |
Rusty Russell | 8e07bd7 | 2000-12-19 03:11:00 +0000 | [diff] [blame] | 17 | DO_IPV6=1 |
| 18 | endif |
| 19 | |
Rusty Russell | 8c245b5 | 2000-07-14 08:01:22 +0000 | [diff] [blame] | 20 | COPT_FLAGS:=-O2 -DNDEBUG |
| 21 | CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -Iinclude/ -I$(KERNEL_DIR)/include -DNETFILTER_VERSION=\"$(NETFILTER_VERSION)\" #-g #-pg |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 22 | |
Rusty Russell | 5622f21 | 2000-05-02 16:42:09 +0000 | [diff] [blame] | 23 | DEPFILES = $(SHARED_LIBS:%.so=%.d) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 24 | SH_CFLAGS:=$(CFLAGS) -fPIC |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 25 | |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 26 | EXTRAS+=iptables iptables.o |
Rusty Russell | 01c4520 | 2001-01-07 06:50:31 +0000 | [diff] [blame] | 27 | EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8 |
| 28 | |
| 29 | # Still experimental. |
| 30 | EXTRAS_EXP+=iptables-save iptables-restore |
| 31 | 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] | 32 | |
| 33 | ifdef DO_IPV6 |
| 34 | EXTRAS+=ip6tables ip6tables.o |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 35 | EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables |
Rusty Russell | 8e07bd7 | 2000-12-19 03:11:00 +0000 | [diff] [blame] | 36 | endif |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 37 | |
Rusty Russell | 09b9a41 | 2000-04-27 10:16:47 +0000 | [diff] [blame] | 38 | # Sparc64 hack |
| 39 | ifeq ($(shell uname -m),sparc64) |
| 40 | # The kernel is 64-bit, even though userspace is 32. |
Rusty Russell | c8d7d89 | 2000-09-19 07:01:00 +0000 | [diff] [blame] | 41 | CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32 |
Rusty Russell | 09b9a41 | 2000-04-27 10:16:47 +0000 | [diff] [blame] | 42 | endif |
| 43 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 44 | ifndef IPT_LIBDIR |
| 45 | IPT_LIBDIR:=$(LIBDIR)/iptables |
| 46 | endif |
| 47 | |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 48 | default: print-extensions all |
| 49 | |
| 50 | print-extensions: |
Rusty Russell | c8d7d89 | 2000-09-19 07:01:00 +0000 | [diff] [blame] | 51 | @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 52 | |
| 53 | iptables.o: iptables.c |
| 54 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $< |
| 55 | |
| 56 | iptables: 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 | |
| 63 | iptables-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 | |
| 70 | iptables-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 Blundell | 8c70090 | 2000-05-15 02:17:52 +0000 | [diff] [blame] | 77 | ip6tables.o: ip6tables.c |
| 78 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $< |
| 79 | |
| 80 | ip6tables: 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 | |
| 87 | ip6tables-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 | |
| 94 | ip6tables-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 Russell | 01c4520 | 2001-01-07 06:50:31 +0000 | [diff] [blame] | 101 | $(DESTDIR)$(MANDIR)/man8/%.8: %.8 |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 102 | @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8 |
| 103 | cp $< $@ |
| 104 | |
| 105 | EXTRA_DEPENDS+=iptables-standalone.d iptables.d |
| 106 | |
| 107 | iptables-standalone.d iptables.d: %.d: %.c |
| 108 | @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@ |
| 109 | |
James Morris | c82e9ac | 2000-11-24 14:34:02 +0000 | [diff] [blame] | 110 | |
| 111 | # Development Targets |
| 112 | install-devel-man3: $(DEVEL_MAN3) |
| 113 | @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3 |
| 114 | @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3 |
| 115 | |
| 116 | install-devel-headers: $(DEVEL_HEADERS) |
| 117 | @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR) |
| 118 | @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR) |
| 119 | |
| 120 | install-devel-libs: $(DEVEL_LIBS) |
| 121 | @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR) |
| 122 | @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR) |
| 123 | |
| 124 | install-devel: all install-devel-man3 install-devel-headers install-devel-libs |
| 125 | |
Rusty Russell | 905795c | 2000-04-19 11:22:03 +0000 | [diff] [blame] | 126 | distclean: clean |
Rusty Russell | a470f33 | 2000-11-07 04:08:34 +0000 | [diff] [blame] | 127 | @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] | 128 | |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 129 | .PHONY: patch-o-matic |
Rusty Russell | a470f33 | 2000-11-07 04:08:34 +0000 | [diff] [blame] | 130 | patch-o-matic/ patch-o-matic: |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 131 | @cd $@ && KERNEL_DIR=$(KERNEL_DIR) ./runme |
| 132 | |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 133 | # Rusty's distro magic. |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 134 | 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] | 135 | |
| 136 | # Makefile must not define: |
| 137 | # -g -pg |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 138 | # And must define -NDEBUG |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 139 | check: |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 140 | @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 Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 142 | |
| 143 | nowhitespace: |
Rusty Russell | 2e5f953 | 2001-01-07 09:37:02 +0000 | [diff] [blame] | 144 | @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] | 145 | |
| 146 | delrelease: |
| 147 | rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 148 | |
| 149 | /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2: |
Rusty Russell | 905795c | 2000-04-19 11:22:03 +0000 | [diff] [blame] | 150 | 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] | 151 | |
| 152 | diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 153 | @mkdir /tmp/diffdir |
Rusty Russell | 01c4520 | 2001-01-07 06:50:31 +0000 | [diff] [blame] | 154 | @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 Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 156 | @rm -rf /tmp/diffdir |
| 157 | |
| 158 | md5sums: |
| 159 | cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2 |
| 160 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 161 | # $(wildcard) fails wierdly with make v.3.78.1. |
| 162 | include $(shell echo */Makefile) |
| 163 | include Rules.make |