]> git.ipfire.org Git - people/ms/dnsmasq.git/blame - Makefile
Fix new poll() code for helper pipe. Removed CPU-spin.
[people/ms/dnsmasq.git] / Makefile
CommitLineData
aff33962 1# dnsmasq is Copyright (c) 2000-2015 Simon Kelley
824af85b
SK
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#
73a08a24
SK
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/>.
824af85b 15
24848940 16# NOTE: Building the i18n targets requires GNU-make
9e4abcb5 17
b36ae194 18
24848940
SK
19# Variables you may well want to override.
20
21PREFIX = /usr/local
22BINDIR = $(PREFIX)/sbin
23MANDIR = $(PREFIX)/share/man
24LOCALEDIR = $(PREFIX)/share/locale
25BUILDDIR = $(SRC)
26DESTDIR =
27CFLAGS = -Wall -W -O2
28LDFLAGS =
29COPTS =
30RPM_OPT_FLAGS =
31LIBS =
b36ae194 32
e5ffdb9c
SK
33#################################################################
34
24848940
SK
35# Variables you might want to override.
36
824af85b 37PKG_CONFIG = pkg-config
24848940
SK
38INSTALL = install
39MSGMERGE = msgmerge
40MSGFMT = msgfmt
41XGETTEXT = xgettext
824af85b 42
316e2730 43SRC = src
24848940 44PO = po
316e2730
SK
45MAN = man
46
24848940
SK
47#################################################################
48
c46c7c75
SK
49# pmake way. (NB no spaces to keep gmake 3.82 happy)
50top!=pwd
24848940 51# GNU make way.
c46c7c75 52top?=$(CURDIR)
24848940 53
86bec2d3
SK
54dbus_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1`
55dbus_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1`
56idn_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn`
57idn_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn`
58ct_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --cflags libnetfilter_conntrack`
59ct_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --libs libnetfilter_conntrack`
60lua_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --cflags lua5.1`
61lua_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --libs lua5.1`
62nettle_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --cflags nettle hogweed`
63nettle_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --libs nettle hogweed`
063efb33 64gmp_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC NO_GMP --copy -lgmp`
86bec2d3 65sunos_libs = `if uname | grep SunOS >/dev/null 2>&1; then echo -lsocket -lnsl -lposix4; fi`
24848940 66version = -DVERSION='\"`$(top)/bld/get-version $(top)`\"'
10626676
SK
67
68sum?=$(shell $(CC) -DDNSMASQ_COMPILE_OPTS $(COPTS) -E $(top)/$(SRC)/dnsmasq.h | ( md5sum 2>/dev/null || md5 ) | cut -f 1 -d ' ')
69sum!=$(CC) -DDNSMASQ_COMPILE_OPTS $(COPTS) -E $(top)/$(SRC)/dnsmasq.h | ( md5sum 2>/dev/null || md5 ) | cut -f 1 -d ' '
70copts_conf = .copts_$(sum)
24848940
SK
71
72objs = cache.o rfc1035.o util.o option.o forward.o network.o \
316e2730 73 dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
c5ad4e79 74 helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \
e292e93d 75 dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o \
b842bc97 76 domain.o dnssec.o blockdata.o tables.o loop.o inotify.o poll.o
208b65c5 77
24848940 78hdrs = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \
cc111e0b 79 dns-protocol.h radv-protocol.h ip6addr.h
b36ae194 80
e5ffdb9c
SK
81all : $(BUILDDIR)
82 @cd $(BUILDDIR) && $(MAKE) \
24848940 83 top="$(top)" \
86bec2d3 84 build_cflags="$(version) $(dbus_cflags) $(idn_cflags) $(ct_cflags) $(lua_cflags) $(nettle_cflags)" \
b98d22c1 85 build_libs="$(dbus_libs) $(idn_libs) $(ct_libs) $(lua_libs) $(sunos_libs) $(nettle_libs) $(gmp_libs)" \
24848940 86 -f $(top)/Makefile dnsmasq
9e4abcb5 87
ceae52df
SK
88mostly_clean :
89 rm -f $(BUILDDIR)/*.mo $(BUILDDIR)/*.pot
81c538ef 90 rm -f $(BUILDDIR)/.copts_* $(BUILDDIR)/*.o $(BUILDDIR)/dnsmasq.a $(BUILDDIR)/dnsmasq
ceae52df
SK
91
92clean : mostly_clean
93 rm -f $(BUILDDIR)/dnsmasq_baseline
94 rm -f core */core
95 rm -f *~ contrib/*/*~ */*~
9e4abcb5 96
b8187c80
SK
97install : all install-common
98
99install-common :
824af85b
SK
100 $(INSTALL) -d $(DESTDIR)$(BINDIR) -d $(DESTDIR)$(MANDIR)/man8
101 $(INSTALL) -m 644 $(MAN)/dnsmasq.8 $(DESTDIR)$(MANDIR)/man8
e5ffdb9c 102 $(INSTALL) -m 755 $(BUILDDIR)/dnsmasq $(DESTDIR)$(BINDIR)
9e4abcb5 103
e5ffdb9c
SK
104all-i18n : $(BUILDDIR)
105 @cd $(BUILDDIR) && $(MAKE) \
24848940
SK
106 top="$(top)" \
107 i18n=-DLOCALEDIR=\'\"$(LOCALEDIR)\"\' \
00ec693d 108 build_cflags="$(version) $(dbus_cflags) $(ct_cflags) $(lua_cflags) $(nettle_cflags) `$(PKG_CONFIG) --cflags libidn`" \
b98d22c1 109 build_libs="$(dbus_libs) $(ct_libs) $(lua_libs) $(sunos_libs) $(nettle_libs) $(gmp_libs) `$(PKG_CONFIG) --libs libidn`" \
24848940 110 -f $(top)/Makefile dnsmasq
fdacfb01 111 for f in `cd $(PO); echo *.po`; do \
24848940 112 cd $(top) && cd $(BUILDDIR) && $(MAKE) top="$(top)" -f $(top)/Makefile $${f%.po}.mo; \
b8187c80
SK
113 done
114
115install-i18n : all-i18n install-common
24848940 116 cd $(BUILDDIR); $(top)/bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL)
1f15b81d 117 cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL)
b8187c80 118
fdacfb01 119merge :
f7bfbdc8 120 @cd $(BUILDDIR) && $(MAKE) top="$(top)" -f $(top)/Makefile dnsmasq.pot
fdacfb01
SK
121 for f in `cd $(PO); echo *.po`; do \
122 echo -n msgmerge $(PO)/$$f && $(MSGMERGE) --no-wrap -U $(PO)/$$f $(BUILDDIR)/dnsmasq.pot; \
b8187c80 123 done
9e4abcb5 124
b7f666ff
SK
125# Cannonicalise .po file.
126%.po :
127 @cd $(BUILDDIR) && $(MAKE) -f $(top)/Makefile dnsmasq.pot
128 mv $(PO)/$*.po $(PO)/$*.po.orig && $(MSGMERGE) --no-wrap $(PO)/$*.po.orig $(BUILDDIR)/dnsmasq.pot >$(PO)/$*.po;
129
e5ffdb9c 130$(BUILDDIR):
fdacfb01 131 mkdir -p $(BUILDDIR)
b36ae194 132
ceae52df
SK
133# rules below are helpers for size tracking
134
135baseline : mostly_clean all
136 @cd $(BUILDDIR) && \
137 mv dnsmasq dnsmasq_baseline
138
139bloatcheck : $(BUILDDIR)/dnsmasq_baseline mostly_clean all
140 @cd $(BUILDDIR) && \
141 $(top)/bld/bloat-o-meter dnsmasq_baseline dnsmasq; \
142 size dnsmasq_baseline dnsmasq
9e4abcb5 143
8e4b8791
SK
144# rules below are targets in recusive makes with cwd=$(BUILDDIR)
145
81c538ef
YZ
146$(copts_conf): $(hdrs)
147 @rm -f *.o .copts_*
8e4b8791 148 @touch $@
316e2730 149
24848940
SK
150$(objs:.o=.c) $(hdrs):
151 ln -s $(top)/$(SRC)/$@ .
b36ae194 152
d8dbd903
YZ
153$(objs): $(copts_conf) $(hdrs)
154
1adadf58 155.c.o:
24848940 156 $(CC) $(CFLAGS) $(COPTS) $(i18n) $(build_cflags) $(RPM_OPT_FLAGS) -c $<
316e2730 157
d8dbd903 158dnsmasq : $(objs)
24848940 159 $(CC) $(LDFLAGS) -o $@ $(objs) $(build_libs) $(LIBS)
316e2730 160
24848940
SK
161dnsmasq.pot : $(objs:.o=.c) $(hdrs)
162 $(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(objs:.o=.c)
316e2730 163
24848940 164%.mo : $(top)/$(PO)/%.po dnsmasq.pot
4f8ff361 165 $(MSGMERGE) -o - $(top)/$(PO)/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo -
316e2730 166
ceae52df 167.PHONY : all clean mostly_clean install install-common all-i18n install-i18n merge baseline bloatcheck