blob: 0e047cf343d0dbc4d8dbfde00c9f274df7206858 [file] [log] [blame]
Simon Kelley59546082012-01-06 20:02:04 +00001# dnsmasq is Copyright (c) 2000-2012 Simon Kelley
Simon Kelley824af852008-02-12 20:43:05 +00002#
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 Kelley73a08a22009-02-05 20:28:08 +000013# 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 Kelley824af852008-02-12 20:43:05 +000015
16PREFIX = /usr/local
17BINDIR = ${PREFIX}/sbin
18MANDIR = ${PREFIX}/share/man
19LOCALEDIR = ${PREFIX}/share/locale
Simon Kelley9e4abcb2004-01-22 19:47:41 +000020
Simon Kelleye5ffdb92012-02-13 14:19:25 +000021BUILDDIR = $(SRC)
Simon Kelleyb36ae192012-02-13 12:54:34 +000022
23CFLAGS = -Wall -W -O2
24
Simon Kelleye5ffdb92012-02-13 14:19:25 +000025#################################################################
26
Simon Kelley824af852008-02-12 20:43:05 +000027PKG_CONFIG = pkg-config
Simon Kelley824af852008-02-12 20:43:05 +000028INSTALL = install
Simon Kelley1f15b812009-10-13 17:49:32 +010029MSGMERGE = msgmerge
30MSGFMT = msgfmt
31XGETTEXT = xgettext
Simon Kelley824af852008-02-12 20:43:05 +000032
Simon Kelley316e2732010-01-22 20:16:09 +000033SRC = src
34PO = po
35MAN = man
36
Simon Kelley7de060b2011-08-26 17:24:52 +010037DBUS_CFLAGS=`echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1`
38DBUS_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1`
39IDN_CFLAGS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn`
40IDN_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn`
41CT_CFLAGS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --cflags libnetfilter_conntrack`
42CT_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --libs libnetfilter_conntrack`
Simon Kelleya4f04ed2012-01-06 11:47:02 +000043LUA_CFLAGS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --cflags lua5.1`
44LUA_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --libs lua5.1`
Simon Kelley1f15b812009-10-13 17:49:32 +010045SUNOS_LIBS= `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi`
Simon Kelleya4f04ed2012-01-06 11:47:02 +000046VERSION= -DVERSION='\"`../bld/get-version`\"'
Simon Kelley9e4abcb2004-01-22 19:47:41 +000047
Simon Kelley316e2732010-01-22 20:16:09 +000048OBJS = 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 Kelley4cb1b322012-02-06 14:30:41 +000050 helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o dhcp-common.o
Simon Kelley208b65c2006-08-05 21:41:37 +010051
Simon Kelleyb36ae192012-02-13 12:54:34 +000052HDRS = dnsmasq.h config.h dhcp_protocol.h dhcp6_protocol.h dns_protocol.h
53
54
Simon Kelleye5ffdb92012-02-13 14:19:25 +000055all : $(BUILDDIR)
56 @cd $(BUILDDIR) && $(MAKE) \
Simon Kelleya4f04ed2012-01-06 11:47:02 +000057 BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(IDN_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS)" \
Simon Kelleyc72daea2012-01-05 21:33:27 +000058 BUILD_LIBS="$(DBUS_LIBS) $(IDN_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS)" \
Simon Kelley316e2732010-01-22 20:16:09 +000059 -f ../Makefile dnsmasq
Simon Kelley9e4abcb2004-01-22 19:47:41 +000060
61clean :
Simon Kelleye5ffdb92012-02-13 14:19:25 +000062 rm -f *~ $(BUILDDIR)/*.mo contrib/*/*~ */*~ $(BUILDDIR)/*.pot
63 rm -f $(BUILDDIR)/*.o $(BUILDDIR)/dnsmasq.a $(BUILDDIR)/dnsmasq core */core
Simon Kelley9e4abcb2004-01-22 19:47:41 +000064
Simon Kelleyb8187c82005-11-26 21:46:27 +000065install : all install-common
66
67install-common :
Simon Kelley824af852008-02-12 20:43:05 +000068 $(INSTALL) -d $(DESTDIR)$(BINDIR) -d $(DESTDIR)$(MANDIR)/man8
69 $(INSTALL) -m 644 $(MAN)/dnsmasq.8 $(DESTDIR)$(MANDIR)/man8
Simon Kelleye5ffdb92012-02-13 14:19:25 +000070 $(INSTALL) -m 755 $(BUILDDIR)/dnsmasq $(DESTDIR)$(BINDIR)
Simon Kelley9e4abcb2004-01-22 19:47:41 +000071
Simon Kelleye5ffdb92012-02-13 14:19:25 +000072all-i18n : $(BUILDDIR)
73 @cd $(BUILDDIR) && $(MAKE) \
Simon Kelleya4f04ed2012-01-06 11:47:02 +000074 I18N=-DLOCALEDIR=\'\"$(LOCALEDIR)\"\' \
75 BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS) `$(PKG_CONFIG) --cflags libidn`" \
Simon Kelleyc72daea2012-01-05 21:33:27 +000076 BUILD_LIBS="$(DBUS_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS) `$(PKG_CONFIG) --libs libidn`" \
Simon Kelley316e2732010-01-22 20:16:09 +000077 -f ../Makefile dnsmasq
Simon Kelley1f15b812009-10-13 17:49:32 +010078 @cd $(PO); for f in *.po; do \
Simon Kelleye5ffdb92012-02-13 14:19:25 +000079 cd ../$(BUILDDIR) && $(MAKE) \
Simon Kelley316e2732010-01-22 20:16:09 +000080 -f ../Makefile $${f%.po}.mo; \
Simon Kelleyb8187c82005-11-26 21:46:27 +000081 done
Simon Kelley9e4abcb2004-01-22 19:47:41 +000082
Simon Kelleyb8187c82005-11-26 21:46:27 +000083install-i18n : all-i18n install-common
Simon Kelleye5ffdb92012-02-13 14:19:25 +000084 cd $(BUILDDIR); ../bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL)
Simon Kelley1f15b812009-10-13 17:49:32 +010085 cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL)
Simon Kelleyb8187c82005-11-26 21:46:27 +000086
Simon Kelleye5ffdb92012-02-13 14:19:25 +000087merge : $(BUILDDIR)
88 @cd $(BUILDDIR) && $(MAKE) -f ../Makefile dnsmasq.pot
Simon Kelley1f15b812009-10-13 17:49:32 +010089 @cd $(PO); for f in *.po; do \
Simon Kelleye5ffdb92012-02-13 14:19:25 +000090 echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(BUILDDIR)/dnsmasq.pot; \
Simon Kelleyb8187c82005-11-26 21:46:27 +000091 done
Simon Kelley9e4abcb2004-01-22 19:47:41 +000092
Simon Kelleye5ffdb92012-02-13 14:19:25 +000093$(BUILDDIR):
94 mkdir $(BUILDDIR)
Simon Kelleyb36ae192012-02-13 12:54:34 +000095
Simon Kelley9e4abcb2004-01-22 19:47:41 +000096
Simon Kelley316e2732010-01-22 20:16:09 +000097# rules below are targets in recusive makes with cwd=$(SRC)
98
Simon Kelleyb36ae192012-02-13 12:54:34 +000099$(OBJS:.o=.c) $(HDRS):
100 ln -s ../$(SRC)/$@ .
101
Simon Kelley1adadf52012-02-13 22:15:58 +0000102.c.o:
103 $(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $<
Simon Kelley316e2732010-01-22 20:16:09 +0000104
Simon Kelley1adadf52012-02-13 22:15:58 +0000105dnsmasq : $(HDRS) $(OBJS)
Simon Kelley316e2732010-01-22 20:16:09 +0000106 $(CC) $(LDFLAGS) -o $@ $(OBJS) $(BUILD_LIBS) $(LIBS)
107
Simon Kelleyb36ae192012-02-13 12:54:34 +0000108dnsmasq.pot : $(OBJS:.o=.c) $(HDRS)
Simon Kelley316e2732010-01-22 20:16:09 +0000109 $(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
115.PHONY : all clean install install-common all-i18n install-i18n merge