diff --git a/Makefile b/Makefile index bf173a4967..dd30da2245 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ include config.mk TARGET = ssnes tools/ssnes-joyconfig -OBJ = ssnes.o file.o driver.o conf/config_file.o settings.o dynamic.o +OBJ = ssnes.o file.o driver.o settings.o dynamic.o JOYCONFIG_OBJ = tools/ssnes-joyconfig.o conf/config_file.o HEADERS = $(wildcard */*.h) $(wildcard *.h) @@ -14,6 +14,10 @@ ifeq ($(HAVE_SRC), 1) DEFINES += $(SRC_CFLAGS) endif +ifeq ($(HAVE_CONFIGFILE), 1) + OBJ += conf/config_file.o +endif + ifeq ($(HAVE_RSOUND), 1) OBJ += audio/rsound.o LIBS += -lrsound diff --git a/general.h b/general.h index 6e9f28250a..828b321bcf 100644 --- a/general.h +++ b/general.h @@ -107,7 +107,9 @@ struct global char bsx_rom_path[256]; char sufami_rom_path[2][256]; +#ifdef HAVE_CONFIGFILE char config_path[256]; +#endif char basename[256]; char savefile_name_srm[256]; diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 9e910d9cc2..12d9ce462b 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -3,6 +3,12 @@ check_switch_c C99 -std=gnu99 check_critical C99 "Cannot find C99 compatible compiler." +if [ "$HAVE_DYNAMIC" = "yes" ] && [ "$HAVE_CONFIGFILE" = "no" ]; then + echo "Cannot have dynamic loading of libsnes and no configfile support." + echo "Dynamic loading requires config file support." + exit 1 +fi + if [ $HAVE_DYNAMIC != yes ]; then check_lib_cxx SNES $LIBSNES snes_init -ldl check_critical SNES "Cannot find libsnes." @@ -38,7 +44,7 @@ check_critical SRC "Cannot find libsamplerate." check_lib DYNAMIC -ldl dlopen # Creates config.mk and config.h. -VARS="ALSA OSS AL RSOUND ROAR JACK SDL FILTER CG XML DYNAMIC FFMPEG AVCODEC AVFORMAT AVCORE AVUTIL SWSCALE SRC" +VARS="ALSA OSS AL RSOUND ROAR JACK SDL FILTER CG XML DYNAMIC FFMPEG AVCODEC AVFORMAT AVCORE AVUTIL SWSCALE SRC CONFIGFILE" create_config_make config.mk $VARS create_config_header config.h $VARS diff --git a/qb/config.params.sh b/qb/config.params.sh index 20d930236f..e49d11d877 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -11,6 +11,7 @@ add_command_line_enable DYNAMIC "Enable dynamic loading of libsnes library." no add_command_line_string LIBSNES "libsnes library used" "-lsnes" add_command_line_enable FFMPEG "Enable FFmpeg recording support" auto add_command_line_enable FILTER "Disable CPU filter support" yes +add_command_line_enable CONFIGFILE "Disable support for config file" yes add_command_line_enable CG "Enable Cg shader support" auto add_command_line_enable XML "Enable bSNES-style XML shader support" auto add_command_line_enable ALSA "Enable ALSA support" auto diff --git a/settings.c b/settings.c index 275fc43068..08fd588cbb 100644 --- a/settings.c +++ b/settings.c @@ -125,9 +125,23 @@ static void set_defaults(void) g_settings.input.joypad_map[i] = SSNES_NO_JOYPAD; } +#ifdef HAVE_CONFIGFILE +static void parse_config_file(void); +#endif + void parse_config(void) { memset(&g_settings, 0, sizeof(struct settings)); + set_defaults(); + +#ifdef HAVE_CONFIGFILE + parse_config_file(); +#endif +} + +#ifdef HAVE_CONFIGFILE +static void parse_config_file(void) +{ config_file_t *conf = NULL; if (strlen(g_extern.config_path) > 0) @@ -167,7 +181,6 @@ void parse_config(void) #endif } - set_defaults(); if (conf == NULL) return; @@ -328,6 +341,7 @@ void parse_config(void) config_file_free(conf); } +#endif struct bind_map { diff --git a/ssnes.c b/ssnes.c index b05ae6ed74..f01fcbfa7a 100644 --- a/ssnes.c +++ b/ssnes.c @@ -246,7 +246,9 @@ static void print_help(void) puts("\t-h/--help: Show this help message"); puts("\t-s/--save: Path for save file (*.srm). Required when rom is input from stdin"); puts("\t-S/--savestate: Path to use for save states. If not selected, *.state will be assumed."); +#ifdef HAVE_CONFIGFILE puts("\t-c/--config: Path for config file." SSNES_DEFAULT_CONF_PATH_STR); +#endif puts("\t-g/--gameboy: Path to Gameboy ROM. Load SuperGameBoy as the regular rom."); puts("\t-b/--bsx: Path to BSX rom. Load BSX BIOS as the regular rom."); puts("\t-B/--bsxslot: Path to BSX slotted rom. Load BSX BIOS as the regular rom."); @@ -281,7 +283,9 @@ static void parse_input(int argc, char *argv[]) #endif { "verbose", 0, NULL, 'v' }, { "gameboy", 1, NULL, 'g' }, +#ifdef HAVE_CONFIGFILE { "config", 0, NULL, 'c' }, +#endif { "mouse", 1, NULL, 'm' }, { "scope", 0, NULL, 'p' }, { "savestate", 1, NULL, 'S' }, @@ -303,7 +307,13 @@ static void parse_input(int argc, char *argv[]) #define FFMPEG_RECORD_ARG #endif - char optstring[] = "hs:vc:S:m:p4jJg:b:B:Y:Z:" FFMPEG_RECORD_ARG; +#ifdef HAVE_CONFIGFILE +#define CONFIG_FILE_ARG "c:" +#else +#define CONFIG_FILE_ARG +#endif + + char optstring[] = "hs:vS:m:p4jJg:b:B:Y:Z:" FFMPEG_RECORD_ARG CONFIG_FILE_ARG; for(;;) { int c = getopt_long(argc, argv, optstring, opts, &option_index); @@ -382,9 +392,11 @@ static void parse_input(int argc, char *argv[]) g_extern.has_scope[1] = true; break; +#ifdef HAVE_CONFIGFILE case 'c': strncpy(g_extern.config_path, optarg, sizeof(g_extern.config_path) - 1); break; +#endif #ifdef HAVE_FFMPEG case 'r':