mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-12 16:30:44 +00:00
Enable build of a standalone GUI (first step).
This commit is contained in:
parent
5f3874c853
commit
6994ab671e
@ -35,6 +35,10 @@ SLIRP_CFLAGS = @SLIRP_CFLAGS@
|
||||
SLIRP_SRCS = @SLIRP_SRCS@
|
||||
SLIRP_OBJS = $(SLIRP_SRCS:../slirp/%.c=obj/%.o)
|
||||
|
||||
STANDALONE_GUI = @STANDALONE_GUI@
|
||||
GUI_SRCS = ../prefs.cpp prefs_unix.cpp prefs_editor_gtk.cpp ../prefs_items.cpp \
|
||||
../user_strings.cpp user_strings_unix.cpp xpram_unix.cpp sys_unix.cpp
|
||||
|
||||
## Files
|
||||
SRCS = ../main.cpp main_unix.cpp ../prefs.cpp ../prefs_items.cpp prefs_unix.cpp \
|
||||
sys_unix.cpp ../rom_patches.cpp ../slot_rom.cpp ../rsrc_patches.cpp \
|
||||
@ -47,12 +51,18 @@ SRCS = ../main.cpp main_unix.cpp ../prefs.cpp ../prefs_items.cpp prefs_unix.cpp
|
||||
APP = BasiliskII
|
||||
APP_APP = $(APP).app
|
||||
|
||||
PROGS = $(APP)$(EXEEXT)
|
||||
ifeq ($(STANDALONE_GUI),yes)
|
||||
GUI_APP = BasiliskIIGUI
|
||||
PROGS += $(GUI_APP)$(EXEEXT)
|
||||
endif
|
||||
|
||||
## Rules
|
||||
.PHONY: modules install installdirs uninstall mostlyclean clean distclean depend dep
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .cpp .s .o .h
|
||||
|
||||
all: $(APP)$(EXEEXT)
|
||||
all: $(PROGS)
|
||||
|
||||
OBJ_DIR = obj
|
||||
$(OBJ_DIR)::
|
||||
@ -64,14 +74,23 @@ define SRCS_LIST_TO_OBJS
|
||||
endef
|
||||
OBJS = $(SRCS_LIST_TO_OBJS)
|
||||
|
||||
define GUI_SRCS_LIST_TO_OBJS
|
||||
$(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(GUI_SRCS), \
|
||||
$(basename $(notdir $(file))))))
|
||||
endef
|
||||
GUI_OBJS = $(GUI_SRCS_LIST_TO_OBJS)
|
||||
|
||||
SRC_PATHS += $(sort $(foreach file, $(SRCS), $(dir $(file))))
|
||||
VPATH :=
|
||||
VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SRC_PATHS))))
|
||||
|
||||
$(APP)$(EXEEXT): $(OBJ_DIR) $(OBJS)
|
||||
$(CXX) -o $(APP)$(EXEEXT) $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
$(CXX) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
$(BLESS) $(APP)$(EXEEXT)
|
||||
|
||||
$(GUI_APP)$(EXEEXT): $(OBJ_DIR) $(GUI_OBJS)
|
||||
$(CXX) -o $@ $(LDFLAGS) $(GUI_OBJS) $(LIBS)
|
||||
|
||||
$(APP)_app: $(APP) ../MacOSX/Info.plist ../MacOSX/$(APP).icns
|
||||
mkdir -p $(APP_APP)/Contents
|
||||
cp -f ../MacOSX/Info.plist $(APP_APP)/Contents/
|
||||
@ -85,8 +104,11 @@ $(APP)_app: $(APP) ../MacOSX/Info.plist ../MacOSX/$(APP).icns
|
||||
modules:
|
||||
cd Linux/NetDriver; make
|
||||
|
||||
install: $(APP)$(EXEEXT) installdirs
|
||||
install: $(PROGS) installdirs
|
||||
$(INSTALL_PROGRAM) $(APP)$(EXEEXT) $(DESTDIR)$(bindir)/$(APP)$(EXEEXT)
|
||||
if test -f "$(GUI_APP)$(EXEEXT)"; then \
|
||||
$(INSTALL_PROGRAM) $(GUI_APP)$(EXEEXT) $(DESTDIR)$(bindir)/$(GUI_APP)$(EXEEXT); \
|
||||
fi
|
||||
-$(INSTALL_DATA) $(APP).1 $(DESTDIR)$(man1dir)/$(APP).1
|
||||
$(INSTALL_DATA) $(KEYCODES) $(DESTDIR)$(datadir)/$(APP)/keycodes
|
||||
$(INSTALL_DATA) fbdevices $(DESTDIR)$(datadir)/$(APP)/fbdevices
|
||||
@ -97,6 +119,7 @@ installdirs:
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(bindir)/$(APP)$(EXEEXT)
|
||||
rm -f $(DESTDIR)$(bindir)/$(GUI_APP)$(EXEEXT)
|
||||
rm -f $(DESTDIR)$(man1dir)/$(APP).1
|
||||
rm -f $(DESTDIR)$(datadir)/$(APP)/keycodes
|
||||
rm -f $(DESTDIR)$(datadir)/$(APP)/fbdevices
|
||||
@ -104,7 +127,7 @@ uninstall:
|
||||
rmdir $(DESTDIR)$(datadir)/$(APP)
|
||||
|
||||
mostlyclean:
|
||||
rm -f $(APP)$(EXEEXT) $(OBJ_DIR)/* core* *.core *~ *.bak
|
||||
rm -f $(PROGS) $(OBJ_DIR)/* core* *.core *~ *.bak
|
||||
|
||||
clean: mostlyclean
|
||||
rm -f cpuemu.cpp cpudefs.cpp cputmp*.s cpufast*.s cpustbl.cpp cputbl.h compemu.cpp compstbl.cpp comptbl.h
|
||||
|
@ -14,6 +14,8 @@ dnl Some systems do not put corefiles in the currect directory, avoid saving
|
||||
dnl cores for the configure tests since some are intended to dump core.
|
||||
ulimit -c 0
|
||||
|
||||
AC_ARG_ENABLE(standalone-gui,[ --enable-standalone-gui enable a standalone GUI prefs editor [default=no]], [WANT_STANDALONE_GUI=$enableval], [WANT_STANDALONE_GUI=no])
|
||||
|
||||
dnl Video options.
|
||||
AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes])
|
||||
AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=yes]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=yes])
|
||||
@ -292,6 +294,19 @@ if [[ "x$WANT_GTK" = "xgtk" ]]; then
|
||||
])
|
||||
fi
|
||||
|
||||
dnl Enable standalone GUI?
|
||||
if [[ "$WANT_STANDALONE_GUI" != "yes" ]]; then
|
||||
WANT_STANDALONE_GUI=no
|
||||
fi
|
||||
if [[ "$WANT_GTK" = "no" ]]; then
|
||||
WANT_STANDALONE_GUI=no
|
||||
fi
|
||||
if [[ "$WANT_STANDALONE_GUI" = "yes" ]]; then
|
||||
UISRCS=""
|
||||
AC_DEFINE(STANDALONE_GUI, 1, [Define to use build a standalone GUI prefs editor.])
|
||||
fi
|
||||
AC_SUBST(STANDALONE_GUI, [$WANT_STANDALONE_GUI])
|
||||
|
||||
dnl We use ESD if possible.
|
||||
if [[ "x$WANT_ESD" = "xyes" ]]; then
|
||||
AM_PATH_ESD(0.2.8, [
|
||||
|
@ -508,10 +508,12 @@ int main(int argc, char **argv)
|
||||
// Init system routines
|
||||
SysInit();
|
||||
|
||||
#ifndef STANDALONE_GUI
|
||||
// Show preferences editor
|
||||
if (!PrefsFindBool("nogui"))
|
||||
if (!PrefsEditor())
|
||||
QuitEmulator();
|
||||
#endif
|
||||
|
||||
// Install the handler for SIGSEGV
|
||||
if (!sigsegv_install_handler(sigsegv_handler)) {
|
||||
|
@ -1521,3 +1521,110 @@ static void read_settings(void)
|
||||
read_memory_settings();
|
||||
read_jit_settings();
|
||||
}
|
||||
|
||||
|
||||
#ifdef STANDALONE_GUI
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
* Fake unused data and functions
|
||||
*/
|
||||
|
||||
uint8 XPRAM[XPRAM_SIZE];
|
||||
void MountVolume(void *fh) { }
|
||||
void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { }
|
||||
void WarningAlert(const char *text) { }
|
||||
|
||||
|
||||
/*
|
||||
* Display alert
|
||||
*/
|
||||
|
||||
static void dl_destroyed(void)
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
static void display_alert(int title_id, int prefix_id, int button_id, const char *text)
|
||||
{
|
||||
char str[256];
|
||||
sprintf(str, GetString(prefix_id), text);
|
||||
|
||||
GtkWidget *dialog = gtk_dialog_new();
|
||||
gtk_window_set_title(GTK_WINDOW(dialog), GetString(title_id));
|
||||
gtk_container_border_width(GTK_CONTAINER(dialog), 5);
|
||||
gtk_widget_set_uposition(GTK_WIDGET(dialog), 100, 150);
|
||||
gtk_signal_connect(GTK_OBJECT(dialog), "destroy", GTK_SIGNAL_FUNC(dl_destroyed), NULL);
|
||||
|
||||
GtkWidget *label = gtk_label_new(str);
|
||||
gtk_widget_show(label);
|
||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0);
|
||||
|
||||
GtkWidget *button = gtk_button_new_with_label(GetString(button_id));
|
||||
gtk_widget_show(button);
|
||||
gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(dl_quit), GTK_OBJECT(dialog));
|
||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, FALSE, FALSE, 0);
|
||||
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default(button);
|
||||
gtk_widget_show(dialog);
|
||||
|
||||
gtk_main();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Display error alert
|
||||
*/
|
||||
|
||||
static void ErrorAlert(const char *text)
|
||||
{
|
||||
display_alert(STR_ERROR_ALERT_TITLE, STR_GUI_ERROR_PREFIX, STR_QUIT_BUTTON, text);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Start standalone GUI
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef HAVE_GNOMEUI
|
||||
// Init GNOME/GTK
|
||||
char version[16];
|
||||
sprintf(version, "%d.%d", VERSION_MAJOR, VERSION_MINOR);
|
||||
gnome_init("Basilisk II", version, argc, argv);
|
||||
#else
|
||||
// Init GTK
|
||||
gtk_set_locale();
|
||||
gtk_init(&argc, &argv);
|
||||
#endif
|
||||
|
||||
// Read preferences
|
||||
PrefsInit(argc, argv);
|
||||
|
||||
// Show preferences editor
|
||||
bool start = PrefsEditor();
|
||||
|
||||
// Exit preferences
|
||||
PrefsExit();
|
||||
|
||||
// Transfer control to the executable
|
||||
if (start) {
|
||||
char b2_path[PATH_MAX];
|
||||
strcpy(b2_path, argv[0]);
|
||||
char *p = strrchr(b2_path, '/');
|
||||
p = p ? p + 1 : b2_path;
|
||||
*p = '\0';
|
||||
strcat(b2_path, "BasiliskII");
|
||||
argv[0] = b2_path;
|
||||
execv(b2_path, argv);
|
||||
|
||||
char str[256];
|
||||
sprintf(str, GetString(STR_NO_B2_EXE_FOUND), b2_path, strerror(errno));
|
||||
ErrorAlert(str);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -86,6 +86,8 @@ user_string_def platform_strings[] = {
|
||||
|
||||
{STR_WINDOW_TITLE_GRABBED, "Basilisk II (mouse grabbed, press Ctrl-F5 to release)"},
|
||||
|
||||
{STR_NO_B2_EXE_FOUND, "Could not start %s (%s)."},
|
||||
|
||||
{-1, NULL} // End marker
|
||||
};
|
||||
|
||||
|
@ -75,7 +75,9 @@ enum {
|
||||
|
||||
STR_IGNORESEGV_CTRL,
|
||||
|
||||
STR_WINDOW_TITLE_GRABBED
|
||||
STR_WINDOW_TITLE_GRABBED,
|
||||
|
||||
STR_NO_B2_EXE_FOUND
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user