Skip to content

Commit

Permalink
Initial support for MinGW target
Browse files Browse the repository at this point in the history
  • Loading branch information
dciabrin committed May 28, 2018
1 parent 3aca8c3 commit 1bcd5a2
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 18 deletions.
36 changes: 28 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,11 @@ GN_ARG_ENABLE(wii, [--enable-wii Enable WII build])
GN_ARG_ENABLE(rpi, [--enable-rpi Enable Raspberry Pi build])
GN_ARG_ENABLE(pandora, [--enable-pandora Enable PANDORA build])
GN_ARG_ENABLE(win32, [--enable-win32 Enable WIN32 build])
GN_ARG_ENABLE(mingw, [--enable-mingw Enable MinGW build])
GN_ARG_ENABLE(dingux, [--enable-dingux Enable DINGUX build])
GN_ARG_ENABLE(embedded,[--enable-embedded Enable Embedded directory structure])


# Check for SDL
SDL_VERSION=2.0.0
AM_PATH_SDL2($SDL_VERSION,,AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]))
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"

# Setup platform specific optimisation/source/cflags/libs/etc.
if test "x$enable_gp2x" = xtrue ; then
AC_DEFINE([GP2X],[1],[Define if you build for gp2x])
Expand Down Expand Up @@ -101,12 +96,31 @@ if test "x$enable_win32" = xtrue ; then
AC_DEFINE([WIN32],[1],[Define if you build for win32])
NASMENV="--prefix_"
fi
if test "x$enable_mingw" = xtrue ; then
enable_embedded=true
with_emudbg=no
host=`uname -p`-w64-mingw32
datarootdir="${prefix}"
bindir="${prefix}"
mandir="${prefix}"/doc
CFLAGS="$CFLAGS -I/usr/${host}/include -I/usr/local/${host}/include"
CPPFLAGS="$CPPFLAGS -I/usr/${host}/include -I/usr/local/${host}/include"
LDFLAGS="$LDFLAGS -L/usr/${host}/lib -L/usr/local/${host}/lib"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/${host}/lib/pkgconfig"
AC_DEFINE([MINGW],[1],[Define if you build for MinGW])
fi
if test "x$enable_embedded" = xtrue ; then
AC_DEFINE([EMBEDDED_FS],[1],[Define for embedded directory structure])
fi

# CFLAGS="$CFLAGS -DDATA_DIRECTORY=\"${pkgdatadir}\""

# Check for SDL
SDL_VERSION=2.0.0
AM_PATH_SDL2($SDL_VERSION,,AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]))
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"

# Checks for libraries.
#AC_SUBST(LIBOBJS)
AC_CHECK_LIB([m], [acos])
Expand Down Expand Up @@ -260,6 +274,8 @@ AM_CONDITIONAL(USE_DRZ80,[test x$use_drz80 = xtrue])
AM_CONDITIONAL(USE_GUI,[test x$enable_gui = xtrue])
AM_CONDITIONAL(USE_GP2X,[test x$enable_gp2x = xtrue])
AM_CONDITIONAL(USE_WIZ,[test x$enable_wiz = xtrue])
AM_CONDITIONAL(USE_MINGW,[test x$enable_mingw = xtrue])
AM_CONDITIONAL(USE_GLSL,[test x$ng_cv_use_glsl = xtrue])

# Checks for header files.
AC_HEADER_DIRENT
Expand All @@ -278,8 +294,12 @@ AC_FUNC_VPRINTF
AC_CHECK_FUNCS([atexit floor gettimeofday memset mkdir pow strchr strstr strtoul])

# Checks for emudbg source-level debugging extension
AC_CHECK_HEADERS([emudbg.h])
AC_CHECK_LIB([emudbg], [emudbg_server_loop], [use_emudbg=true])
AC_ARG_WITH([emudbg],
AS_HELP_STRING([--without-emudbg], [Ignore emudbg source-level debugging extension]))
AS_IF([test "x$with_emudbg" != "xno"],[
AC_CHECK_HEADERS([emudbg.h])
AC_CHECK_LIB([emudbg], [emudbg_server_loop], [use_emudbg=true])
])
AM_CONDITIONAL(USE_EMUDBG,[test x$use_emudbg = xtrue])


