# This file is part of WebPFormat, a File Format plugin for Adobe Photoshop # Copyright (C) 2010-2013 Toby Thain, toby@telegraphics.com.au # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # GNU Makefile: # libvpx build for Win32 with MS Visual C++ Express Edition # running under WINE on Linux. # ,-. | # / | _ _ _|__|_ _ TM # | -- |/ | |_) | | | \ # \__/ | | \_, \_ \_ \_| # # --------- Disclaimer --------- # Don't take this ugly hack too seriously - but it does achieve # my goal of being able to cross-build libvpx for Windows from Linux # without having to bother with Windows or IDEs. # How to use it # 1) Requires libvpx. There is a target in the main Makefile to clone # the correct tag. (If you have trouble, try 'make realclean' first.) # $ make libvpx # 2) Uncomment required libvpx architecture definitions below. # 3) Requires libwebp. Again, use libwebp target in main Makefile to clone. # 4) Configure the VC project(s), compile and assemble all vpx object files: # $ make -f Makefile.wine # 5) Then run the plugin's NMAKE makefile: # $ wine nmake /f nmake.mak # Tip: This *won't work* if a different architecture is already configured. # To fix that, 'make -f Makefile.wine realclean' # (You'll see something like: # idctllm_mmx.obj : fatal error LNK1112: module machine type 'x64' # conflicts with target machine type 'X86' ) # # At step (3): If you see this error: # libvpx\vpx_ports/x86.h(123) : error C4235: nonstandard extension used : '__asm' keyword not supported on this architecture # it means that your toolchain is configured for x64. # Change the environment variables for a 32-bit target. LIBVPX = libvpx LIBWEBP = libwebp # Define libvpx architecture # (per Tom Finegan, "use vs8 for Visual Studio 2005 and vs9 for 2008") # 32-bit build: VPXTARGET = x86-win32-vs9 LIBWEBP_ARCH = x86 AFLAGS = -f win32 # 64-bit build: #VPXTARGET = x86_64-win64-vs9 #LIBWEBP_ARCH = x64 #AFLAGS = -f x64 # MUST be x64; win64 will not work. AS = yasm CC = wine cl CFLAGS = /O2 CPPFLAGS = /DWIN32 /I$(LIBVPX)/vpx /I$(LIBVPX) \ /I$(LIBVPX)/vp8/decoder /I$(LIBVPX)/vp8/decoder/x86 \ /I$(LIBVPX)/vp8/encoder /I$(LIBVPX)/vp8/encoder/x86 \ /I$(LIBVPX)/vp8/common /I$(LIBVPX)/vp8/common/x86 include vpx.mk vpath %.asm $(LIBVPX) \ $(LIBVPX)/vp8/common/x86 \ $(LIBVPX)/vp8/encoder/x86 \ $(LIBVPX)/vp8/decoder/x86 \ $(LIBVPX)/vpx_ports %.obj : %.asm ; $(AS) $(AFLAGS) -I$(LIBVPX) $< CSRC := $(addprefix $(LIBVPX)/, $(filter %.c, $(VPXSRC))) COBJ := $(notdir $(subst .c,.obj, $(CSRC))) ASRC := $(filter %.asm, $(VPXSRC)) AOBJ := $(notdir $(subst .asm,.obj, $(ASRC))) LIBWEBP_LIB := ../obj/release-static/$(LIBWEBP_ARCH)/lib/libwebp.lib LIBWEBP_ENV := /e ARCH=$(LIBWEBP_ARCH) /e CFG=release-static /e RTLIBCFG=static .PHONY : all vpxobj clean realclean all : $(LIBVPX)/vpx.vcproj \ $(LIBVPX)/asm_com_offsets.asm \ $(LIBVPX)/asm_dec_offsets.asm \ $(LIBVPX)/asm_enc_offsets.asm \ $(AOBJ) \ $(LIBWEBP_LIB) $(CC) $(CFLAGS) $(CPPFLAGS) /c $(CSRC) # Show the list of object files, needed by the NMAKE makefile. vpxobj : $(LIBVPX)/vpx.vcproj # Copy the following into NMAKE.MAK: @echo VPXOBJ = $(COBJ) $(AOBJ) # Build this tool natively, because we might be cross-building to a Windows runtime # that we cannot actually use at build-time (e.g. Win64 versus a 32-bit Linux/WINE installation). OBJ_INT_EXTRACT = $(LIBVPX)/build/make/obj_int_extract $(OBJ_INT_EXTRACT) : $(LIBVPX)/build/make/obj_int_extract.c $(LIBVPX)/Makefile gcc -o $@ $< -I$(LIBVPX) -D__MINGW32__ # pretend we are building on Win32, to get COFF decoder $(LIBVPX)/asm_com_offsets.asm : $(LIBVPX)/vp8/common/asm_com_offsets.c $(OBJ_INT_EXTRACT) $(CC) /I $(LIBVPX) /c $< && $(OBJ_INT_EXTRACT) rvds asm_com_offsets.obj > $@ $(LIBVPX)/asm_dec_offsets.asm : $(LIBVPX)/vp8/decoder/asm_dec_offsets.c $(OBJ_INT_EXTRACT) $(CC) /I $(LIBVPX) /c $< && $(OBJ_INT_EXTRACT) rvds asm_dec_offsets.obj > $@ $(LIBVPX)/asm_enc_offsets.asm : $(LIBVPX)/vp8/encoder/asm_enc_offsets.c $(OBJ_INT_EXTRACT) $(CC) /I $(LIBVPX) /c $< && $(OBJ_INT_EXTRACT) rvds asm_enc_offsets.obj > $@ clean : rm -f vpx.mk $(COBJ) $(AOBJ) $(OBJ_INT_EXTRACT) $(LIBVPX)/asm_*_offsets.asm cd $(LIBWEBP) && wine nmake /f Makefile.vc $(LIBWEBP_ENV) clean realclean : clean rm -f $(LIBVPX)/vpx.vcproj $(LIBVPX)/Makefile cd $(LIBWEBP) && wine nmake /f Makefile.vc /e ARCH=x86 /e CFG=release-static clean cd $(LIBWEBP) && wine nmake /f Makefile.vc /e ARCH=x64 /e CFG=release-static clean vpx.mk : $(LIBVPX)/vpx.vcproj echo VPXSRC=` sed -E -n 's/RelativePath="(.*)"/\1/p' $< | tr '\\\\' / ` > $@ $(LIBVPX)/Makefile : $(LIBVPX)/configure cd $(LIBVPX) && ./configure --target=$(VPXTARGET) \ --enable-runtime-cpu-detect \ --enable-vp8 \ --enable-postproc \ --enable-small \ --disable-examples \ --disable-multithread \ --disable-spatial-resampling \ --disable-unit-tests $(LIBVPX)/vpx.vcproj : $(LIBVPX)/Makefile $(MAKE) -C $(LIBVPX) # --------- libwebp --------- # Use the project's supplied Makefile directly. $(LIBWEBP_LIB) : cd $(LIBWEBP) && wine nmake /f Makefile.vc $(LIBWEBP_ENV) $(LIBWEBP_LIB) # Warning: If you try to build all, Linux/WINE may crash: # "Program Error - The program mt.exe has encountered a serious error..." # So we specify the static library target only, to avoid this.