blob: 0b20d77e9f6d397a936a32d075ee027be1ae6201 [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 Kelleyb36ae192012-02-13 12:54:34 +000021BUILD_DIR = $(SRC)
22
23CFLAGS = -Wall -W -O2
24
Simon Kelley824af852008-02-12 20:43:05 +000025PKG_CONFIG = pkg-config
Simon Kelley824af852008-02-12 20:43:05 +000026INSTALL = install
Simon Kelley1f15b812009-10-13 17:49:32 +010027MSGMERGE = msgmerge
28MSGFMT = msgfmt
29XGETTEXT = xgettext
Simon Kelley824af852008-02-12 20:43:05 +000030
Simon Kelley1f15b812009-10-13 17:49:32 +010031#################################################################
32
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
55all : $(BUILD_DIR)
56 @cd $(BUILD_DIR) && $(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 Kelleyb36ae192012-02-13 12:54:34 +000062 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 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 Kelleyb36ae192012-02-13 12:54:34 +000070 $(INSTALL) -m 755 $(BUILD_DIR)/dnsmasq $(DESTDIR)$(BINDIR)
Simon Kelley9e4abcb2004-01-22 19:47:41 +000071
Simon Kelleyb36ae192012-02-13 12:54:34 +000072all-i18n : $(BUILD_DIR)
73 @cd $(BUILD_DIR) && $(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 Kelleyb36ae192012-02-13 12:54:34 +000079 cd ../$(BUILD_DIR) && $(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 Kelleyb36ae192012-02-13 12:54:34 +000084 cd $(BUILD_DIR); ../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 Kelleyb36ae192012-02-13 12:54:34 +000087merge : $(BUILD_DIR)
88 @cd $(BUILD_DIR) && $(MAKE) -f ../Makefile dnsmasq.pot
Simon Kelley1f15b812009-10-13 17:49:32 +010089 @cd $(PO); for f in *.po; do \
Simon Kelleyb36ae192012-02-13 12:54:34 +000090 echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(BUILD_DIR)/dnsmasq.pot; \
Simon Kelleyb8187c82005-11-26 21:46:27 +000091 done
Simon Kelley9e4abcb2004-01-22 19:47:41 +000092
Simon Kelleyb36ae192012-02-13 12:54:34 +000093$(BUILD_DIR):
94 mkdir $(BUILD_DIR)
95
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
102%.o: %.c $(HDRS)
103 $(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $*.c
Simon Kelley316e2732010-01-22 20:16:09 +0000104
Simon Kelley4cb1b322012-02-06 14:30:41 +0000105dnsmasq : $(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
Simon Kelleyb36ae192012-02-13 12:54:34 +0000115
Simon Kelley316e2732010-01-22 20:16:09 +0000116.PHONY : all clean install install-common all-i18n install-i18n merge