# gcc 3.x provides a win32api.h header
MINGW32VERSION=3.0
+# If you want to compile on Wine, simply uncomment this variable
+# If you don't want to edit the file, you can simply define it
+# on the command line like so: make WINE=1 -f makefile.g95
+#WINE=1
+
# If we're using MSYS, or other utilities that use forward slashes,
# you need to set this when invoking the makefile from DOS, or the
# wrong separators will be assumed. However, if you're using MSYS,
# you really ought to invoke the makefile from MSYS--or, even better,
# use the './configure && make' technique that MSYS is designed for.
+ifndef WINE
#OSTYPE=msys
+else
+OSTYPE=msys
+endif
# If building DLL, the version
WXVERSION=250
# Versions since 3.0 provide win32api.h . An old comment said to
# define this 'if you have w32api >= 0.5', but mingw 2.95.2-1
# has no such header.
+ifndef WINE
_USE_W32API_HEADER_IF_SUPPORTED = -DHAVE_W32API_H
+endif
#
# Revision 1.70.2.6 of this file suggested '--pipe' for mingw but
# not for cygwin, and only for version 3.0 or later. Since then,
#
endif
-# C compiler
+# Define the C++ and C compiler respectively
+ifndef WINE
CXX = g++
-
-# C compiler
CC = gcc
+else
+CXX = wineg++
+CC = winegcc
+endif
# Compiler used for LEX generated C
# For now at least, it can be the same as the regular C compiler
# Settings for Cyginw/Mingw32
# Some versions of windres cannot cope with the --preprocessor
# option. Uncomment the RCPREPROCESSOR line below if yours can.
+ifndef WINE
RESCOMP=windres $(_USE_TEMP_FILE_IF_SUPPORTED)
+else
+RESCOMP=wrc
+endif
RCINPUTSWITCH=-i
RCOUTPUTSWITCH=-o
RCINCSWITCH=--include-dir
########################## Compiler flags #############################
+# Unicode defines
+ifeq ($(UNICODE),1)
+ UNICODE_OPT = -D_UNICODE -DUNICODE -DwxUSE_UNICODE=1
+else
+ UNICODE_OPT =
+endif
+
# Miscellaneous compiler options
OPTIONS = -DSTRICT $(_USE_W32API_HEADER_IF_SUPPORTED)
# Add "-mthreads" if you want to have threads under mingw32
-COMMON_THREADFLAGS =
+# Add "-mno-cygwin" if you want to link with msvcrt.dll in Cywin and Wine
+# Otherwise, you link against the native runtime (cygwin.dll or libc)
+# Having the flag in mingw32 does not hurt as you always link against msvcrt.dll
+# By default it should be on, to minimize dependencies on Cygwin, and
+# have more correct filename behaviour in Wine.
+COMMON_FLAGS = -mno-cygwin # -mthreads
# Debugging information
ifeq ($(FINAL),0)
# C and C++ compiler flags for compatibility with old gcc versions
REQUIRED_GCC_FLAGS = $(_STRUCT_RETURN_WORKAROUND) $(_THUNK_WORKAROUND)
# C++ compiler flags
-ALL_CXXFLAGS = $(COMMON_THREADFLAGS) $(REQUIRED_GCC_FLAGS) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CXXFLAGS)
+ALL_CXXFLAGS = $(COMMON_FLAGS) $(REQUIRED_GCC_FLAGS) $(UNICODE_OPT) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CXXFLAGS)
# C compiler flags
-ALL_CFLAGS = $(COMMON_THREADFLAGS) $(REQUIRED_GCC_FLAGS) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CFLAGS)
+ALL_CFLAGS = $(COMMON_FLAGS) $(REQUIRED_GCC_FLAGS) $(UNICODE_OPT) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CFLAGS)
# Linker flags
-ALL_LDFLAGS = $(COMMON_THREADFLAGS) $(WINDOWSLDFLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
+ALL_LDFLAGS = $(COMMON_FLAGS) $(WINDOWSLDFLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
# under Cygwin, Dlls must not be linked with subsystem=windows
-ALL_LDFLAGS_DLL = $(COMMON_THREADFLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
+ALL_LDFLAGS_DLL = $(COMMON_FLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
.SUFFIXES: .rc .$(RESSUFF) .$(RSCSUFF) .cpp .cxx .cc .c