Simon Kelley | aff3396 | 2015-01-31 20:13:40 +0000 | [diff] [blame] | 1 | # dnsmasq is Copyright (c) 2000-2015 Simon Kelley |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 2 | # |
| 3 | # This program is free software; you can redistribute it and/or modify |
| 4 | # it under the terms of the GNU General Public License as published by |
| 5 | # the Free Software Foundation; version 2 dated June, 1991, or |
| 6 | # (at your option) version 3 dated 29 June, 2007. |
| 7 | # |
| 8 | # This program is distributed in the hope that it will be useful, |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | # GNU General Public License for more details. |
| 12 | # |
Simon Kelley | 73a08a2 | 2009-02-05 20:28:08 +0000 | [diff] [blame] | 13 | # You should have received a copy of the GNU General Public License |
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 15 | |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 16 | # NOTE: Building the i18n targets requires GNU-make |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 17 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 18 | |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 19 | # Variables you may well want to override. |
| 20 | |
| 21 | PREFIX = /usr/local |
| 22 | BINDIR = $(PREFIX)/sbin |
| 23 | MANDIR = $(PREFIX)/share/man |
| 24 | LOCALEDIR = $(PREFIX)/share/locale |
| 25 | BUILDDIR = $(SRC) |
| 26 | DESTDIR = |
| 27 | CFLAGS = -Wall -W -O2 |
| 28 | LDFLAGS = |
| 29 | COPTS = |
| 30 | RPM_OPT_FLAGS = |
| 31 | LIBS = |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 32 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 33 | ################################################################# |
| 34 | |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 35 | # Variables you might want to override. |
| 36 | |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 37 | PKG_CONFIG = pkg-config |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 38 | INSTALL = install |
| 39 | MSGMERGE = msgmerge |
| 40 | MSGFMT = msgfmt |
| 41 | XGETTEXT = xgettext |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 42 | |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 43 | SRC = src |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 44 | PO = po |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 45 | MAN = man |
| 46 | |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 47 | ################################################################# |
Simon Kelley | fdacfb0 | 2012-02-28 15:20:25 +0000 | [diff] [blame] | 48 | |
Simon Kelley | c46c7c7 | 2012-02-29 21:37:14 +0000 | [diff] [blame] | 49 | # pmake way. (NB no spaces to keep gmake 3.82 happy) |
| 50 | top!=pwd |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 51 | # GNU make way. |
Simon Kelley | c46c7c7 | 2012-02-29 21:37:14 +0000 | [diff] [blame] | 52 | top?=$(CURDIR) |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 53 | |
Simon Kelley | 86bec2d | 2014-01-13 21:31:20 +0000 | [diff] [blame] | 54 | dbus_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1` |
| 55 | dbus_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1` |
| 56 | idn_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn` |
| 57 | idn_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn` |
| 58 | ct_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --cflags libnetfilter_conntrack` |
| 59 | ct_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --libs libnetfilter_conntrack` |
| 60 | lua_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --cflags lua5.1` |
| 61 | lua_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --libs lua5.1` |
| 62 | nettle_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --cflags nettle hogweed` |
| 63 | nettle_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --libs nettle hogweed` |
Simon Kelley | 063efb3 | 2014-06-17 19:49:31 +0100 | [diff] [blame] | 64 | gmp_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC NO_GMP --copy -lgmp` |
Simon Kelley | 86bec2d | 2014-01-13 21:31:20 +0000 | [diff] [blame] | 65 | sunos_libs = `if uname | grep SunOS >/dev/null 2>&1; then echo -lsocket -lnsl -lposix4; fi` |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 66 | version = -DVERSION='\"`$(top)/bld/get-version $(top)`\"' |
Yousong Zhou | 81c538e | 2015-01-03 16:36:14 +0000 | [diff] [blame] | 67 | copts_conf = .copts_$(shell $(CC) -DDNSMASQ_COMPILE_OPTS $(COPTS) -E $(top)/$(SRC)/dnsmasq.h | \ |
| 68 | ( md5sum 2>/dev/null || md5 ) | cut -f 1 -d ' ') |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 69 | |
| 70 | objs = cache.o rfc1035.o util.o option.o forward.o network.o \ |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 71 | dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \ |
Simon Kelley | c5ad4e7 | 2012-02-24 16:06:20 +0000 | [diff] [blame] | 72 | helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \ |
Giovanni Bajo | e292e93 | 2012-04-22 14:32:02 +0200 | [diff] [blame] | 73 | dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o \ |
Simon Kelley | 193de4a | 2014-12-10 17:32:16 +0000 | [diff] [blame] | 74 | domain.o dnssec.o blockdata.o tables.o loop.o inotify.o |
Simon Kelley | 208b65c | 2006-08-05 21:41:37 +0100 | [diff] [blame] | 75 | |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 76 | hdrs = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \ |
Simon Kelley | cc111e0 | 2014-01-13 21:38:19 +0000 | [diff] [blame] | 77 | dns-protocol.h radv-protocol.h ip6addr.h |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 78 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 79 | all : $(BUILDDIR) |
| 80 | @cd $(BUILDDIR) && $(MAKE) \ |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 81 | top="$(top)" \ |
Simon Kelley | 86bec2d | 2014-01-13 21:31:20 +0000 | [diff] [blame] | 82 | build_cflags="$(version) $(dbus_cflags) $(idn_cflags) $(ct_cflags) $(lua_cflags) $(nettle_cflags)" \ |
Simon Kelley | b98d22c | 2014-02-04 16:57:25 +0000 | [diff] [blame] | 83 | build_libs="$(dbus_libs) $(idn_libs) $(ct_libs) $(lua_libs) $(sunos_libs) $(nettle_libs) $(gmp_libs)" \ |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 84 | -f $(top)/Makefile dnsmasq |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 85 | |
Simon Kelley | ceae52d | 2013-09-12 15:05:47 +0100 | [diff] [blame] | 86 | mostly_clean : |
| 87 | rm -f $(BUILDDIR)/*.mo $(BUILDDIR)/*.pot |
Yousong Zhou | 81c538e | 2015-01-03 16:36:14 +0000 | [diff] [blame] | 88 | rm -f $(BUILDDIR)/.copts_* $(BUILDDIR)/*.o $(BUILDDIR)/dnsmasq.a $(BUILDDIR)/dnsmasq |
Simon Kelley | ceae52d | 2013-09-12 15:05:47 +0100 | [diff] [blame] | 89 | |
| 90 | clean : mostly_clean |
| 91 | rm -f $(BUILDDIR)/dnsmasq_baseline |
| 92 | rm -f core */core |
| 93 | rm -f *~ contrib/*/*~ */*~ |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 94 | |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 95 | install : all install-common |
| 96 | |
| 97 | install-common : |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 98 | $(INSTALL) -d $(DESTDIR)$(BINDIR) -d $(DESTDIR)$(MANDIR)/man8 |
| 99 | $(INSTALL) -m 644 $(MAN)/dnsmasq.8 $(DESTDIR)$(MANDIR)/man8 |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 100 | $(INSTALL) -m 755 $(BUILDDIR)/dnsmasq $(DESTDIR)$(BINDIR) |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 101 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 102 | all-i18n : $(BUILDDIR) |
| 103 | @cd $(BUILDDIR) && $(MAKE) \ |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 104 | top="$(top)" \ |
| 105 | i18n=-DLOCALEDIR=\'\"$(LOCALEDIR)\"\' \ |
Simon Kelley | 00ec693 | 2014-01-28 11:08:57 +0000 | [diff] [blame] | 106 | build_cflags="$(version) $(dbus_cflags) $(ct_cflags) $(lua_cflags) $(nettle_cflags) `$(PKG_CONFIG) --cflags libidn`" \ |
Simon Kelley | b98d22c | 2014-02-04 16:57:25 +0000 | [diff] [blame] | 107 | build_libs="$(dbus_libs) $(ct_libs) $(lua_libs) $(sunos_libs) $(nettle_libs) $(gmp_libs) `$(PKG_CONFIG) --libs libidn`" \ |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 108 | -f $(top)/Makefile dnsmasq |
Simon Kelley | fdacfb0 | 2012-02-28 15:20:25 +0000 | [diff] [blame] | 109 | for f in `cd $(PO); echo *.po`; do \ |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 110 | cd $(top) && cd $(BUILDDIR) && $(MAKE) top="$(top)" -f $(top)/Makefile $${f%.po}.mo; \ |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 111 | done |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 112 | |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 113 | install-i18n : all-i18n install-common |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 114 | cd $(BUILDDIR); $(top)/bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL) |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 115 | cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL) |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 116 | |
Simon Kelley | fdacfb0 | 2012-02-28 15:20:25 +0000 | [diff] [blame] | 117 | merge : |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 118 | @cd $(BUILDDIR) && $(MAKE) -f $(top)/Makefile dnsmasq.pot |
Simon Kelley | fdacfb0 | 2012-02-28 15:20:25 +0000 | [diff] [blame] | 119 | for f in `cd $(PO); echo *.po`; do \ |
| 120 | echo -n msgmerge $(PO)/$$f && $(MSGMERGE) --no-wrap -U $(PO)/$$f $(BUILDDIR)/dnsmasq.pot; \ |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 121 | done |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 122 | |
Simon Kelley | b7f666f | 2013-10-02 11:44:59 +0100 | [diff] [blame] | 123 | # Cannonicalise .po file. |
| 124 | %.po : |
| 125 | @cd $(BUILDDIR) && $(MAKE) -f $(top)/Makefile dnsmasq.pot |
| 126 | mv $(PO)/$*.po $(PO)/$*.po.orig && $(MSGMERGE) --no-wrap $(PO)/$*.po.orig $(BUILDDIR)/dnsmasq.pot >$(PO)/$*.po; |
| 127 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 128 | $(BUILDDIR): |
Simon Kelley | fdacfb0 | 2012-02-28 15:20:25 +0000 | [diff] [blame] | 129 | mkdir -p $(BUILDDIR) |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 130 | |
Simon Kelley | ceae52d | 2013-09-12 15:05:47 +0100 | [diff] [blame] | 131 | # rules below are helpers for size tracking |
| 132 | |
| 133 | baseline : mostly_clean all |
| 134 | @cd $(BUILDDIR) && \ |
| 135 | mv dnsmasq dnsmasq_baseline |
| 136 | |
| 137 | bloatcheck : $(BUILDDIR)/dnsmasq_baseline mostly_clean all |
| 138 | @cd $(BUILDDIR) && \ |
| 139 | $(top)/bld/bloat-o-meter dnsmasq_baseline dnsmasq; \ |
| 140 | size dnsmasq_baseline dnsmasq |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 141 | |
Simon Kelley | 8e4b879 | 2012-11-14 14:12:56 +0000 | [diff] [blame] | 142 | # rules below are targets in recusive makes with cwd=$(BUILDDIR) |
| 143 | |
Yousong Zhou | 81c538e | 2015-01-03 16:36:14 +0000 | [diff] [blame] | 144 | $(copts_conf): $(hdrs) |
| 145 | @rm -f *.o .copts_* |
Simon Kelley | 8e4b879 | 2012-11-14 14:12:56 +0000 | [diff] [blame] | 146 | @touch $@ |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 147 | |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 148 | $(objs:.o=.c) $(hdrs): |
| 149 | ln -s $(top)/$(SRC)/$@ . |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 150 | |
Yousong Zhou | d8dbd90 | 2015-01-05 17:03:35 +0000 | [diff] [blame] | 151 | $(objs): $(copts_conf) $(hdrs) |
| 152 | |
Simon Kelley | 1adadf5 | 2012-02-13 22:15:58 +0000 | [diff] [blame] | 153 | .c.o: |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 154 | $(CC) $(CFLAGS) $(COPTS) $(i18n) $(build_cflags) $(RPM_OPT_FLAGS) -c $< |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 155 | |
Yousong Zhou | d8dbd90 | 2015-01-05 17:03:35 +0000 | [diff] [blame] | 156 | dnsmasq : $(objs) |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 157 | $(CC) $(LDFLAGS) -o $@ $(objs) $(build_libs) $(LIBS) |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 158 | |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 159 | dnsmasq.pot : $(objs:.o=.c) $(hdrs) |
| 160 | $(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(objs:.o=.c) |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 161 | |
Simon Kelley | 2484894 | 2012-02-29 11:23:41 +0000 | [diff] [blame] | 162 | %.mo : $(top)/$(PO)/%.po dnsmasq.pot |
Simon Kelley | 4f8ff36 | 2012-02-29 16:01:17 +0000 | [diff] [blame] | 163 | $(MSGMERGE) -o - $(top)/$(PO)/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo - |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 164 | |
Simon Kelley | ceae52d | 2013-09-12 15:05:47 +0100 | [diff] [blame] | 165 | .PHONY : all clean mostly_clean install install-common all-i18n install-i18n merge baseline bloatcheck |