Simon Kelley | 5954608 | 2012-01-06 20:02:04 +0000 | [diff] [blame] | 1 | # dnsmasq is Copyright (c) 2000-2012 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 | |
| 16 | PREFIX = /usr/local |
| 17 | BINDIR = ${PREFIX}/sbin |
| 18 | MANDIR = ${PREFIX}/share/man |
| 19 | LOCALEDIR = ${PREFIX}/share/locale |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 20 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 21 | BUILDDIR = $(SRC) |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 22 | |
| 23 | CFLAGS = -Wall -W -O2 |
| 24 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 25 | ################################################################# |
| 26 | |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 27 | PKG_CONFIG = pkg-config |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 28 | INSTALL = install |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 29 | MSGMERGE = msgmerge |
| 30 | MSGFMT = msgfmt |
| 31 | XGETTEXT = xgettext |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 32 | |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 33 | SRC = src |
| 34 | PO = po |
| 35 | MAN = man |
| 36 | |
Simon Kelley | 7de060b | 2011-08-26 17:24:52 +0100 | [diff] [blame] | 37 | DBUS_CFLAGS=`echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1` |
| 38 | DBUS_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1` |
| 39 | IDN_CFLAGS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn` |
| 40 | IDN_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn` |
| 41 | CT_CFLAGS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --cflags libnetfilter_conntrack` |
| 42 | CT_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --libs libnetfilter_conntrack` |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 43 | LUA_CFLAGS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --cflags lua5.1` |
| 44 | LUA_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --libs lua5.1` |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 45 | SUNOS_LIBS= `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi` |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 46 | VERSION= -DVERSION='\"`../bld/get-version`\"' |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 47 | |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 48 | OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \ |
| 49 | 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^] | 50 | helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \ |
| 51 | dhcp-common.o outpacket.o radv.o |
Simon Kelley | 208b65c | 2006-08-05 21:41:37 +0100 | [diff] [blame] | 52 | |
Simon Kelley | c5ad4e7 | 2012-02-24 16:06:20 +0000 | [diff] [blame^] | 53 | HDRS = dnsmasq.h config.h dhcp_protocol.h dhcp6_protocol.h \ |
| 54 | dns_protocol.h radv_protocol.h |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 55 | |
| 56 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 57 | all : $(BUILDDIR) |
| 58 | @cd $(BUILDDIR) && $(MAKE) \ |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 59 | BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(IDN_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS)" \ |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 60 | BUILD_LIBS="$(DBUS_LIBS) $(IDN_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS)" \ |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 61 | -f ../Makefile dnsmasq |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 62 | |
| 63 | clean : |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 64 | rm -f *~ $(BUILDDIR)/*.mo contrib/*/*~ */*~ $(BUILDDIR)/*.pot |
| 65 | rm -f $(BUILDDIR)/*.o $(BUILDDIR)/dnsmasq.a $(BUILDDIR)/dnsmasq core */core |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 66 | |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 67 | install : all install-common |
| 68 | |
| 69 | install-common : |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 70 | $(INSTALL) -d $(DESTDIR)$(BINDIR) -d $(DESTDIR)$(MANDIR)/man8 |
| 71 | $(INSTALL) -m 644 $(MAN)/dnsmasq.8 $(DESTDIR)$(MANDIR)/man8 |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 72 | $(INSTALL) -m 755 $(BUILDDIR)/dnsmasq $(DESTDIR)$(BINDIR) |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 73 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 74 | all-i18n : $(BUILDDIR) |
| 75 | @cd $(BUILDDIR) && $(MAKE) \ |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 76 | I18N=-DLOCALEDIR=\'\"$(LOCALEDIR)\"\' \ |
| 77 | BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS) `$(PKG_CONFIG) --cflags libidn`" \ |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 78 | BUILD_LIBS="$(DBUS_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS) `$(PKG_CONFIG) --libs libidn`" \ |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 79 | -f ../Makefile dnsmasq |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 80 | @cd $(PO); for f in *.po; do \ |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 81 | cd ../$(BUILDDIR) && $(MAKE) \ |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 82 | -f ../Makefile $${f%.po}.mo; \ |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 83 | done |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 84 | |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 85 | install-i18n : all-i18n install-common |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 86 | cd $(BUILDDIR); ../bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL) |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 87 | cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL) |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 88 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 89 | merge : $(BUILDDIR) |
| 90 | @cd $(BUILDDIR) && $(MAKE) -f ../Makefile dnsmasq.pot |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 91 | @cd $(PO); for f in *.po; do \ |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 92 | echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(BUILDDIR)/dnsmasq.pot; \ |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 93 | done |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 94 | |
Simon Kelley | e5ffdb9 | 2012-02-13 14:19:25 +0000 | [diff] [blame] | 95 | $(BUILDDIR): |
| 96 | mkdir $(BUILDDIR) |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 97 | |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 98 | |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 99 | # rules below are targets in recusive makes with cwd=$(SRC) |
| 100 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 101 | $(OBJS:.o=.c) $(HDRS): |
| 102 | ln -s ../$(SRC)/$@ . |
| 103 | |
Simon Kelley | 1adadf5 | 2012-02-13 22:15:58 +0000 | [diff] [blame] | 104 | .c.o: |
| 105 | $(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $< |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 106 | |
Simon Kelley | 1adadf5 | 2012-02-13 22:15:58 +0000 | [diff] [blame] | 107 | dnsmasq : $(HDRS) $(OBJS) |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 108 | $(CC) $(LDFLAGS) -o $@ $(OBJS) $(BUILD_LIBS) $(LIBS) |
| 109 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame] | 110 | dnsmasq.pot : $(OBJS:.o=.c) $(HDRS) |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 111 | $(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(OBJS:.o=.c) |
| 112 | |
| 113 | %.mo : ../po/%.po dnsmasq.pot |
| 114 | $(MSGMERGE) -o - ../po/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo - |
| 115 | |
| 116 | |
| 117 | .PHONY : all clean install install-common all-i18n install-i18n merge |