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 | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 21 | BUILD_DIR = $(SRC) |
| 22 | |
| 23 | CFLAGS = -Wall -W -O2 |
| 24 | |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 25 | PKG_CONFIG = pkg-config |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 26 | INSTALL = install |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 27 | MSGMERGE = msgmerge |
| 28 | MSGFMT = msgfmt |
| 29 | XGETTEXT = xgettext |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 30 | |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 31 | ################################################################# |
| 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 | 4cb1b32 | 2012-02-06 14:30:41 +0000 | [diff] [blame] | 50 | helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o dhcp-common.o |
Simon Kelley | 208b65c | 2006-08-05 21:41:37 +0100 | [diff] [blame] | 51 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 52 | HDRS = dnsmasq.h config.h dhcp_protocol.h dhcp6_protocol.h dns_protocol.h |
| 53 | |
| 54 | |
| 55 | all : $(BUILD_DIR) |
| 56 | @cd $(BUILD_DIR) && $(MAKE) \ |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 57 | BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(IDN_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS)" \ |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 58 | BUILD_LIBS="$(DBUS_LIBS) $(IDN_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS)" \ |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 59 | -f ../Makefile dnsmasq |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 60 | |
| 61 | clean : |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 62 | rm -f *~ $(BUILD_DIR)/*.mo contrib/*/*~ */*~ $(BUILD_DIR)/*.pot |
| 63 | rm -f $(BUILD_DIR)/*.o $(BUILD_DIR)/dnsmasq.a $(BUILD_DIR)/dnsmasq core */core |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 64 | |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 65 | install : all install-common |
| 66 | |
| 67 | install-common : |
Simon Kelley | 824af85 | 2008-02-12 20:43:05 +0000 | [diff] [blame] | 68 | $(INSTALL) -d $(DESTDIR)$(BINDIR) -d $(DESTDIR)$(MANDIR)/man8 |
| 69 | $(INSTALL) -m 644 $(MAN)/dnsmasq.8 $(DESTDIR)$(MANDIR)/man8 |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 70 | $(INSTALL) -m 755 $(BUILD_DIR)/dnsmasq $(DESTDIR)$(BINDIR) |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 71 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 72 | all-i18n : $(BUILD_DIR) |
| 73 | @cd $(BUILD_DIR) && $(MAKE) \ |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 74 | I18N=-DLOCALEDIR=\'\"$(LOCALEDIR)\"\' \ |
| 75 | 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] | 76 | 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] | 77 | -f ../Makefile dnsmasq |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 78 | @cd $(PO); for f in *.po; do \ |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 79 | cd ../$(BUILD_DIR) && $(MAKE) \ |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 80 | -f ../Makefile $${f%.po}.mo; \ |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 81 | done |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 82 | |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 83 | install-i18n : all-i18n install-common |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 84 | cd $(BUILD_DIR); ../bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL) |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 85 | cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL) |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 86 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 87 | merge : $(BUILD_DIR) |
| 88 | @cd $(BUILD_DIR) && $(MAKE) -f ../Makefile dnsmasq.pot |
Simon Kelley | 1f15b81 | 2009-10-13 17:49:32 +0100 | [diff] [blame] | 89 | @cd $(PO); for f in *.po; do \ |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 90 | echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(BUILD_DIR)/dnsmasq.pot; \ |
Simon Kelley | b8187c8 | 2005-11-26 21:46:27 +0000 | [diff] [blame] | 91 | done |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 92 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 93 | $(BUILD_DIR): |
| 94 | mkdir $(BUILD_DIR) |
| 95 | |
Simon Kelley | 9e4abcb | 2004-01-22 19:47:41 +0000 | [diff] [blame] | 96 | |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 97 | # rules below are targets in recusive makes with cwd=$(SRC) |
| 98 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 99 | $(OBJS:.o=.c) $(HDRS): |
| 100 | ln -s ../$(SRC)/$@ . |
| 101 | |
| 102 | %.o: %.c $(HDRS) |
| 103 | $(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $*.c |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 104 | |
Simon Kelley | 4cb1b32 | 2012-02-06 14:30:41 +0000 | [diff] [blame] | 105 | dnsmasq : $(OBJS) |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 106 | $(CC) $(LDFLAGS) -o $@ $(OBJS) $(BUILD_LIBS) $(LIBS) |
| 107 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 108 | dnsmasq.pot : $(OBJS:.o=.c) $(HDRS) |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 109 | $(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(OBJS:.o=.c) |
| 110 | |
| 111 | %.mo : ../po/%.po dnsmasq.pot |
| 112 | $(MSGMERGE) -o - ../po/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo - |
| 113 | |
| 114 | |
Simon Kelley | b36ae19 | 2012-02-13 12:54:34 +0000 | [diff] [blame^] | 115 | |
Simon Kelley | 316e273 | 2010-01-22 20:16:09 +0000 | [diff] [blame] | 116 | .PHONY : all clean install install-common all-i18n install-i18n merge |