From: Adam Sutton Date: Thu, 21 Feb 2013 11:58:48 +0000 (+0000) Subject: build: update build system to fix some odd use cases X-Git-Tag: v3.9~166 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fab063340974a35cd68ea5ff9759acce66a291c;p=thirdparty%2Ftvheadend.git build: update build system to fix some odd use cases --- diff --git a/Makefile b/Makefile index cd79dad8c..1498467eb 100644 --- a/Makefile +++ b/Makefile @@ -20,8 +20,8 @@ # Configuration # -include ${CURDIR}/.config.mk -PROG = ${BUILDDIR}/tvheadend +include $(dir $(lastword $(MAKEFILE_LIST))).config.mk +PROG := $(BUILDDIR)/tvheadend # # Common compiler flags @@ -31,9 +31,12 @@ CFLAGS += -Wall -Werror -Wwrite-strings -Wno-deprecated-declarations CFLAGS += -Wmissing-prototypes -fms-extensions CFLAGS += -g -funsigned-char -O2 CFLAGS += -D_FILE_OFFSET_BITS=64 -CFLAGS += -I${BUILDDIR} -I${CURDIR}/src -I${CURDIR} +CFLAGS += -I${BUILDDIR} -I${ROOTDIR}/src -I${ROOTDIR} LDFLAGS += -lrt -ldl -lpthread -lm +vpath %.c $(ROOTDIR) +vpath %.h $(ROOTDIR) + # # Other config # @@ -45,7 +48,7 @@ BUNDLE_FLAGS = ${BUNDLE_FLAGS-yes} # Binaries/Scripts # -MKBUNDLE = $(PYTHON) $(CURDIR)/support/mkbundle +MKBUNDLE = $(PYTHON) $(ROOTDIR)/support/mkbundle # # Debug/Output @@ -54,7 +57,7 @@ MKBUNDLE = $(PYTHON) $(CURDIR)/support/mkbundle ifndef V ECHO = printf "%-16s%s\n" $(1) $(2) BRIEF = CC MKBUNDLE CXX -MSG = $(subst $(CURDIR)/,,$@) +MSG = $(subst $(BUILDDIR)/,,$@) $(foreach VAR,$(BRIEF), \ $(eval $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) endif @@ -62,10 +65,10 @@ endif # # Core # -SRCS = src/main.c \ +SRCS = src/version.c \ + src/main.c \ src/utils.c \ src/wrappers.c \ - src/version.c \ src/access.c \ src/dtable.c \ src/tcp.c \ @@ -208,7 +211,7 @@ SRCS-${CONFIG_BUNDLE} += bundle.c BUNDLES-yes += docs/html docs/docresources src/webui/static BUNDLES-yes += data/conf BUNDLES-${CONFIG_DVBSCAN} += data/dvb-scan -BUNDLES = $(BUNDLES-yes) +BUNDLES = $(BUNDLES-yes:%=$(ROOTDIR)/%) # # Add-on modules @@ -237,13 +240,13 @@ all: ${PROG} # Check configure output is valid check_config: - @test $(CURDIR)/.config.mk -nt $(CURDIR)/configure\ + @test $(ROOTDIR)/.config.mk -nt $(ROOTDIR)/configure\ || echo "./configure output is old, please re-run" - @test $(CURDIR)/.config.mk -nt $(CURDIR)/configure + @test $(ROOTDIR)/.config.mk -nt $(ROOTDIR)/configure # Recreate configuration reconfigure: - $(CURDIR)/configure $(CONFIGURE_ARGS) + $(ROOTDIR)/configure $(CONFIGURE_ARGS) # Binary ${PROG}: check_config $(OBJS) $(ALLDEPS) @@ -252,7 +255,7 @@ ${PROG}: check_config $(OBJS) $(ALLDEPS) # Object ${BUILDDIR}/%.o: %.c @mkdir -p $(dir $@) - $(CC) -MD -MP $(CFLAGS) -c -o $@ $(CURDIR)/$< + $(CC) -MD -MP $(CFLAGS) -c -o $@ $< # Add-on ${BUILDDIR}/%.so: ${SRCS_EXTRA} @@ -265,24 +268,24 @@ clean: find . -name "*~" | xargs rm -f distclean: clean - rm -rf ${CURDIR}/build.* - rm -f ${CURDIR}/.config.mk + rm -rf ${ROOTDIR}/build.* + rm -f ${ROOTDIR}/.config.mk -# Create buildversion.h -src/version.c: FORCE - @$(CURDIR)/support/version $@ > /dev/null +# Create version +$(ROOTDIR)/src/version.c: FORCE + @$(ROOTDIR)/support/version $@ > /dev/null FORCE: # Include dependency files if they exist. -include $(DEPS) # Include OS specific targets -include support/${OSENV}.mk +include ${ROOTDIR}/support/${OSENV}.mk # Bundle files $(BUILDDIR)/bundle.o: $(BUILDDIR)/bundle.c @mkdir -p $(dir $@) - $(CC) -I${CURDIR}/src -c -o $@ $< + $(CC) -I${ROOTDIR}/src -c -o $@ $< $(BUILDDIR)/bundle.c: @mkdir -p $(dir $@) diff --git a/configure b/configure index 3d3ec68fa..542ec423d 100755 --- a/configure +++ b/configure @@ -9,7 +9,7 @@ # Setup # ########################################################################### -ROOTDIR=$(dirname $0) +ROOTDIR=$(cd $(dirname $0); pwd) # # Options diff --git a/support/configure.inc b/support/configure.inc index ecb85da4b..f5737f1fe 100644 --- a/support/configure.inc +++ b/support/configure.inc @@ -464,7 +464,7 @@ function write_config # Automatically generated by configure - DO NOT EDIT! CONFIGURE_ARGS = ${CONFIGURE_ARGS} ROOTDIR ?= ${ROOTDIR} -BUILDDIR ?= ${ROOTDIR}/build.${PLATFORM} +BUILDDIR ?= ${BUILDDIR} OSENV ?= ${OSENV} ARCH ?= ${ARCH} CPU ?= ${CPU}