From b3de60dd454564ed62822f880183175c5baa8445 Mon Sep 17 00:00:00 2001
From: soules <soules@users.sf.net>
Date: Fri, 28 Jul 2006 15:35:22 +0000
Subject: [PATCH] - checkpoint of getting SDL build working with scons

[[Split portion of a mixed commit.]]
---
 SConscript            | 104 +++++++++++++++++++++++++++---------------
 driver.h              |   2 -
 drivers/pc/SConscript |  11 +++--
 fceu.h                |   7 +--
 general.cpp           |  27 +++++------
 input/SConscript      |   2 +-
 mappers/SConscript    |   2 +-
 7 files changed, 90 insertions(+), 65 deletions(-)

diff --git a/SConscript b/SConscript
index b011e7df..e09752df 100644
--- a/SConscript
+++ b/SConscript
@@ -26,7 +26,7 @@ vsuni.cpp
 wave.cpp
 x6502.cpp
 movie.cpp
-unzip.cpp""")
+unzip.c""")
 
 boards_file_list = Split("""
 01-222.cpp
@@ -82,9 +82,10 @@ super24.cpp
 supervision.cpp
 t-262.cpp
 tengen.cpp
-mapinc.h
-mmc3.h
 """)
+#mapinc.h
+#mmc3.h
+
 
 for x in range(len(boards_file_list)):
   boards_file_list[x] = 'boards/' + boards_file_list[x]
@@ -107,7 +108,6 @@ arkanoid.cpp
 bworld.cpp
 cursor.cpp
 fkb.cpp
-fkb.h
 ftrainer.cpp
 hypershot.cpp
 mahjong.cpp
@@ -116,12 +116,15 @@ oekakids.cpp
 powerpad.cpp
 quiz.cpp
 shadow.cpp
-share.h
 suborkb.cpp
-suborkb.h
 toprider.cpp
 zapper.cpp
 """)
+# fkb.h
+# share.h
+# suborkb.h
+
+
 for x in range(len(input_file_list)):
   input_file_list[x] = 'input/' + input_file_list[x]
   
@@ -200,77 +203,81 @@ __226.cpp
 97.cpp
 99.cpp
 emu2413.c
-emu2413.h
-emutypes.h
-mapinc.h
 mmc2and4.cpp
 simple.cpp
-vrc7tone.h
 """)
+# emu2413.h
+# emutypes.h
+# mapinc.h
+# vrc7tone.h
+
 for x in range(len(mappers_file_list)):
   mappers_file_list[x] = 'mappers/' + mappers_file_list[x]
   
 palettes_file_list = Split("""
 conv.c
-palettes.h
-rp2c04001.h 
-rp2c04002.h 
-rp2c04003.h
-rp2c05004.h
 """)
+# palettes.h
+# rp2c04001.h 
+# rp2c04002.h 
+# rp2c04003.h
+# rp2c05004.h
+
 for x in range(len(palettes_file_list)):
   palettes_file_list[x] = 'palettes/' + palettes_file_list[x]
   
 common_file_list = Split("""
 args.cpp
-args.h
 cheat.cpp
-cheat.h
 config.cpp
-config.h
 hq2x.cpp
-hq2x.h
 hq3x.cpp
-hq3x.h
 scale2x.cpp
-scale2x.h
 scale3x.cpp
-scale3x.h
 scalebit.cpp
-scalebit.h
 vidblit.cpp
-vidblit.h
 """)
+# args.h
+# cheat.h
+# vidblit.h
+# scalebit.h
+# scale3x.h
+# scale2x.h
+# config.h
+# hq2x.h
+# hq3x.h
 
 for x in range(len(common_file_list)):
   common_file_list[x] = 'drivers/common/' + common_file_list[x]
   
 pc_file_list = Split("""
-dface.h
 input.cpp
-input.h
-keyscan.h
 main.cpp
-main.h
 sdl.cpp
-sdl.h
-sdl-icon.h
 sdl-joystick.cpp
 sdl-netplay.cpp
-sdl-netplay.h
 sdl-opengl.cpp
-sdl-opengl.h
 sdl-sound.cpp
 sdl-throttle.cpp
 sdl-video.cpp
-sdl-video.h
 throttle.cpp
-throttle.h
 unix-netplay.cpp
-unix-netplay.h
-usage.h
 """)
 
+# main.h
+# dface.h
+# input.h
+# keyscan.h
+# sdl.h
+# sdl-icon.h
+# sdl-netplay.h
+# sdl-opengl.h
+# sdl-video.h
+# throttle.h
+# unix-netplay.h
+# usage.h
+
+
 for x in range(len(pc_file_list)):
   pc_file_list[x] = 'drivers/pc/' + pc_file_list[x]
 