Expand Down
8 changes: 7 additions & 1 deletion gngeo.dat/Makefile.am
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
dist_pkgdata_DATA = gngeo_data.zip
if USE_MINGW
gngeodir = $(datadir)
else
gngeodir = $(pkgdatadir)
endif

dist_gngeo_DATA = gngeo_data.zip
10 changes: 10 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ if PROCESSOR_ARM
gngeo_SOURCES += video_arm.s memcpy.S
endif

if USE_MINGW
AM_CFLAGS = -Dprintf=gn_log_printf -Dfprintf=gn_log_fprintf
install-exec-local:
for dir in "$(DESTDIR)$(datadir)/conf" \
"$(DESTDIR)$(datadir)/roms" \
"$(DESTDIR)$(datadir)/save" ; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
endif

if USE_GP2X
gngeo_SOURCES += gp2x.h gp2x.c
endif
Expand Down
15 changes: 14 additions & 1 deletion src/blitter/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
noinst_LIBRARIES = libblitter.a
libblitter_a_SOURCES = glproc.h soft.c opengl.c glsl.c # overlay.c
dist_pkgdata_DATA = noop.glsl noop.glslp

if USE_GLSL
if USE_MINGW
shaderdir = $(datadir)/shaders
else
shaderdir = $(pkgdatadir)
endif

dist_shader_DATA = noop.glsl noop.glslp
endif

if USE_MINGW
AM_CFLAGS = -Dprintf=gn_log_printf -Dfprintf=gn_log_fprintf
endif
4 changes: 4 additions & 0 deletions src/effect/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ if HAVE_NASM
libeffect_a_SOURCES += sai.c
endif

if USE_MINGW
AM_CFLAGS = -Dprintf=gn_log_printf -Dfprintf=gn_log_fprintf
endif

2xsaimmx.o effect_i386.o hq2x16.o hq3x16.o: %.o: %.asm
nasm -f elf -I $(srcdir)/ $< -o $@

Expand Down
10 changes: 5 additions & 5 deletions src/generator68k/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in

noinst_PROGRAMS = def68k gen68k
noinst_PROGRAMS = def68k$(EXEEXT) gen68k$(EXEEXT)
BUILT_SOURCES = def68k-iibs.h def68k-funcs.h def68k-proto.h \
cpu68k-0.c cpu68k-1.c cpu68k-2.c cpu68k-3.c \
cpu68k-4.c cpu68k-5.c cpu68k-6.c cpu68k-7.c \
Expand Down Expand Up @@ -29,8 +29,8 @@ gcc_build_verbose = $(gcc_build_verbose_$(V))
gcc_build_verbose_ = $(gcc_build_verbose_$(AM_DEFAULT_VERBOSITY))
gcc_build_verbose_0 = @echo " HCC $@";

def68k-proto.h def68k-funcs.h def68k-iibs.h : def68k def68k.def
$(AM_V_GEN)./def68k 2>&1 >/dev/null
def68k-proto.h def68k-funcs.h def68k-iibs.h : def68k$(EXEEXT) def68k.def
$(AM_V_GEN)./def68k$(EXEEXT) 2>&1 >/dev/null

cpu68k.c : def68k-proto.h

Expand Down Expand Up @@ -93,8 +93,8 @@ CPU_OBJ = cpu68k-0.o cpu68k-1.o cpu68k-2.o cpu68k-3.o \
cpu68k-8.o cpu68k-9.o cpu68k-a.o cpu68k-b.o \
cpu68k-c.o cpu68k-d.o cpu68k-e.o cpu68k-f.o

$(CPU_SOURCE) : gen68k
$(AM_V_GEN)./gen68k 2>&1 >/dev/null
$(CPU_SOURCE) : gen68k$(EXEEXT)
$(AM_V_GEN)./gen68k$(EXEEXT) 2>&1 >/dev/null

