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