From fe55d26666ef0b0e5756b87613c9ac9afb994ccf Mon Sep 17 00:00:00 2001
From: jkeil <jkeil@b3059339-0415-0410-9bf9-f77b7e298cf2>
Date: Tue, 14 Aug 2001 18:28:56 +0000
Subject: [PATCH] Use USE_WIN32DLL define instead of ARCH_X86 to decide whether
 or not to compile Win32 DLL code into mplayer.  Default for USE_WIN32DLL is
 enabled on x86 machines, disabled otherwise.

Use of Win32 DLLs can be disabled on x86 using the --disable-win32 configure
option.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1518 b3059339-0415-0410-9bf9-f77b7e298cf2
---
 Makefile    |  9 +++------
 configure   | 40 ++++++++++++++++++++++++++++++----------
 dec_audio.c |  8 ++++----
 dec_video.c | 12 +++++-------
 4 files changed, 42 insertions(+), 27 deletions(-)

diff --git a/Makefile b/Makefile
index 3ce5919566..1bbbe5fedd 100644
--- a/Makefile
+++ b/Makefile
@@ -24,15 +24,12 @@ VO_LIBS = -Llibvo -lvo $(X_LIBS)
 
 PARTS = mp3lib libac3 libmpeg2 opendivx libavcodec encore libvo libao2 drivers drivers/syncfb
 
-ifeq ($(TARGET_ARCH_X86),yes)
+ifneq ($(W32_LIB),)
 PARTS += loader loader/DirectShow
 SRCS += dll_init.c
-LOADER_DEP = loader/libloader.a $(DS_DEP)
-LIB_LOADER = -Lloader -lloader $(DS_LIB)
-else
-LOADER_DEP =
-LIB_LOADER =
 endif
+LOADER_DEP = $(W32_DEP) $(DS_DEP)
+LIB_LOADER = $(W32_LIB) $(DS_LIB)
 
 
 .SUFFIXES: .c .o
diff --git a/configure b/configure
index 118373eddf..e4c1819476 100755
--- a/configure
+++ b/configure
@@ -163,6 +163,7 @@ params:
 	--disable-select        disable audio select() support ( for example required this
 	                        option ALSA or Vortex2 driver )
 
+	--disable-win32         disable Win32 DLL support
 	--disable-dshow         disable DirectShow support (if you don't have
                                 C++ compiler&libs, or you've found dshow codecs
                                 slower than old VfW ones)
@@ -456,8 +457,8 @@ _fbdev=no
 [ "$system_name" = Linux ] && _fbdev=yes
 _lirc=no
 _css=no
-_dshow=yes
-[ "$host_arch" != i386 ] && _dshow=no
+_win32dll=yes _dshow=yes
+[ "$host_arch" != i386 ] && _dshow=no _win32dll=no
 _fastmemcpy=yes
 _streaming=no
 _libavcodec=no
@@ -510,7 +511,7 @@ done
 
 
 _win32libdirnotify=no
-if [ "$host_arch" = i386 ]; then
+if [ $_win32dll = yes ]; then
     if [ -d /usr/lib/win32 ]; then
 	_win32libdir=/usr/lib/win32
     elif [ -d /usr/local/lib/win32 ]; then
@@ -1169,6 +1170,10 @@ for ac_option do
   --disable-select)
         _select='#undef HAVE_AUDIO_SELECT'
 	;;
+  --disable-win32)
+        _win32dll=no
+        _dshow=no # no dshow without win32dlls
+	;;
   --disable-dshow)
         _dshow=no
 	;;
@@ -1408,6 +1413,7 @@ echo "Checking for ESD Audio ... $_esd"
 echo "Checking for Sun Audio ... $_sun_audio"
 echo "Checking for DeCSS support ... $_css"
 echo "Checking for PNG support ... $_png"
+echo "Checking for Win32 DLL support ... $_win32dll"
 echo "Checking for DirectShow ... $_dshow"
 echo "Checking for libavcodec ... $_libavcodec"
 echo "Checking for divx4linux ... $_divx4linux"
@@ -1454,16 +1460,25 @@ else
    _cssinc=''
 fi
 
-if [ $_dshow = yes ]; then
-   _dshowlib='-Lloader/DirectShow -lDS_Filter -lstdc++'
-   _dshowdep='loader/DirectShow/libDS_Filter.a'
-   _dshow='#define USE_DIRECTSHOW'
+
+
+if [ $_win32dll = yes ]; then
+    _win32dll='#define USE_WIN32DLL 1'
+    _win32lib='-Lloader -lloader'
+    _win32dep='loader/libloader.a'
+    if [ $_dshow = yes ]; then
+	_dshow='#define USE_DIRECTSHOW'
+	_dshowlib='-Lloader/DirectShow -lDS_Filter -lstdc++'
+	_dshowdep='loader/DirectShow/libDS_Filter.a'
+    else
+	_dshow='#undef USE_DIRECTSHOW' _dshowlib='' _dshowdep=''
+    fi
 else