$(CPU_OBJ) : %.o : %.c
$(AM_V_CC)$(COMPILE) -c $< -o $@
Expand Down
41 changes: 38 additions & 3 deletions src/gnutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,17 @@ void gn_set_error_msg(char *fmt,...) {
vsnprintf(gnerror,GNERROR_SIZE,fmt,pvar);
}

#if defined(MINGW)
#define GN_DIR_SEP '\\'
#else
#define GN_DIR_SEP '/'
#endif

/*
* replace any ending / with a 0
*/
void gn_rtrim_slash(char *dir) {
if (dir[strlen(dir)-1]=='/' && strlen(dir)!=1)
if (dir[strlen(dir)-1]==GN_DIR_SEP && strlen(dir)!=1)
dir[strlen(dir)-1]=0;
}

Expand All @@ -115,15 +121,44 @@ void gn_strncat_dir(char *basedir,char *dir,size_t n) {
return;
if (strcmp(dir,"..")==0 ) {
if (strlen(basedir)!=1) {
char *slash=strrchr(basedir,'/');
char *slash=strrchr(basedir,GN_DIR_SEP);
if (slash==basedir)
slash[1]=0;
else if (slash!=NULL)
slash[0]=0;
} else
return;
} else {
if (strlen(basedir)!=1) strncat(basedir,"/",n);
if (strlen(basedir)!=1) {
char sep[2];
sep[0]=GN_DIR_SEP; sep[1]=0;
strncat(basedir,sep,n);
}
strncat(basedir,dir,n);
}
}

#if defined(MINGW)
static FILE* logfile;
void gn_log_init(void){
if (!logfile) {
logfile=fopen("gngeo_log.txt","w");
}
}

int gn_log_printf(const char*fmt, ...) {
va_list args;
va_start(args,fmt);
gn_log_init();
vfprintf(logfile,fmt,args);
return 0;
}

int gn_log_fprintf(FILE*f, const char*fmt, ...) {
va_list args;
va_start(args,fmt);
gn_log_init();
vfprintf(logfile,fmt,args);
return 0;
}
#endif
5 changes: 5 additions & 0 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,11 @@ int rom_browser_scanning_anim(void *data) {
}
return 0;
}

#if defined(MINGW)
#define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
#endif

static void free_rom_browser_menu(void);
void init_rom_browser_menu(void);
static int changedir_action(GN_MENU_ITEM *self, void *param) {
Expand Down
4 changes: 4 additions & 0 deletions src/resfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ int res_verify_datafile(char *file) {

if (!file) file=CF_STR(cf_get_item_by_name("datafile"));

#ifdef MINGW
return GN_TRUE;
#else
if (lstat(file,&sb)==-1) {
gn_set_error_msg("%s not found",file);
return GN_FALSE;
Expand All @@ -60,6 +63,7 @@ int res_verify_datafile(char *file) {
if (S_ISREG(sb.st_mode)) return GN_TRUE;
gn_set_error_msg("%s not a valid file",file);
return GN_FALSE;
#endif


}
Expand Down
4 changes: 4 additions & 0 deletions src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,11 @@ void init_sdl(void) {
char *nomouse = getenv("SDL_NOMOUSE");
SDL_Surface *icon;

#ifndef MINGW
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE);
#else
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
#endif

#ifdef GP2X
atexit(gp2x_quit);
Expand Down
2 changes: 2 additions & 0 deletions src/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ PKZIP *gn_open_zip(char *file) {
struct stat sb;
//printf("CWR %s\n",get_current_dir_name());

#ifndef MINGW
if (lstat(file,&sb)==-1) {
printf("Couldn't open %s\n", file);
free(zf);
Expand All @@ -385,6 +386,7 @@ PKZIP *gn_open_zip(char *file) {
free(zf);
return NULL;
}
#endif

zf->file = fopen(file, "rb");
if (zf->file == NULL) {
Expand Down

0 comments on commit 1bcd5a2

Please sign in to comment.