blob: dab6a9c374240b503c998efff4fcfb3b89a5113c [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 Kelleyc5ad4e72012-02-24 16:06:20 +000050 helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \
51 dhcp-common.o outpacket.o radv.o
Simon Kelley208b65c2006-08-05 21:41:37 +010052
Simon Kelleyc5ad4e72012-02-24 16:06:20 +000053HDRS = dnsmasq.h config.h dhcp_protocol.h dhcp6_protocol.h \
54 dns_protocol.h radv_protocol.h
Simon Kelleyb36ae192012-02-13 12:54:34 +000055
56
Simon Kelleye5ffdb92012-02-13 14:19:25 +000057all : $(BUILDDIR)
58 @cd $(BUILDDIR) && $(MAKE) \
Simon Kelleya4f04ed2012-01-06 11:47:02 +000059 BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(IDN_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS)" \
Simon Kelleyc72daea2012-01-05 21:33:27 +000060 BUILD_LIBS="$(DBUS_LIBS) $(IDN_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS)" \
Simon Kelley316e2732010-01-22 20:16:09 +000061 -f ../Makefile dnsmasq
Simon Kelley9e4abcb2004-01-22 19:47:41 +000062
63clean :
Simon Kelleye5ffdb92012-02-13 14:19:25 +000064 rm -f *~ $(BUILDDIR)/*.mo contrib/*/*~ */*~ $(BUILDDIR)/*.pot
65 rm -f $(BUILDDIR)/*.o $(BUILDDIR)/dnsmasq.a $(BUILDDIR)/dnsmasq core */core
Simon Kelley9e4abcb2004-01-22 19:47:41 +000066
Simon Kelleyb8187c82005-11-26 21:46:27 +000067install : all install-common
68
69install-common :
Simon Kelley824af852008-02-12 20:43:05 +000070 $(INSTALL) -d $(DESTDIR)$(BINDIR) -d $(DESTDIR)$(MANDIR)/man8
71 $(INSTALL) -m 644 $(MAN)/dnsmasq.8 $(DESTDIR)$(MANDIR)/man8
Simon Kelleye5ffdb92012-02-13 14:19:25 +000072 $(INSTALL) -m 755 $(BUILDDIR)/dnsmasq $(DESTDIR)$(BINDIR)
Simon Kelley9e4abcb2004-01-22 19:47:41 +000073
Simon Kelleye5ffdb92012-02-13 14:19:25 +000074all-i18n : $(BUILDDIR)
75 @cd $(BUILDDIR) && $(MAKE) \
Simon Kelleya4f04ed2012-01-06 11:47:02 +000076 I18N=-DLOCALEDIR=\'\"$(LOCALEDIR)\"\' \
77 BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS) `$(PKG_CONFIG) --cflags libidn`" \
Simon Kelleyc72daea2012-01-05 21:33:27 +000078 BUILD_LIBS="$(DBUS_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS) `$(PKG_CONFIG) --libs libidn`" \
Simon Kelley316e2732010-01-22 20:16:09 +000079 -f ../Makefile dnsmasq
Simon Kelley1f15b812009-10-13 17:49:32 +010080 @cd $(PO); for f in *.po; do \
Simon Kelleye5ffdb92012-02-13 14:19:25 +000081 cd ../$(BUILDDIR) && $(MAKE) \
Simon Kelley316e2732010-01-22 20:16:09 +000082 -f ../Makefile $${f%.po}.mo; \
Simon Kelleyb8187c82005-11-26 21:46:27 +000083 done
Simon Kelley9e4abcb2004-01-22 19:47:41 +000084
Simon Kelleyb8187c82005-11-26 21:46:27 +000085install-i18n : all-i18n install-common
Simon Kelleye5ffdb92012-02-13 14:19:25 +000086 cd $(BUILDDIR); ../bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL)
Simon Kelley1f15b812009-10-13 17:49:32 +010087 cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL)
Simon Kelleyb8187c82005-11-26 21:46:27 +000088
Simon Kelleye5ffdb92012-02-13 14:19:25 +000089merge : $(BUILDDIR)
90 @cd $(BUILDDIR) && $(MAKE) -f ../Makefile dnsmasq.pot
Simon Kelley1f15b812009-10-13 17:49:32 +010091 @cd $(PO); for f in *.po; do \
Simon Kelleye5ffdb92012-02-13 14:19:25 +000092 echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(BUILDDIR)/dnsmasq.pot; \
Simon Kelleyb8187c82005-11-26 21:46:27 +000093 done
Simon Kelley9e4abcb2004-01-22 19:47:41 +000094
Simon Kelleye5ffdb92012-02-13 14:19:25 +000095$(BUILDDIR):
96 mkdir $(BUILDDIR)
Simon Kelleyb36ae192012-02-13 12:54:34 +000097
Simon Kelley9e4abcb2004-01-22 19:47:41 +000098
Simon Kelley316e2732010-01-22 20:16:09 +000099# rules below are targets in recusive makes with cwd=$(SRC)
100
Simon Kelleyb36ae192012-02-13 12:54:34 +0000101$(OBJS:.o=.c) $(HDRS):
102 ln -s ../$(SRC)/$@ .
103
Simon Kelley1adadf52012-02-13 22:15:58 +0000104.c.o:
105 $(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $<
Simon Kelley316e2732010-01-22 20:16:09 +0000106
Simon Kelley1adadf52012-02-13 22:15:58 +0000107dnsmasq : $(HDRS) $(OBJS)
Simon Kelley316e2732010-01-22 20:16:09 +0000108 $(CC) $(LDFLAGS) -o $@ $(OBJS) $(BUILD_LIBS) $(LIBS)
109
Simon Kelleyb36ae192012-02-13 12:54:34 +0000110dnsmasq.pot : $(OBJS:.o=.c) $(HDRS)
Simon Kelley316e2732010-01-22 20:16:09 +0000111 $(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