@@ -287,5 +294,26 @@ drivers/pc/SConscript
 """))
 
 Import('file_list')
-env = Environment()
-env.Program('fceu', file_list, LIBS='SDL', LIBPATH='.')
+
+# XXX path separator fixed right now
+opts = Options()
+opts.Add('PSS_STYLE', 'Path separator style', 1)
+opts.Add('LSB_FIRST', 'Least significant byte first?', 1)
+
+env = Environment(options = opts,
+                  CPPDEFINES={'PSS_STYLE' : '${PSS_STYLE}',
+                              'LSB_FIRST' : '${LSB_FIRST}'})
+
+# use sdl-config to get the cflags and libpath
+import os;
+sdl_cflags = os.popen("sdl-config --cflags");
+CCFLAGS = sdl_cflags.read();
+CCFLAGS = CCFLAGS.rstrip(os.linesep);
+sdl_cflags.close();
+
+sdl_libflags = os.popen("sdl-config --libs");
+LINKFLAGS = sdl_libflags.read();
+LINKFLAGS = LINKFLAGS.rstrip(os.linesep);
+sdl_libflags.close();
+
+env.Program('fceu', file_list, CCFLAGS=CCFLAGS, LIBPATH=LINKFLAGS)
diff --git a/driver.h b/driver.h
index d1034b73..e59556d6 100644
--- a/driver.h
+++ b/driver.h
@@ -24,7 +24,6 @@ void FCEUD_GetPalette(uint8 i,uint8 *r, uint8 *g, uint8 *b);
 void FCEUD_PrintError(char *s);
 void FCEUD_Message(char *s);
 
-#ifdef NETWORK
 /* Network interface */
 
 /* Call only when a game is loaded. */
@@ -52,7 +51,6 @@ void FCEUI_NetplayText(uint8 *text);
    side.
 */
 void FCEUD_NetworkClose(void);
-#endif
 
 int FCEUI_BeginWaveRecord(char *fn);
 int FCEUI_EndWaveRecord(void);
diff --git a/drivers/pc/SConscript b/drivers/pc/SConscript
index 3288fadd..6bec97de 100644
--- a/drivers/pc/SConscript
+++ b/drivers/pc/SConscript
@@ -10,20 +10,21 @@ sdl.cpp
 sdl.h
 sdl-icon.h
 sdl-joystick.cpp
-sdl-netplay.cpp
-sdl-netplay.h
-sdl-opengl.cpp
-sdl-opengl.h
 sdl-sound.cpp
 sdl-throttle.cpp
 sdl-video.cpp
 sdl-video.h
-throttle.cpp
 throttle.h
 unix-netplay.cpp
 unix-netplay.h
 usage.h
 """)
+
+# XXX need to deal with opengl configuration and testing at some point
+#sdl-opengl.cpp
+#sdl-opengl.h
+
+
 for x in range(len(my_list)):
   my_list[x] = 'drivers/pc/' + my_list[x]
 file_list = my_list + file_list
diff --git a/fceu.h b/fceu.h
index e241f038..3061d6d5 100644
--- a/fceu.h
+++ b/fceu.h
@@ -41,13 +41,10 @@ extern uint8 MMC5HackSPScroll;
 extern uint8 MMC5HackSPPage;
 
 #ifdef _USE_SHARED_MEMORY_
+extern  uint32 *BotInput;
+#endif
 extern  uint8  *RAM;            //shared memory modifications
 extern  uint8  *GameMemBlock;   //shared memory modifications
-extern  uint32 *BotInput;
-#else
-extern uint8 RAM[0x800];
-extern uint8 GameMemBlock[131072];
-#endif
 
 extern readfunc ARead[0x10000];
 extern writefunc BWrite[0x10000];
diff --git a/general.cpp b/general.cpp
index 7cb93bfb..1a8c9dc3 100644
--- a/general.cpp
+++ b/general.cpp
@@ -67,20 +67,21 @@ if(which < FCEUIOD__COUNT)
  }
 }
 
-#ifndef HAVE_ASPRINTF
-static int asprintf(char **strp, const char *fmt, ...)
-{
- va_list ap;
- int ret;
+// XXX commented out for now... Linux has asprintf()
+// #ifndef HAVE_ASPRINTF
+// static int asprintf(char **strp, const char *fmt, ...)
+// {
+//  va_list ap;
+//  int ret;
 
- va_start(ap,fmt);
- if(!(*strp=(char*)malloc(2048))) //mbg merge 7/17/06 cast to char*
-  return(0);
- ret=vsnprintf(*strp,2048,fmt,ap);
- va_end(ap);
- return(ret);
-}
-#endif
+//  va_start(ap,fmt);
+//  if(!(*strp=(char*)malloc(2048))) //mbg merge 7/17/06 cast to char*
+//   return(0);
+//  ret=vsnprintf(*strp,2048,fmt,ap);
+//  va_end(ap);
+//  return(ret);
+// }
+// #endif
 
 char* FCEU_GetPath(int type)
 {
diff --git a/input/SConscript b/input/SConscript
index 6fe1f743..992a82cf 100644
--- a/input/SConscript
+++ b/input/SConscript
@@ -20,6 +20,6 @@ toprider.cpp
 zapper.cpp
 """)
 for x in range(len(my_list)):
-  my_list[x] = 'input' + my_list[x]
+  my_list[x] = 'input/' + my_list[x]
 file_list = my_list + file_list
 Export('file_list')
diff --git a/mappers/SConscript b/mappers/SConscript
index d4f223b7..f35f3e7b 100644
--- a/mappers/SConscript
+++ b/mappers/SConscript
@@ -82,6 +82,6 @@ simple.cpp
 vrc7tone.h
 """)
 for x in range(len(my_list)):
-  my_list[x] = 'mappers' + my_list[x]
+  my_list[x] = 'mappers/' + my_list[x]
 file_list = my_list + file_list
 Export('file_list')