Permalink
Browse files

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...
1 parent 75fc2fa commit 4d66f6e535ec509bde0857540ff400f6c407ed79 @pnd10 pnd10 committed Jan 1, 2012
Showing with 43 additions and 15 deletions.
  1. +22 −0 configure.ac
  2. +1 −0 mk/extra.mk.in
  3. +4 −0 src/Makefile
  4. +1 −1 src/Makefile.src
  5. +13 −11 src/h-basic.h
  6. +2 −3 src/z-file.c
View
22 configure.ac
@@ -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],
@@ -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
@@ -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
View
1 mk/extra.mk.in
@@ -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
View
4 src/Makefile
@@ -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 $@
View
2 src/Makefile.src
@@ -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)
View
24 src/h-basic.h
@@ -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
@@ -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.
View
5 src/z-file.c
@@ -821,8 +821,7 @@ void my_dclose(ang_dir *dir)
FREE(dir);
}
-#endif /* WINDOWS */
-
+#else /* WINDOWS */
#ifdef HAVE_DIRENT_H
@@ -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.