1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00

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 <h.leppkes@gmail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
This commit is contained in:
Andreas Cadhalpun 2016-01-25 01:42:23 +01:00
parent 8b02af1e6f
commit b46aae0936
5 changed files with 27 additions and 13 deletions

1
.gitignore vendored
View File

@ -64,6 +64,7 @@
/libavcodec/*_tables.h /libavcodec/*_tables.h
/libavutil/avconfig.h /libavutil/avconfig.h
/libavutil/ffversion.h /libavutil/ffversion.h
/src
/tests/audiogen /tests/audiogen
/tests/base64 /tests/base64
/tests/checkasm/checkasm /tests/checkasm/checkasm

View File

@ -181,7 +181,7 @@ clean::
distclean:: distclean::
$(RM) $(DISTCLEANSUFFIXES) $(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 $(RM) -rf doc/examples/pc-uninstalled
config: config:

View File

@ -32,7 +32,7 @@ endif
ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
# NASM requires -I path terminated with / # NASM requires -I path terminated with /
IFLAGS := -I$(DST_PATH)/ -I$(SRC_PATH)/ IFLAGS := -I. -I$(SRC_LINK)/
CPPFLAGS := $(IFLAGS) $(CPPFLAGS) CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
CFLAGS += $(ECFLAGS) CFLAGS += $(ECFLAGS)
CCFLAGS = $(CPPFLAGS) $(CFLAGS) CCFLAGS = $(CPPFLAGS) $(CFLAGS)
@ -43,12 +43,11 @@ CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS) HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)$(DST_PATH)/lib%) $(LDFLAGS) LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
define COMPILE define COMPILE
$(call $(1)DEP,$(1)) $(call $(1)DEP,$(1))
$(Q)cd $(SRC_PATH); if [ -n "$(findstring $(SRC_PATH),$<)" ]; then dest=$(subst $(SRC_PATH)/,,$<); else dest=$(DST_PATH)/$<; fi; \ $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
$(subst @,,$($(1))) $($(1)FLAGS) $($(1)_DEPFLAGS:$(@:.o=.d)=$(DST_PATH)/$(@:.o=.d)) $($(1)_C) $($(1)_O:$@=$(DST_PATH)/$@) $$dest
endef endef
COMPILE_C = $(call COMPILE,CC) COMPILE_C = $(call COMPILE,CC)

28
configure vendored
View File

@ -4696,6 +4696,26 @@ case $target_os in
;; ;;
esac 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 # determine libc flavour
probe_libc(){ probe_libc(){
@ -6229,12 +6249,6 @@ enabled stripping || strip="echo skipping strip"
config_files="$TMPH config.mak doc/config.texi" config_files="$TMPH config.mak doc/config.texi"
if enabled msvc; then
dst_path=$(pwd -W)
else
dst_path=$(pwd)
fi
cat > config.mak <<EOF cat > config.mak <<EOF
# Automatically generated by configure - do not modify! # Automatically generated by configure - do not modify!
ifndef FFMPEG_CONFIG_MAK ifndef FFMPEG_CONFIG_MAK
@ -6250,10 +6264,10 @@ DOCDIR=\$(DESTDIR)$docdir
MANDIR=\$(DESTDIR)$mandir MANDIR=\$(DESTDIR)$mandir
PKGCONFIGDIR=\$(DESTDIR)$pkgconfigdir PKGCONFIGDIR=\$(DESTDIR)$pkgconfigdir
SRC_PATH=$source_path SRC_PATH=$source_path
SRC_LINK=$source_link
ifndef MAIN_MAKEFILE ifndef MAIN_MAKEFILE
SRC_PATH:=\$(SRC_PATH:.%=..%) SRC_PATH:=\$(SRC_PATH:.%=..%)
endif endif
DST_PATH=$dst_path
CC_IDENT=$cc_ident CC_IDENT=$cc_ident
ARCH=$arch ARCH=$arch
INTRINSICS=$intrinsics INTRINSICS=$intrinsics

View File

@ -28,7 +28,7 @@ $(SUBDIR)x86/%$(DEFAULT_YASMD).asm: $(SUBDIR)x86/%.asm
$(SUBDIR)x86/%.o: $(SUBDIR)x86/%$(YASMD).asm $(SUBDIR)x86/%.o: $(SUBDIR)x86/%$(YASMD).asm
$(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d) $(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
$(Q)cd $(SRC_PATH); $(subst @,,$(YASM)) $(YASMFLAGS) -I $(<D)/ -o $(DST_PATH)/$@ $(subst $(SRC_PATH)/,,$<) $(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
-$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@) -$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS) LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS)