From fdacfb01196c47aafd1dbb338e130d730e173cfe Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Tue, 28 Feb 2012 15:20:25 +0000 Subject: [PATCH] Makefile: support absolute paths in BUILDDIR --- CHANGELOG | 25 ++++++++++++++--------- Makefile | 53 +++++++++++++++++++++++++++---------------------- bld/get-version | 13 +++++------- 3 files changed, 50 insertions(+), 41 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 614eae5..3269406 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -45,18 +45,25 @@ version 2.60 round-robin to multiple servers, in the same way as --dhcp-boot. A good suggestion from Cristiano Cumer. - Support BUILDDIR variable in the Makefile. Allows - builds from multiple architectures in the same tree with eg - make BUILDDIR=linux + Support BUILDDIR variable in the Makefile. Allows builds + for multiple archs from the same source tree with eg. + make BUILDDIR=linux (relative to dnsmasq tree) + make BUILDDIR=/tmp/openbsd (absolute path) If BUILDDIR is not set, compilation happens in the src directory, as before. Suggestion from Mark Mitchell. - First cut at supporting DHCPv6. Support is pretty much - there for the sort of things the existing v4 server does, - including tags, options, static addresses and relay - support. Missing is prefix delegation. This is lightly - tested alpha code, it is NOT YET PRODUCTION READY. Test - reports would be greatly valued. + Support DHCPv6. Support is there for the sort of things + the existing v4 server does, including tags, options, + static addresses and relay support. Missing is prefix + delegation, which is probably not required in the dnsmasq + niche, and an easy way to accept prefix delegations from + an upstream DHCPv6 server, which is. Future plans include + support for DHCPv6 router option and MAC address option + (to make selecting clients by MAC address work like IPv4). + These will be added as the standards mature. + This code has been tested, but this is the first release, + so don't bet the farm on it just yet. Many thanks to all + testers who have got it this far. Support IPv6 router advertisements. This is a simple-minded implementation, aimed at providing the diff --git a/Makefile b/Makefile index 5fde74d..8264794 100644 --- a/Makefile +++ b/Makefile @@ -34,16 +34,21 @@ SRC = src PO = po MAN = man -DBUS_CFLAGS=`echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1` -DBUS_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1` -IDN_CFLAGS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn` -IDN_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn` -CT_CFLAGS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --cflags libnetfilter_conntrack` -CT_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --libs libnetfilter_conntrack` -LUA_CFLAGS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --cflags lua5.1` -LUA_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --libs lua5.1` +# pmake way to learn path of Makefile +TOP != echo `pwd`/ +# GNU make way to learn path of Makefile +TOP ?= $(shell pwd) + +DBUS_CFLAGS=`echo $(COPTS) | $(TOP)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1` +DBUS_LIBS= `echo $(COPTS) | $(TOP)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1` +IDN_CFLAGS= `echo $(COPTS) | $(TOP)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn` +IDN_LIBS= `echo $(COPTS) | $(TOP)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn` +CT_CFLAGS= `echo $(COPTS) | $(TOP)/bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --cflags libnetfilter_conntrack` +CT_LIBS= `echo $(COPTS) | $(TOP)/bld/pkg-wrapper HAVE_CONNTRACK $(PKG_CONFIG) --libs libnetfilter_conntrack` +LUA_CFLAGS= `echo $(COPTS) | $(TOP)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --cflags lua5.1` +LUA_LIBS= `echo $(COPTS) | $(TOP)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --libs lua5.1` SUNOS_LIBS= `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi` -VERSION= -DVERSION='\"`../bld/get-version`\"' +VERSION= -DVERSION='\"`$(TOP)/bld/get-version $(TOP)`\"' 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 \ @@ -53,12 +58,12 @@ OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \ HDRS = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \ dns-protocol.h radv-protocol.h - all : $(BUILDDIR) @cd $(BUILDDIR) && $(MAKE) \ + TOP="$(TOP)" \ BUILD_CFLAGS="$(VERSION) $(DBUS_CFLAGS) $(IDN_CFLAGS) $(CT_CFLAGS) $(LUA_CFLAGS)" \ BUILD_LIBS="$(DBUS_LIBS) $(IDN_LIBS) $(CT_LIBS) $(LUA_LIBS) $(SUNOS_LIBS)" \ - -f ../Makefile dnsmasq + -f $(TOP)/Makefile dnsmasq clean : rm -f *~ $(BUILDDIR)/*.mo contrib/*/*~ */*~ $(BUILDDIR)/*.pot @@ -73,33 +78,33 @@ install-common : all-i18n : $(BUILDDIR) @cd $(BUILDDIR) && $(MAKE) \ + TOP="$(TOP)" \ I18N=-DLOCALEDIR=\'\"$(LOCALEDIR)\"\' \ 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`" \ - -f ../Makefile dnsmasq - @cd $(PO); for f in *.po; do \ - cd ../$(BUILDDIR) && $(MAKE) \ - -f ../Makefile $${f%.po}.mo; \ + -f $(TOP)/Makefile dnsmasq + for f in `cd $(PO); echo *.po`; do \ + cd $(TOP) && cd $(BUILDDIR) && $(MAKE) TOP="$(TOP)" -f $(TOP)/Makefile $${f%.po}.mo; \ done install-i18n : all-i18n install-common - cd $(BUILDDIR); ../bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL) + cd $(BUILDDIR); $(TOP)/bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL) cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL) -merge : $(BUILDDIR) - @cd $(BUILDDIR) && $(MAKE) -f ../Makefile dnsmasq.pot - @cd $(PO); for f in *.po; do \ - echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(BUILDDIR)/dnsmasq.pot; \ +merge : + @cd $(BUILDDIR) && $(MAKE) -f $(TOP)/Makefile dnsmasq.pot + for f in `cd $(PO); echo *.po`; do \ + echo -n msgmerge $(PO)/$$f && $(MSGMERGE) --no-wrap -U $(PO)/$$f $(BUILDDIR)/dnsmasq.pot; \ done $(BUILDDIR): - mkdir $(BUILDDIR) + mkdir -p $(BUILDDIR) # rules below are targets in recusive makes with cwd=$(SRC) $(OBJS:.o=.c) $(HDRS): - ln -s ../$(SRC)/$@ . + ln -s $(TOP)/$(SRC)/$@ . .c.o: $(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $< @@ -110,8 +115,8 @@ dnsmasq : $(HDRS) $(OBJS) dnsmasq.pot : $(OBJS:.o=.c) $(HDRS) $(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(OBJS:.o=.c) -%.mo : ../po/%.po dnsmasq.pot - $(MSGMERGE) -o - ../po/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo - +%.mo : $(TOP)/po/%.po dnsmasq.pot + $(MSGMERGE) -o - $(TOP)/po/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo - .PHONY : all clean install install-common all-i18n install-i18n merge diff --git a/bld/get-version b/bld/get-version index a68b96b..3b082dc 100755 --- a/bld/get-version +++ b/bld/get-version @@ -9,21 +9,18 @@ # If we can find one which matches $v[0-9].* then we assume it's # a version-number tag, else we just use the whole string. -# we're called with pwd == TLD -cd .. - -if which git >/dev/null 2>&1 && [ -d .git ]; then - git describe -elif grep '\$Format:%d\$' VERSION >/dev/null 2>&1; then +if which git >/dev/null 2>&1 && [ -d $1/.git ]; then + cd $1; git describe +elif grep '\$Format:%d\$' $1/VERSION >/dev/null 2>&1; then # unsubstituted VERSION, but no git available. echo UNKNOWN else - vers=`cat VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep $v[0-9]` + vers=`cat $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep $v[0-9]` if [ $? -eq 0 ]; then echo "${vers}" | head -n 1 | tail -c +2 else - cat VERSION + cat $1/VERSION fi fi -- 2.39.5