Fix ffmpeg plugin not compiling on UNIX and Windows.

Suppress passing -O3 to bullet's cmake. This will fail otherwise.
Fix plugin.c attempting to return 'false' instead of 'qfalse'.


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5988 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Eukara 2021-07-22 08:40:55 +00:00
parent de522617e7
commit 878f9b9d7c
2 changed files with 68 additions and 65 deletions

View file

@ -8,6 +8,7 @@ PLUG_LDFLAGS_ZLIB=-L../engine/libs/mingw-libs -lzlib
PLUG_LDFLAGS_DL= PLUG_LDFLAGS_DL=
CMAKERULES=$(OUT_DIR)/toolchain_$(FTE_TARGET).cmake CMAKERULES=$(OUT_DIR)/toolchain_$(FTE_TARGET).cmake
endif endif
ifeq ($(FTE_TARGET),win64) ifeq ($(FTE_TARGET),win64)
PLUG_NATIVE_EXT=_x64.dll PLUG_NATIVE_EXT=_x64.dll
PLUG_LDFLAGS=-Wl,--support-old-code -static-libgcc PLUG_LDFLAGS=-Wl,--support-old-code -static-libgcc
@ -59,9 +60,11 @@ ifeq ($(PLUG_NATIVE_EXT),)
PLUG_NATIVE_EXT=_amd64.so PLUG_NATIVE_EXT=_amd64.so
endif endif
endif endif
ifneq ($(shell echo|$(CC) -E -dM -|grep __i386__),) ifneq ($(shell echo|$(CC) -E -dM -|grep __i386__),)
PLUG_NATIVE_EXT=_x86.so PLUG_NATIVE_EXT=_x86.so
endif endif
ifneq ($(shell echo|$(CC) -E -dM -|grep __arm__),) ifneq ($(shell echo|$(CC) -E -dM -|grep __arm__),)
#gnueabi[hf] #gnueabi[hf]
ifneq ($(shell echo|$(CC) -E -dM -|grep __SOFTFP__),) ifneq ($(shell echo|$(CC) -E -dM -|grep __SOFTFP__),)
@ -70,16 +73,20 @@ ifeq ($(PLUG_NATIVE_EXT),)
PLUG_NATIVE_EXT=_armhf.so PLUG_NATIVE_EXT=_armhf.so
endif endif
endif endif
ifneq ($(shell echo|$(CC) -E -dM -|grep __ppc__),) ifneq ($(shell echo|$(CC) -E -dM -|grep __ppc__),)
PLUG_NATIVE_EXT=_ppc.so #32bit big-endian PLUG_NATIVE_EXT=_ppc.so #32bit big-endian
endif endif
ifneq ($(shell echo|$(CC) -E -dM -|grep __ppc64__),) ifneq ($(shell echo|$(CC) -E -dM -|grep __ppc64__),)
PLUG_NATIVE_EXT=_ppc64.so #64bit big-endian PLUG_NATIVE_EXT=_ppc64.so #64bit big-endian
endif endif
ifneq ($(shell echo|$(CC) -E -dM -|grep __ppc64le__),) ifneq ($(shell echo|$(CC) -E -dM -|grep __ppc64le__),)
PLUG_NATIVE_EXT=_ppc64le.so #64bit little-endian. PLUG_NATIVE_EXT=_ppc64le.so #64bit little-endian.
endif endif
endif endif
ifeq ($(FTE_TARGET),droid) ifeq ($(FTE_TARGET),droid)
#plugins get written to the tmp build dir, to avoid conflicts #plugins get written to the tmp build dir, to avoid conflicts
PLUG_PREFIX=$(OUT_DIR)/m_droid-$(DROID_ARCH)/libplug_ PLUG_PREFIX=$(OUT_DIR)/m_droid-$(DROID_ARCH)/libplug_
@ -120,27 +127,8 @@ help:
#linux users are expected to have the library installed locally already. If your version is too old or missing, run the following command to install it (to /usr/local), then delete the gz and directory. #linux users are expected to have the library installed locally already. If your version is too old or missing, run the following command to install it (to /usr/local), then delete the gz and directory.
#wget http://ffmpeg.org/releases/ffmpeg-1.2.tar.gz && cd tar xvfz ffmpeg-1.2.tar.gz && cd ffmpeg-1.2/ && ./configure --disable-yasm --enable-shared && make && sudo make install #wget http://ffmpeg.org/releases/ffmpeg-1.2.tar.gz && cd tar xvfz ffmpeg-1.2.tar.gz && cd ffmpeg-1.2/ && ./configure --disable-yasm --enable-shared && make && sudo make install
#we use ffmpeg's version for some reason, as opposed to libav. not sure what the differences are meant to be, but libav seemed to have non-depricated functions defined, docs that say to use them, and these functions missing. #we use ffmpeg's version for some reason, as opposed to libav. not sure what the differences are meant to be, but libav seemed to have non-depricated functions defined, docs that say to use them, and these functions missing.
ifeq ($(findstring win,$(FTE_TARGET)),win)
AV_VER=ffmpeg-4.0 AV_VER=ffmpeg-4.0
ifeq (0,1)
AV_ARCHIVEEXT=.z7
AV_EXTRACT=7z e -y
else
AV_ARCHIVEEXT=.zip
AV_EXTRACT=unzip -ju
endif
AV_W32_DEV=$(AV_VER)-win32-dev$(AV_ARCHIVEEXT)
AV_W64_DEV=$(AV_VER)-win64-dev$(AV_ARCHIVEEXT)
AV_W32_BIN=$(AV_VER)-win32-shared$(AV_ARCHIVEEXT)
AV_W64_BIN=$(AV_VER)-win64-shared$(AV_ARCHIVEEXT)
AV_URL32_DEV=https://ffmpeg.zeranoe.com/builds/win32/dev/$(AV_W32_DEV)
AV_URL64_DEV=https://ffmpeg.zeranoe.com/builds/win64/dev/$(AV_W64_DEV)
AV_URL32_BIN=https://ffmpeg.zeranoe.com/builds/win32/shared/$(AV_W32_BIN)
AV_URL64_BIN=https://ffmpeg.zeranoe.com/builds/win64/shared/$(AV_W64_BIN)
AV_PRE32_DEV=$(AV_VER)-win32-dev/
AV_PRE64_DEV=$(AV_VER)-win64-dev/
AV_PRE32_BIN=$(AV_VER)-win32-shared/
AV_PRE64_BIN=$(AV_VER)-win64-shared/
ifeq ($(findstring win,$(FTE_TARGET)),win) ifeq ($(findstring win,$(FTE_TARGET)),win)
AV_BASE=$(abspath $(OUT_DIR)/../fte_libav_$(AV_VER))/ AV_BASE=$(abspath $(OUT_DIR)/../fte_libav_$(AV_VER))/
@ -164,14 +152,37 @@ ifeq ($(FTE_TARGET),bsd)
AV_LDFLAGS+=-lc AV_LDFLAGS+=-lc
endif endif
AVPLUG_OBJS= avplug/avaudio.c avplug/avencode.c avplug/avdecode.c plugin.c AVPLUG_OBJS= avplug/avaudio.c avplug/avencode.c avplug/avdecode.c plugin.c
ifeq ($(findstring win,$(FTE_TARGET)),win)
ifeq (0,1)
AV_ARCHIVEEXT=.z7
AV_EXTRACT=7z e -y
else
AV_ARCHIVEEXT=.zip
AV_EXTRACT=unzip -ju
endif
AV_W32_DEV=$(AV_VER)-win32-dev$(AV_ARCHIVEEXT)
AV_W64_DEV=$(AV_VER)-win64-dev$(AV_ARCHIVEEXT)
AV_W32_BIN=$(AV_VER)-win32-shared$(AV_ARCHIVEEXT)
AV_W64_BIN=$(AV_VER)-win64-shared$(AV_ARCHIVEEXT)
AV_URL32_DEV=https://archive.org/download/zeranoe/win32/dev/$(AV_W32_DEV)
AV_URL64_DEV=https://archive.org/download/zeranoe/win64/dev/$(AV_W64_DEV)
AV_URL32_BIN=https://archive.org/download/zeranoe/win32/shared/$(AV_W32_BIN)
AV_URL64_BIN=https://archive.org/download/zeranoe/win64/shared/$(AV_W64_BIN)
AV_PRE32_DEV=$(AV_VER)-win32-dev/
AV_PRE64_DEV=$(AV_VER)-win64-dev/
AV_PRE32_BIN=$(AV_VER)-win32-shared/
AV_PRE64_BIN=$(AV_VER)-win64-shared/
ifeq ($(FTE_TARGET),win32) ifeq ($(FTE_TARGET),win32)
FFMPEG_ZIP=$(OUT_DIR)/$(AV_VER)-x86.zip FFMPEG_ZIP=$(AV_BASE)/$(AV_VER)-x86.zip
#NATIVE_PLUGINS+=ffmpeg #NATIVE_PLUGINS+=ffmpeg
endif endif
ifeq ($(FTE_TARGET),win64) ifeq ($(FTE_TARGET),win64)
FFMPEG_ZIP=$(OUT_DIR)/$(AV_VER)-x64.zip FFMPEG_ZIP=$(AV_BASE)/$(AV_VER)-x64.zip
#NATIVE_PLUGINS+=ffmpeg #NATIVE_PLUGINS+=ffmpeg
endif endif
@ -200,29 +211,21 @@ $(AV_BASE)libavformat/avformat.h:
mkdir -p $(AV_BASE)libavutil && cd $(AV_BASE)libavutil && $(AV_EXTRACT) ../$(AV_W32_DEV) $(AV_PRE32_DEV)include/libavutil/* && cd - mkdir -p $(AV_BASE)libavutil && cd $(AV_BASE)libavutil && $(AV_EXTRACT) ../$(AV_W32_DEV) $(AV_PRE32_DEV)include/libavutil/* && cd -
mkdir -p $(AV_BASE)libswscale && cd $(AV_BASE)libswscale && $(AV_EXTRACT) ../$(AV_W32_DEV) $(AV_PRE32_DEV)include/libswscale/* && cd - mkdir -p $(AV_BASE)libswscale && cd $(AV_BASE)libswscale && $(AV_EXTRACT) ../$(AV_W32_DEV) $(AV_PRE32_DEV)include/libswscale/* && cd -
mkdir -p $(AV_BASE)lib32 && cd $(AV_BASE)lib32 && $(AV_EXTRACT) ../$(AV_W32_DEV) $(AV_PRE32_DEV)lib/avformat.lib $(AV_PRE32_DEV)lib/avcodec.lib $(AV_PRE32_DEV)lib/avutil.lib $(AV_PRE32_DEV)lib/swscale.lib && cd - mkdir -p $(AV_BASE)lib32 && cd $(AV_BASE)lib32 && $(AV_EXTRACT) ../$(AV_W32_DEV) $(AV_PRE32_DEV)lib/avformat.lib $(AV_PRE32_DEV)lib/avcodec.lib $(AV_PRE32_DEV)lib/avutil.lib $(AV_PRE32_DEV)lib/swscale.lib && cd -
#rm $(AV_BASE)$(AV_W32)
cd $(AV_BASE) && wget -N $(AV_URL64_DEV) cd $(AV_BASE) && wget -N $(AV_URL64_DEV)
mkdir -p $(AV_BASE)lib64 && cd $(AV_BASE)lib64 && $(AV_EXTRACT) ../$(AV_W64_DEV) $(AV_PRE64_DEV)lib/avformat.lib $(AV_PRE64_DEV)lib/avcodec.lib $(AV_PRE64_DEV)lib/avutil.lib $(AV_PRE64_DEV)lib/swscale.lib && cd - mkdir -p $(AV_BASE)lib64 && cd $(AV_BASE)lib64 && $(AV_EXTRACT) ../$(AV_W64_DEV) $(AV_PRE64_DEV)lib/avformat.lib $(AV_PRE64_DEV)lib/avcodec.lib $(AV_PRE64_DEV)lib/avutil.lib $(AV_PRE64_DEV)lib/swscale.lib && cd -
#rm $(AV_BASE)$(AV_W64)
distclean: distclean:
rm $(AV_BASE)libavformat/avformat.h rm $(AV_BASE)libavformat/avformat.h
rm $(AV_BASE)$(AV_VER)-win32.zip rm $(AV_BASE)$(AV_VER)-win32.zip
rm $(AV_BASE)$(AV_VER)-win64.zip rm $(AV_BASE)$(AV_VER)-win64.zip
$(PLUG_PREFIX)ffmpeg$(PLUG_NATIVE_EXT): $(AV_DEP) $(FFMPEG_ZIP) $(PLUG_PREFIX)ffmpeg$(PLUG_NATIVE_EXT): $(AV_DEP) $(AVPLUG_OBJS)
$(PLUG_PREFIX)ffmpeg$(PLUG_NATIVE_EXT): $(AVPLUG_OBJS)
$(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -s -o $@ -shared $(PLUG_CFLAGS) $(AV_CFLAGS) $(AVPLUG_OBJS) $(PLUG_DEFFILE) $(PLUG_LDFLAGS) $(AV_LDFLAGS) $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -s -o $@ -shared $(PLUG_CFLAGS) $(AV_CFLAGS) $(AVPLUG_OBJS) $(PLUG_DEFFILE) $(PLUG_LDFLAGS) $(AV_LDFLAGS)
#above uses wget and zips and mess.
else else # NIX
#just use pkg-config $(PLUG_PREFIX)ffmpeg$(PLUG_NATIVE_EXT):
$(PLUG_PREFIX)ffmpeg$(PLUG_NATIVE_EXT): $(AVPLUG_OBJS) $(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -s -o $@ -shared $(PLUG_CFLAGS) $(AV_CFLAGS) $(AVPLUG_OBJS) $(PLUG_DEFFILE) $(PLUG_LDFLAGS) $(AV_LDFLAGS)
$(CC) $(BASE_CFLAGS) $(CFLAGS) -DFTEPLUGIN -s -o $@ -shared $(PLUG_CFLAGS) $(AVPLUG_OBJS) $(PLUG_DEFFILE) $(PLUG_LDFLAGS) `$(PKGCONFIG) --cflags --libs libavformat libavcodec libavutil libswscale`
ifeq ($(shell $(PKGCONFIG) --exists libavformat libavcodec libavutil libswscale && echo 1),1)
NATIVE_PLUGINS+=ffmpeg
endif
endif endif
###################################### ######################################
@ -288,7 +291,7 @@ $(BULLET_BASE)bullet3-$(BULLET_VER)/lib/libBulletDynamics.a $(BULLET_BASE)bullet
$(BULLET_LIB): $(OUT_DIR)/../bullet3-$(BULLET_VER).tar.gz $(CMAKERULES) $(BULLET_LIB): $(OUT_DIR)/../bullet3-$(BULLET_VER).tar.gz $(CMAKERULES)
mkdir -p $(BULLET_BASE) && cd $(BULLET_BASE) && tar xvfz $< mkdir -p $(BULLET_BASE) && cd $(BULLET_BASE) && tar xvfz $<
rm $(BULLET_BASE)bullet3-$(BULLET_VER)/build3/cmake/FindPythonLibs.cmake #cmake is a pile of shite and fails at cross compiling. oh well, we didn't want any python stuff anyway. rm $(BULLET_BASE)bullet3-$(BULLET_VER)/build3/cmake/FindPythonLibs.cmake #cmake is a pile of shite and fails at cross compiling. oh well, we didn't want any python stuff anyway.
cd $(BULLET_BASE)bullet3-$(BULLET_VER)/ && cmake $(PLUG_CMAKE) -DBUILD_DEMOS:BOOL=OFF -DBUILD_EXTRAS:BOOL=OFF -DLIBRARY_OUTPUT_PATH=$(BULLET_BASE)bullet3-$(BULLET_VER)/lib . && $(MAKE) LinearMath BulletDynamics BulletCollision cd $(BULLET_BASE)bullet3-$(BULLET_VER)/ && cmake $(subst -O3,,$(PLUG_CMAKE)) -DBUILD_DEMOS:BOOL=OFF -DBUILD_EXTRAS:BOOL=OFF -DLIBRARY_OUTPUT_PATH=$(BULLET_BASE)bullet3-$(BULLET_VER)/lib . && $(MAKE) LinearMath BulletDynamics BulletCollision
#./configure --enable-double-precision --disable-demos --without-x CXX="$(CC)" CFLAGS="$(PLUG_CFLAGS)" CXXFLAGS="$(PLUG_CXXFLAGS)" --host=`$(CC) -dumpmachine` && make #./configure --enable-double-precision --disable-demos --without-x CXX="$(CC)" CFLAGS="$(PLUG_CFLAGS)" CXXFLAGS="$(PLUG_CXXFLAGS)" --host=`$(CC) -dumpmachine` && make

View file

@ -235,7 +235,7 @@ qboolean NATIVEEXPORT FTEPlug_Init(plugcorefuncs_t *corefuncs)
cmdfuncs = (plugcmdfuncs_t*)plugfuncs->GetEngineInterface(plugcmdfuncs_name, sizeof(*cmdfuncs)); cmdfuncs = (plugcmdfuncs_t*)plugfuncs->GetEngineInterface(plugcmdfuncs_name, sizeof(*cmdfuncs));
cvarfuncs = (plugcvarfuncs_t*)plugfuncs->GetEngineInterface(plugcvarfuncs_name, sizeof(*cvarfuncs)); cvarfuncs = (plugcvarfuncs_t*)plugfuncs->GetEngineInterface(plugcvarfuncs_name, sizeof(*cvarfuncs));
if (!plugfuncs || !cmdfuncs || !cvarfuncs) if (!plugfuncs || !cmdfuncs || !cvarfuncs)
return false; //erk return qfalse; //erk
return Plug_Init(); return Plug_Init();
} }