Add BUILD_DIR variable to makefile.

This commit is contained in:
Simon Kelley
2012-02-13 12:54:34 +00:00
parent 127ea40ae7
commit b36ae19434
2 changed files with 35 additions and 17 deletions

View File

@@ -45,6 +45,12 @@ version 2.60
round-robin to multiple servers, in the same way as round-robin to multiple servers, in the same way as
--dhcp-boot. A good suggestion from Cristiano Cumer. --dhcp-boot. A good suggestion from Cristiano Cumer.
Support BUILD_DIR variable in the Makefile. Allows
builds from multiple architectures in the same tree with eg
make BUILD_DIR=linux
If BUILD_DIR is not set, compilation happens in the src
directory, as before. Suggestion from Mark Mitchell.
version 2.59 version 2.59
Fix regression in 2.58 which caused failure to start up Fix regression in 2.58 which caused failure to start up

View File

@@ -18,14 +18,16 @@ BINDIR = ${PREFIX}/sbin
MANDIR = ${PREFIX}/share/man MANDIR = ${PREFIX}/share/man
LOCALEDIR = ${PREFIX}/share/locale LOCALEDIR = ${PREFIX}/share/locale
BUILD_DIR = $(SRC)
CFLAGS = -Wall -W -O2
PKG_CONFIG = pkg-config PKG_CONFIG = pkg-config
INSTALL = install INSTALL = install
MSGMERGE = msgmerge MSGMERGE = msgmerge
MSGFMT = msgfmt MSGFMT = msgfmt
XGETTEXT = xgettext XGETTEXT = xgettext
CFLAGS = -Wall -W -O2
################################################################# #################################################################
SRC = src SRC = src
@@ -47,58 +49,68 @@ OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \ dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o dhcp-common.o helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o dhcp-common.o
all : HDRS = dnsmasq.h config.h dhcp_protocol.h dhcp6_protocol.h dns_protocol.h
@cd $(SRC) && $(MAKE) \
all : $(BUILD_DIR)
@cd $(BUILD_DIR) && $(MAKE) \
BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(IDN_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS)" \ BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(IDN_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS)" \
BUILD_LIBS="$(DBUS_LIBS) $(IDN_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS)" \ BUILD_LIBS="$(DBUS_LIBS) $(IDN_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS)" \
-f ../Makefile dnsmasq -f ../Makefile dnsmasq
clean : clean :
rm -f *~ $(SRC)/*.mo contrib/*/*~ */*~ $(SRC)/*.pot rm -f *~ $(BUILD_DIR)/*.mo contrib/*/*~ */*~ $(BUILD_DIR)/*.pot
rm -f $(SRC)/*.o $(SRC)/dnsmasq.a $(SRC)/dnsmasq core */core rm -f $(BUILD_DIR)/*.o $(BUILD_DIR)/dnsmasq.a $(BUILD_DIR)/dnsmasq core */core
install : all install-common install : all install-common
install-common : install-common :
$(INSTALL) -d $(DESTDIR)$(BINDIR) -d $(DESTDIR)$(MANDIR)/man8 $(INSTALL) -d $(DESTDIR)$(BINDIR) -d $(DESTDIR)$(MANDIR)/man8
$(INSTALL) -m 644 $(MAN)/dnsmasq.8 $(DESTDIR)$(MANDIR)/man8 $(INSTALL) -m 644 $(MAN)/dnsmasq.8 $(DESTDIR)$(MANDIR)/man8
$(INSTALL) -m 755 $(SRC)/dnsmasq $(DESTDIR)$(BINDIR) $(INSTALL) -m 755 $(BUILD_DIR)/dnsmasq $(DESTDIR)$(BINDIR)
all-i18n : all-i18n : $(BUILD_DIR)
@cd $(SRC) && $(MAKE) \ @cd $(BUILD_DIR) && $(MAKE) \
I18N=-DLOCALEDIR=\'\"$(LOCALEDIR)\"\' \ I18N=-DLOCALEDIR=\'\"$(LOCALEDIR)\"\' \
BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS) `$(PKG_CONFIG) --cflags libidn`" \ BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS) `$(PKG_CONFIG) --cflags libidn`" \
BUILD_LIBS="$(DBUS_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS) `$(PKG_CONFIG) --libs libidn`" \ BUILD_LIBS="$(DBUS_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS) `$(PKG_CONFIG) --libs libidn`" \
-f ../Makefile dnsmasq -f ../Makefile dnsmasq
@cd $(PO); for f in *.po; do \ @cd $(PO); for f in *.po; do \
cd ../$(SRC) && $(MAKE) \ cd ../$(BUILD_DIR) && $(MAKE) \
-f ../Makefile $${f%.po}.mo; \ -f ../Makefile $${f%.po}.mo; \
done done
install-i18n : all-i18n install-common install-i18n : all-i18n install-common
cd $(SRC); ../bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL) cd $(BUILD_DIR); ../bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL)
cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL) cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL)
merge : merge : $(BUILD_DIR)
@cd $(SRC) && $(MAKE) -f ../Makefile dnsmasq.pot @cd $(BUILD_DIR) && $(MAKE) -f ../Makefile dnsmasq.pot
@cd $(PO); for f in *.po; do \ @cd $(PO); for f in *.po; do \
echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(SRC)/dnsmasq.pot; \ echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(BUILD_DIR)/dnsmasq.pot; \
done done
$(BUILD_DIR):
mkdir $(BUILD_DIR)
# rules below are targets in recusive makes with cwd=$(SRC) # rules below are targets in recusive makes with cwd=$(SRC)
.c.o: $(OBJS:.o=.c) $(HDRS):
$(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $< ln -s ../$(SRC)/$@ .
%.o: %.c $(HDRS)
$(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $*.c
dnsmasq : $(OBJS) dnsmasq : $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(BUILD_LIBS) $(LIBS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(BUILD_LIBS) $(LIBS)
dnsmasq.pot : $(OBJS:.o=.c) dnsmasq.h config.h dnsmasq.pot : $(OBJS:.o=.c) $(HDRS)
$(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(OBJS:.o=.c) $(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(OBJS:.o=.c)
%.mo : ../po/%.po dnsmasq.pot %.mo : ../po/%.po dnsmasq.pot
$(MSGMERGE) -o - ../po/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo - $(MSGMERGE) -o - ../po/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo -
.PHONY : all clean install install-common all-i18n install-i18n merge .PHONY : all clean install install-common all-i18n install-i18n merge