From b46aae093634271931395d65f422f4b2a23112d3 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Mon, 25 Jan 2016 01:42:23 +0100 Subject: [PATCH] build: use a link instead of changing current directory when compiling If links don't work, fall back to using the full source path as was previously done. This should fix build failures with MSVC. Reviewed-by: Hendrik Leppkes Signed-off-by: Andreas Cadhalpun --- .gitignore | 1 + Makefile | 2 +- common.mak | 7 +++---- configure | 28 +++++++++++++++++++++------- library.mak | 2 +- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 93b0dca40a..9fc0ac269c 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,7 @@ /libavcodec/*_tables.h /libavutil/avconfig.h /libavutil/ffversion.h +/src /tests/audiogen /tests/base64 /tests/checkasm/checkasm diff --git a/Makefile b/Makefile index f3bd5f682d..e484249065 100644 --- a/Makefile +++ b/Makefile @@ -181,7 +181,7 @@ clean:: distclean:: $(RM) $(DISTCLEANSUFFIXES) - $(RM) config.* .config libavutil/avconfig.h .version avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h + $(RM) config.* .config libavutil/avconfig.h .version avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h src $(RM) -rf doc/examples/pc-uninstalled config: diff --git a/common.mak b/common.mak index 3812149ef5..03b51c5968 100644 --- a/common.mak +++ b/common.mak @@ -32,7 +32,7 @@ endif ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample # NASM requires -I path terminated with / -IFLAGS := -I$(DST_PATH)/ -I$(SRC_PATH)/ +IFLAGS := -I. -I$(SRC_LINK)/ CPPFLAGS := $(IFLAGS) $(CPPFLAGS) CFLAGS += $(ECFLAGS) CCFLAGS = $(CPPFLAGS) $(CFLAGS) @@ -43,12 +43,11 @@ CXXFLAGS += $(CPPFLAGS) $(CFLAGS) YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS) -LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)$(DST_PATH)/lib%) $(LDFLAGS) +LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS) define COMPILE $(call $(1)DEP,$(1)) - $(Q)cd $(SRC_PATH); if [ -n "$(findstring $(SRC_PATH),$<)" ]; then dest=$(subst $(SRC_PATH)/,,$<); else dest=$(DST_PATH)/$<; fi; \ - $(subst @,,$($(1))) $($(1)FLAGS) $($(1)_DEPFLAGS:$(@:.o=.d)=$(DST_PATH)/$(@:.o=.d)) $($(1)_C) $($(1)_O:$@=$(DST_PATH)/$@) $$dest + $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) endef COMPILE_C = $(call COMPILE,CC) diff --git a/configure b/configure index 0685133975..57b526fce9 100755 --- a/configure +++ b/configure @@ -4696,6 +4696,26 @@ case $target_os in ;; esac +# test if creating links works +link_dest=$(mktemp -u $TMPDIR/dest_XXXXXXXX) +link_name=$(mktemp -u $TMPDIR/name_XXXXXXXX) +mkdir "$link_dest" +$ln_s "$link_dest" "$link_name" +touch "$link_dest/test_file" +if [ -e "$link_name/test_file" ]; then + # create link to source path + [ -e src ] && rm src + $ln_s "$source_path" src + source_link=src +else + # creating directory links doesn't work + # fall back to using the full source path + source_link="$source_path" +fi +# cleanup +rm -r "$link_dest" +rm -r "$link_name" + # determine libc flavour probe_libc(){ @@ -6229,12 +6249,6 @@ enabled stripping || strip="echo skipping strip" config_files="$TMPH config.mak doc/config.texi" -if enabled msvc; then - dst_path=$(pwd -W) -else - dst_path=$(pwd) -fi - cat > config.mak < $(@:.o=.d) - $(Q)cd $(SRC_PATH); $(subst @,,$(YASM)) $(YASMFLAGS) -I $(