Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow MinGW compilation for Windows to use main buildsys Makefiles
Unconditionally set the WINDOWS symbol, even when using autoconf
Make Windows file handling and dirent.h file handling into alternatives
Add --enable-win configure option. Needs more checking of allowable combinations

Signed-off-by: Peter Denison <angband@marshadder.org>
(cherry picked from commit f4e1503899c36a9027d0484f0f8c0240ea91b3d8)
  • Loading branch information
pnd10 committed Jan 9, 2012
1 parent 75fc2fa commit 4d66f6e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 15 deletions.
22 changes: 22 additions & 0 deletions configure.ac
Expand Up @@ -172,6 +172,10 @@ AC_ARG_ENABLE(sdl,
[AS_HELP_STRING([--enable-sdl], [Enables SDL frontend (default: disabled)])],
[enable_sdl=$enableval],
[enable_sdl=no])
AC_ARG_ENABLE(win,
[AS_HELP_STRING([--enable-win], [Enables Windows frontend (default: disabled)])],
[enable_win=$enableval],
[enable_win=no])
AC_ARG_ENABLE(test,
[AS_HELP_STRING([--enable-test], [Enables test frontend (default: disabled)])],
[enable_test=$enableval],
Expand Down Expand Up @@ -269,6 +273,14 @@ if test "$enable_gtk" = "yes"; then
fi
fi

dnl Windows checking
if test "$enable_win" = "yes"; then
AC_DEFINE(USE_WIN, 1, [Define to 1 if using the Windows interface.])
AC_SUBST(USE_WIN, 1)
CFLAGS="${CFLAGS} -DWINDOWS -static -Iwin/include"
LDFLAGS="${LDFLAGS} -Lwin/lib"
LIBS="${LIBS} -mwindows -lwinmm -lzlib -llibpng -lmsimg32"
fi

dnl SDL mixer checking
if test "$enable_sdl_mixer" = "yes"; then
Expand Down Expand Up @@ -416,6 +428,16 @@ else
echo "- SDL Disabled"
fi

if test "$enable_win" = "yes"; then
if test "$with_sdl" = "no"; then
echo "- Windows No; missing libraries"
else
echo "- Windows Yes"
fi
else
echo "- Windows Disabled"
fi

if test "$enable_test" = "yes"; then
echo "- Test Yes"
else
Expand Down
1 change: 1 addition & 0 deletions mk/extra.mk.in
Expand Up @@ -165,6 +165,7 @@ USE_X11 = @USE_X11@
USE_SDL = @USE_SDL@
SOUND_SDL = @SOUND_SDL@
USE_GTK = @USE_GTK@
USE_WIN = @USE_WIN@
USE_TEST = @USE_TEST@
USE_STATS = @USE_STATS@
DISTCLEAN = doc/manual/manual.pdf
4 changes: 4 additions & 0 deletions src/Makefile
Expand Up @@ -24,6 +24,10 @@ angband: angband.o $(MAINFILES)
$(CC) -o angband angband.o $(MAINFILES) $(LDFLAGS) $(LDADD) $(LIBS)
@printf "%10s %-20s\n" LINK $@

WRES = $(CROSS)windres
win/angband.res: win/angband.rc
$(WRES) $< -O coff -o $@

angband.o: $(OBJECTS)
$(LD) -r -o $@ $(OBJECTS)
@printf "%10s %-20s\n" LINK $@
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.src
Expand Up @@ -82,7 +82,7 @@ ifeq ($(USE_TEST),1)
endif

ifeq ($(USE_WIN),1)
MAINFILES += main-win.o
MAINFILES += win/angband.res main-win.o win/readdib.o win/readpng.o win/scrnshot.o
endif

ifeq ($(USE_OSX),1)
Expand Down
24 changes: 13 additions & 11 deletions src/h-basic.h
Expand Up @@ -11,18 +11,12 @@
#else

/*
* Extract the "WINDOWS" flag from the compiler
* Native MSVC compiler doesn't understand inline or snprintf
*/
# if defined(_Windows) || defined(__WINDOWS__) || \
defined(__WIN32__) || defined(WIN32) || \
defined(__WINNT__) || defined(__NT__)
# ifndef WINDOWS
# define WINDOWS
#ifdef _MSC_VER
# define inline __inline
# define snprintf _snprintf
# endif
# endif

#endif

/* Necessary? */
#ifdef NDS
Expand Down Expand Up @@ -53,8 +47,16 @@

#endif /* HAVE_CONFIG_H */



/*
* Extract the "WINDOWS" flag from the compiler
*/
# if defined(_Windows) || defined(__WINDOWS__) || \
defined(__WIN32__) || defined(WIN32) || \
defined(__WINNT__) || defined(__NT__)
# ifndef WINDOWS
# define WINDOWS
# endif
# endif

/*
* OPTION: set "SET_UID" if the machine is a "multi-user" wmachine.
Expand Down
5 changes: 2 additions & 3 deletions src/z-file.c
Expand Up @@ -821,8 +821,7 @@ void my_dclose(ang_dir *dir)
FREE(dir);
}

#endif /* WINDOWS */

#else /* WINDOWS */

#ifdef HAVE_DIRENT_H

Expand Down Expand Up @@ -904,4 +903,4 @@ void my_dclose(ang_dir *dir)
}

#endif /* HAVE_DIRENT_H */

#endif /* WINDOWS */

0 comments on commit 4d66f6e

Please sign in to comment.