From 86b049678f42dfa0c5e53375e5ef33a23dc81ea5 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sun, 20 Mar 2005 23:45:17 +0000 Subject: [PATCH] Windows specific configure script and Makefile --- SheepShaver/src/Windows/Makefile.in | 170 ++++++++++++++++++++ SheepShaver/src/Windows/configure.ac | 232 +++++++++++++++++++++++++++ 2 files changed, 402 insertions(+) create mode 100755 SheepShaver/src/Windows/Makefile.in create mode 100755 SheepShaver/src/Windows/configure.ac diff --git a/SheepShaver/src/Windows/Makefile.in b/SheepShaver/src/Windows/Makefile.in new file mode 100755 index 00000000..3b9aa22a --- /dev/null +++ b/SheepShaver/src/Windows/Makefile.in @@ -0,0 +1,170 @@ +# Windows Makefile for SheepShaver + +## System specific configuration +@SET_MAKE@ +SHELL = /bin/sh + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +datadir = @datadir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 + +DESTDIR = + +LN_S = @LN_S@ +CC = @CC@ +CXX = @CXX@ +CFLAGS = @CFLAGS@ +CXXFLAGS = @CXXFLAGS@ +CPPFLAGS = @CPPFLAGS@ -I../include -I. +DEFS = @DEFS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +CPUSRCS = @CPUSRCS@ +PERL = @PERL@ + +USE_DYNGEN = @USE_DYNGEN@ +DYNGENSRCS = @DYNGENSRCS@ +DYNGEN_CC = $(CXX) +DYNGEN_OP_FLAGS = @DYNGEN_OP_FLAGS@ + +HOST_CC = gcc +HOST_CXX = g++ +HOST_CFLAGS = -O2 +HOST_CXXFLAGS = -O2 +HOST_LDFLAGS = + +## Files +UNIXSRCS = vm_alloc.cpp vm_alloc.h sigsegv.cpp sigsegv.h video_vosf.h video_blit.cpp video_blit.h + +SRCS = ../main.cpp main_windows.cpp ../prefs.cpp ../prefs_items.cpp prefs_windows.cpp \ + sys_windows.cpp cdenable/cache.cpp cdenable/eject_nt.cpp cdenable/ntcd.cpp \ + ../rom_patches.cpp ../rsrc_patches.cpp ../emul_op.cpp ../name_registry.cpp \ + ../macos_util.cpp ../timer.cpp timer_windows.cpp ../xpram.cpp xpram_windows.cpp \ + ../adb.cpp ../sony.cpp ../disk.cpp ../cdrom.cpp ../scsi.cpp ../dummy/scsi_dummy.cpp \ + ../gfxaccel.cpp ../video.cpp ../SDL/video_sdl.cpp video_blit.cpp \ + ../audio.cpp ../SDL/audio_sdl.cpp ../ether.cpp ../dummy/ether_dummy.cpp \ + ../thunks.cpp ../serial.cpp ../dummy/serial_dummy.cpp ../extfs.cpp extfs_windows.cpp \ + about_window_windows.cpp ../user_strings.cpp user_strings_windows.cpp \ + ../dummy/prefs_editor_dummy.cpp clip_windows.cpp util_windows.cpp \ + vm_alloc.cpp sigsegv.cpp posix_emu.cpp SheepShaver.rc $(CPUSRCS) +APP = SheepShaver.exe + +## Rules +.PHONY: clean distclean +.SUFFIXES: +.SUFFIXES: .c .cpp .S .o .h + +all: $(APP) + +$(UNIXSRCS): %: ../Unix/% + $(LN_S) $< $@ + +OBJ_DIR = obj +$(OBJ_DIR):: + @[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1 + +define SRCS_LIST_TO_OBJS + $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(SRCS), \ + $(basename $(notdir $(file)))))) +endef +OBJS = $(SRCS_LIST_TO_OBJS) + +define DYNGENSRCS_LIST_TO_OBJS + $(addprefix $(OBJ_DIR)/, $(addsuffix .ho, $(foreach file, $(DYNGENSRCS), \ + $(basename $(notdir $(file)))))) +endef +DYNGENOBJS = $(DYNGENSRCS_LIST_TO_OBJS) + +SRC_PATHS += $(sort $(foreach file, $(SRCS), $(dir $(file)))) +VPATH := +VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SRC_PATHS)))) + +$(APP): $(UNIXSRCS) $(OBJ_DIR) $(OBJS) + $(CXX) -o $(APP) $(LDFLAGS) $(OBJS) $(LIBS) + +clean: + rm -f $(UNIXSRCS) + rm -f $(APP) $(OBJ_DIR)/* core* *.core *~ *.bak ppc-execute-impl.cpp + rm -f dyngen basic-dyngen-ops.hpp ppc-dyngen-ops.hpp + +distclean: clean + rm -rf $(OBJ_DIR) + rm -f Makefile + rm -f config.cache config.log config.status config.h + +depend dep: + makedepend $(CPPFLAGS) -Y. $(SRCS) 2>/dev/null + +$(OBJ_DIR)/%.ho : %.c + $(HOST_CC) $(CPPFLAGS) $(DEFS) $(HOST_CFLAGS) -c $< -o $@ +$(OBJ_DIR)/%.ho : %.cpp + $(HOST_CXX) $(CPPFLAGS) $(DEFS) $(HOST_CXXFLAGS) -c $< -o $@ +$(OBJ_DIR)/%.o : %.c + $(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c $< -o $@ +$(OBJ_DIR)/%.o : %.cpp + $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c $< -o $@ +$(OBJ_DIR)/%.o : %.mm + $(CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -c $< -o $@ +$(OBJ_DIR)/%.o : %.S + $(CPP) $(CPPFLAGS) -D__ASSEMBLY__ $< -o $*.out.s + $(AS) $(ASFLAGS) -o $@ $*.out.s + rm $*.out.s + +# Windows resources +$(OBJ_DIR)/%.o: %.rc + windres --include-dir ../Windows -i $< -o $@ + +# Kheperix CPU emulator +kpxsrcdir = ../kpx_cpu/src +GENEXECPL = $(kpxsrcdir)/cpu/ppc/genexec.pl +DYNGEN = dyngen.exe + +ifeq ($(USE_DYNGEN),yes) +DYNGENDEPS = basic-dyngen-ops.hpp ppc-dyngen-ops.hpp + +$(DYNGEN): $(DYNGENOBJS) + $(CXX) -o $@ $(LDFLAGS) $(DYNGENOBJS) + +$(OBJ_DIR)/basic-dyngen.o: basic-dyngen-ops.hpp +$(OBJ_DIR)/basic-dyngen-ops.o: $(kpxsrcdir)/cpu/jit/basic-dyngen-ops.cpp + $(DYNGEN_CC) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) $(DYNGEN_OP_FLAGS) -c $< -o $@ +basic-dyngen-ops.hpp: $(OBJ_DIR)/basic-dyngen-ops.o $(DYNGEN) + ./$(DYNGEN) -o $@ $< + +$(OBJ_DIR)/ppc-dyngen.o: ppc-dyngen-ops.hpp +$(OBJ_DIR)/ppc-dyngen-ops.o: $(kpxsrcdir)/cpu/ppc/ppc-dyngen-ops.cpp basic-dyngen-ops.hpp + $(DYNGEN_CC) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) $(DYNGEN_OP_FLAGS) -c $< -o $@ +ppc-dyngen-ops.hpp: $(OBJ_DIR)/ppc-dyngen-ops.o $(DYNGEN) + ./$(DYNGEN) -o $@ $< + +$(OBJ_DIR)/sheepshaver_glue.o $(OBJ_DIR)/ppc-cpu.o $(OBJ_DIR)/ppc-decode.o $(OBJ_DIR)/ppc-translate.o: basic-dyngen-ops.hpp ppc-dyngen-ops.hpp +endif + +$(OBJ_DIR)/ppc-execute.o: ppc-execute-impl.cpp +ppc-execute-impl.cpp: $(kpxsrcdir)/cpu/ppc/ppc-decode.cpp $(GENEXECPL) $(DYNGENDEPS) + $(CPP) $(CPPFLAGS) -DGENEXEC $< | $(PERL) $(GENEXECPL) > $@ + +# PowerPC CPU tester +TESTSRCS_ = mathlib/ieeefp.cpp cpu/ppc/ppc-cpu.cpp cpu/ppc/ppc-decode.cpp cpu/ppc/ppc-execute.cpp cpu/ppc/ppc-translate.cpp test/test-powerpc.cpp $(MONSRCS) vm_alloc.cpp +ifeq ($(USE_DYNGEN),yes) +TESTSRCS_ += cpu/jit/jit-cache.cpp cpu/jit/basic-dyngen.cpp cpu/ppc/ppc-dyngen.cpp +endif +TESTSRCS = $(TESTSRCS_:%.cpp=$(kpxsrcdir)/%.cpp) + +define TESTSRCS_LIST_TO_OBJS + $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(TESTSRCS), \ + $(basename $(notdir $(file)))))) +endef +TESTOBJS = $(TESTSRCS_LIST_TO_OBJS) + +$(OBJ_DIR)/test-powerpc.o: $(kpxsrcdir)/test/test-powerpc.cpp + $(HOST_CXX) $(CPPFLAGS) $(DEFS) $(CXXFLAGS) -DEMU_KHEPERIX -c $< -o $@ + +test-powerpc.exe: $(TESTOBJS) + $(HOST_CXX) -o $@ $(LDFLAGS) $(TESTOBJS) -mconsole + +#------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/SheepShaver/src/Windows/configure.ac b/SheepShaver/src/Windows/configure.ac new file mode 100755 index 00000000..ea31efa3 --- /dev/null +++ b/SheepShaver/src/Windows/configure.ac @@ -0,0 +1,232 @@ +dnl Process this file with autoconf to produce a configure script. +dnl Written in 2002 by Christian Bauer + +AC_INIT([SheepShaver], 2.2, [Christian.Bauer@uni-mainz.de], SheepShaver) +AC_CONFIG_SRCDIR(main_windows.cpp) +AC_CONFIG_AUX_DIR(../Unix) +AC_PREREQ(2.52) +AC_CONFIG_HEADER(config.h) + +dnl Canonical system information. +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +dnl Options. +AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes]) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CPP +AC_PROG_CXX +AC_PROG_MAKE_SET +AC_PROG_EGREP +AC_PROG_LN_S +AC_PATH_PROG(PERL, [perl]) + +dnl We use 64-bit file size support if possible. +AC_SYS_LARGEFILE + +dnl Checks for header files. +AC_HEADER_STDC + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_BIGENDIAN +AC_C_CONST +AC_C_INLINE +AC_CHECK_SIZEOF(short, 2) +AC_CHECK_SIZEOF(int, 4) +AC_CHECK_SIZEOF(long, 4) +AC_CHECK_SIZEOF(long long, 8) +AC_CHECK_SIZEOF(float, 4) +AC_CHECK_SIZEOF(double, 8) +AC_CHECK_SIZEOF(void *, 4) +AC_TYPE_OFF_T +AC_TYPE_SIZE_T + +dnl Checks for library functions. +AC_CHECK_FUNCS(exp2f log2f exp2 log2 trunc) + +dnl Define a macro that translates a yesno-variable into a C macro definition +dnl to be put into the config.h file +dnl $1 -- the macro to define +dnl $2 -- the value to translate +dnl $3 -- template name +AC_DEFUN([AC_TRANSLATE_DEFINE], [ + if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then + AC_DEFINE($1, 1, $3) + fi +]) + +dnl Check that VirtualAlloc(), VirtualProtect() work +AC_CACHE_CHECK([whether VirtualProtect works], + ac_cv_VirtualProtect_works, [ + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + ac_cv_VirtualProtect_works=yes + dnl First the tests that should segfault + for test_def in NONE_READ NONE_WRITE READ_WRITE; do + AC_TRY_RUN([ + #define HAVE_WIN32_VM 1 + #define CONFIGURE_TEST_VM_MAP + #define TEST_VM_PROT_$test_def + #include "../Unix/vm_alloc.cpp" + ], ac_cv_VirtualProtect_works=no, rm -f core, + dnl When cross-compiling, assume it works + ac_cv_VirtualProtect_works="yes" + ) + done + AC_TRY_RUN([ + #define HAVE_WIN32_VM 1 + #define CONFIGURE_TEST_VM_MAP + #define TEST_VM_PROT_RDWR_WRITE + #include "../Unix/vm_alloc.cpp" + ], , ac_cv_VirtualProtect_works=no, + dnl When cross-compiling, assume it works + ac_cv_VirtualProtect_works="yes" + ) + AC_LANG_RESTORE + ] +) +if [[ "x$ac_cv_VirtualProtect_works" = "xyes" ]]; then + AC_DEFINE(HAVE_WIN32_VM, 1, [Define if your system has a working Win32-based memory allocator.]) +else + AC_MSG_ERROR([Sorry, Windows VM functions don't work as expected on your system.]) +fi + +dnl Check if Windows exceptions are supported. +AC_CACHE_CHECK([whether your system supports Windows exceptions], + ac_cv_have_win32_exceptions, [ + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_RUN([ + #define HAVE_WIN32_EXCEPTIONS 1 + #define CONFIGURE_TEST_SIGSEGV_RECOVERY + #include "../Unix/vm_alloc.cpp" + #include "../Unix/sigsegv.cpp" + ], + ac_cv_have_win32_exceptions=yes, + ac_cv_have_win32_exceptions=no, + dnl When cross-compiling, assume it works + ac_cv_have_win32_exceptions="yes" + ) + AC_LANG_RESTORE + ] +) +if [[ "x$ac_cv_have_win32_exceptions" = "xyes" ]]; then + AC_DEFINE(HAVE_WIN32_EXCEPTIONS, 1, [Define if your system supports Windows exceptions.]) +else + AC_MSG_ERROR([Sorry, Windows exceptions don't work as expected on your system.]) +fi + +dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler) +AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler], + ac_cv_have_skip_instruction, [ + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_RUN([ + #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1 + #define CONFIGURE_TEST_SIGSEGV_RECOVERY + #include "../Unix/vm_alloc.cpp" + #include "../Unix/sigsegv.cpp" + ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no, + dnl When cross-compiling, do not assume anything. + ac_cv_have_skip_instruction=no + ) + AC_LANG_RESTORE + ] +) +AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction", + [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).]) + +dnl We really want VOSF (Video on SEGV Signals) screen updates acceleration +AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.]) + +dnl Check for GCC 2.7 or higher. +HAVE_GCC27=no +AC_MSG_CHECKING(for GCC 2.7 or higher) +AC_EGREP_CPP(xyes, +[#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5 + xyes +#endif +], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no)) + +dnl Check for GCC 3.0 or higher. +HAVE_GCC30=no +AC_MSG_CHECKING(for GCC 3.0 or higher) +AC_EGREP_CPP(xyes, +[#if __GNUC__ >= 3 + xyes +#endif +], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no)) + +dnl CPU emulator sources +CPUSRCS="\ + ../kpx_cpu/src/mathlib/ieeefp.cpp \ + ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \ + ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \ + ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \ + ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp" +CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src" + +dnl Enable JIT compiler, if possible +USE_DYNGEN="no" +if [[ "x$WANT_JIT" = "xyes" ]]; then + case $host_cpu in + i?86) + DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2" + if [[ "x$HAVE_GCC30" = "xyes" ]]; then + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0" + else + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0" + fi + ;; + esac + USE_DYNGEN="yes" + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000 -g0" + if [[ "x$HAVE_GCC30" = "xyes" ]]; then + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls" + fi + AC_DEFINE(ENABLE_DYNGEN, 1, [Define to enable dyngen engine]) + DYNGENSRCS="\ + ../kpx_cpu/src/cpu/jit/dyngen.c \ + ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp" + CPUSRCS="\ + ../kpx_cpu/src/cpu/jit/jit-cache.cpp \ + ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \ + ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS" + CPPFLAGS="$CPPFLAGS -DUSE_JIT" +fi +CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp" + +dnl We really want SDL for now +AC_PATH_PROG(sdl_config, "sdl-config", [AC_MSG_ERROR([Sorry, you currently need SDL for this port])]) +sdl_cflags=`$sdl_config --cflags` +sdl_libs=`$sdl_config --libs` +CFLAGS="$CFLAGS $sdl_cflags" +CXXFLAGS="$CXXFLAGS $sdl_cflags" +LIBS="$LIBS $sdl_libs" +AC_DEFINE(USE_SDL, 1, [Define to enble SDL support]) +AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support]) +AC_DEFINE(USE_SDL_AUDIO, 1, [Define to enable SDL audio support]) + +dnl Remove the "-g" option if set for GCC. +if [[ "x$HAVE_GCC27" = "xyes" ]]; then + CFLAGS=`echo $CFLAGS | sed -e 's/-g\b//g'` + CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g\b//g'` +fi + +dnl Generate Makefile. +AC_SUBST(PERL) +AC_SUBST(USE_DYNGEN) +AC_SUBST(DYNGENSRCS) +AC_SUBST(DYNGEN_OP_FLAGS) +AC_SUBST(CPUSRCS) +AC_OUTPUT([Makefile]) + +dnl Print summary. +echo +echo SheepShaver configuration summary: +echo +echo Enable JIT compiler .............. : $WANT_JIT +echo +echo "Configuration done. Now type \"make\"."