-   _dshowlib=''
-   _dshowdep=''
-   _dshow='#undef USE_DIRECTSHOW'
+    _win32dll='#undef USE_WIN32DLL' _win32lib='' _win32dep=''
+    _dshow='#undef USE_DIRECTSHOW' _dshowlib='' _dshowdep=''
 fi
 
+
 if [ $_libavcodec = yes ]; then
    _lavclib='-Llibavcodec -lavcodec'
    _lavcdep='libavcodec/libavcodec.a'
@@ -1844,6 +1859,8 @@ LIRC_LIBS = $_lirclibs
 CSS_LIB = $_csslib
 CSS_INC = $_cssinc
 SDL_INC = $_sdlcflags
+W32_DEP = $_win32dep
+W32_LIB = $_win32lib
 DS_DEP = $_dshowdep
 DS_LIB = $_dshowlib
 AV_DEP = $_lavcdep
@@ -1949,6 +1966,9 @@ $_css
 /* Define this to enable MPEG 1/2 image postprocessing (requires FAST cpu!) */
 #define MPEG12_POSTPROC
 
+/* Win32 DLL support */
+$_win32dll
+
 /* DirectShow support */
 $_dshow
 
diff --git a/dec_audio.c b/dec_audio.c
index 1cc9bd083b..fc90f2ea6c 100644
--- a/dec_audio.c
+++ b/dec_audio.c
@@ -78,8 +78,8 @@ sh_audio->audio_out_minsize=8192;// default size, maybe not enough for Win32/ACM
 
 switch(driver){
 case AFM_ACM:
-#ifndef	ARCH_X86
-  printf("Win32/ACM audio codec unavailable on non-x86 CPU -> force nosound :(\n");
+#ifndef	USE_WIN32DLL
+  printf("Win32/ACM audio codec disabled, or unavailable on non-x86 CPU -> force nosound :(\n");
   driver=0;
 #else
   // Win32 ACM audio codec:
@@ -157,7 +157,7 @@ memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size);
 sh_audio->a_buffer_len=0;
 
 switch(driver){
-#ifdef ARCH_X86
+#ifdef USE_WIN32DLL
 case AFM_ACM: {
     int ret=acm_decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size);
     if(ret<0){
@@ -332,7 +332,7 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
         }
         //printf("{3:%d}",avi_header.idx_pos);fflush(stdout);
         break;
-#ifdef ARCH_X86
+#ifdef USE_WIN32DLL
       case AFM_ACM:
 //        len=sh_audio->audio_out_minsize; // optimal decoded fragment size
 //        if(len<minlen) len=minlen; else
diff --git a/dec_video.c b/dec_video.c
index f365aa70d7..7854dace3a 100644
--- a/dec_video.c
+++ b/dec_video.c
@@ -104,7 +104,6 @@ int get_video_quality_max(sh_video_t *sh_video){
 
 void set_video_quality(sh_video_t *sh_video,int quality){
  switch(sh_video->codec->driver){
-#ifdef ARCH_X86
 #ifdef USE_DIRECTSHOW
   case VFM_DSHOW: {
    if(quality<0 || quality>4) quality=4;
@@ -112,7 +111,6 @@ void set_video_quality(sh_video_t *sh_video,int quality){
   }
   break;
 #endif
-#endif
 #ifdef MPEG12_POSTPROC
   case VFM_MPEG: {
    if(quality<0 || quality>6) quality=6;
@@ -147,7 +145,7 @@ unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx];
 sh_video->our_out_buffer=NULL;
 
 switch(sh_video->codec->driver){
-#ifdef ARCH_X86
+#ifdef USE_WIN32DLL
  case VFM_VFW: {
    if(!init_video_codec(sh_video,0)) {
 //     GUI_MSG( mplUnknowError )
@@ -213,13 +211,13 @@ switch(sh_video->codec->driver){
    break;
 #endif
  }
-#else	/* !ARCH_X86 */
+#else	/* !USE_WIN32DLL */
  case VFM_VFW:
  case VFM_DSHOW:
  case VFM_VFWEX:
-   fprintf(stderr,"MPlayer does not support win32 codecs on non-x86 platforms!\n");
+   fprintf(stderr,"Support for win32 codecs disabled, or unavailable on non-x86 platforms!\n");
    return 0;
-#endif	/* !ARCH_X86 */
+#endif	/* !USE_WIN32DLL */
  case VFM_ODIVX: {  // OpenDivX
    if(verbose) printf("OpenDivX video codec\n");
    { DEC_PARAM dec_param;
@@ -465,7 +463,7 @@ if(verbose>1){
     break;
   }
 #endif
-#ifdef ARCH_X86
+#ifdef USE_WIN32DLL
   case VFM_VFWEX:
   case VFM_VFW:
   {