3 # Common makefile settings for wxWindows programs
4 # This file is included by all the other makefiles, thus changes
5 # made here take effect everywhere (except where overriden).
6 # The settings are for GnuWin32-derived compilers, i.e. Cygwin and Mingw32.
8 # Customize this file to match your own settings.
13 # The MINGW32 and MINGW32VERSION variables are preconfigured for
14 # MinGW gcc version 3.x and must both be changed for any version
15 # earlier than 3.0 or for cygwin. Editing this file is one way to
16 # change them. An easier way, at least with GNU make, is to override
17 # them on the command line, e.g.
18 # make MINGW32=0 MINGW32VERSION=2.8 -f makefile.g95
20 # If using Mingw32 (any version), set this to 1.
21 # If using Cygwin (any version), set this to 0.
23 # This agrees with the instructions given in docs/msw/install.txt .
24 # Earlier versions of this makefile suggested setting MINGW32=1 for
25 # recent versions of cygwin, but that would give the wrong dll entry
26 # point in src/msw/makefile.g95 .
28 # With cygwin, there are still some problems compiling wxWindows
29 # this way; './configure && make' may work better.
33 # set MIN_SUFFIX to nothing if you use only MinGW compiler, set it to
34 # something MinGW-specific if you want to build wxWindows with more than one
42 # Set to your gcc version. Generally 'gcc --version' tells you
43 # which version you have. But it cannot distinguish between
44 # 2.95.2-1 and earlier suffix versions of 2.95 . In that case,
45 # inspect the dates of bin/gcc.exe and bin/ld.exe ; if they
47 # 2000-01-21 for gcc.exe and
48 # 2000-02-04 for ld.exe
49 # then use '2.95-late'.
51 # gcc 2.8.x and earlier require struct-return workaround
54 # gcc 2.95.2 and earlier requires special thunk option
55 #MINGW32VERSION=2.9-early
57 # mingw gcc-2.95.2-1 supports '-shared'
58 # windres provided with gcc-2.95.2-1 supports temp file option
59 #MINGW32VERSION=2.95-late
61 # gcc 3.x provides a win32api.h header
64 # If you want to compile on Wine, simply uncomment this variable
65 # If you don't want to edit the file, you can simply define it
66 # on the command line like so: make WINE=1 -f makefile.g95
69 # Set this if you are using a cross-compiler, i.e. compiling on one system
70 # the program for another one
73 # If we're using MSYS, or other utilities that use forward slashes,
74 # you need to set this when invoking the makefile from DOS, or the
75 # wrong separators will be assumed. However, if you're using MSYS,
76 # you really ought to invoke the makefile from MSYS--or, even better,
77 # use the './configure && make' technique that MSYS is designed for.
84 # If building DLL, the version
85 include $(WXDIR)/src/version.mak
86 WXVERSION=$(wxMAJOR_VERSION)$(wxMINOR_VERSION)$(wxRELEASE_NUMBER_IFUNSTABLE)
100 # Set to the appropriate remove command (must support forward slashes)
101 # You can get a suitable rm.exe from ports/mingw32/extra.zip on the ftp site.
104 # Set to the appropriate copy command (must support forward slashes)
105 # You can get a suitable cp.exe from ports/mingw32/extra.zip on the ftp site.
108 ########################## Compiler ##################################
110 ifneq (,$(findstring $(MINGW32VERSION),2.8))
111 # According to Guillermo Rodriguez Garcia <guille@iies.es>, the
112 # -fno-pcc-struct-return option is needed to make the standard div()
113 # function work - otherwise it returns absolutely incorrect results
114 # which breaks the wxImage class. This was fixed on 1998-08-14 for
115 # mingw and cygwin. It is preferable not to use this option where it
116 # is not required, because it is documented to cause binary API
118 _STRUCT_RETURN_WORKAROUND=-fno-pcc-struct-return
119 # Really old versions of cygwin are thought to require extra headers.
121 GNUWIN32EXTRA=-I$(WXDIR)/include/wx/msw/gnuwin32
125 ifneq (,$(findstring $(MINGW32VERSION),2.8 2.9-early))
126 # Earlier versions of this makefile defined the following macros
127 # explicitly; mingw versions since at least '2.95-late' define
129 OBSOLETE_DEFINES = -D_X86_=1 -DWIN32 -D_WIN32 -D__WIN32__
131 # But cygwin doesn't define them, at least through its version
134 OBSOLETE_DEFINES = -D_X86_=1 -DWIN32 -D_WIN32 -D__WIN32__
137 ifneq (,$(findstring $(MINGW32VERSION),2.8 2.9-early 2.95-late))
138 # Versions prior to 3.0 require -fvtable-thunks for OLE support.
139 # All code must be built with this option, even C++ libraries you
140 # only link to, including system libraries. This option can cause
141 # subtle problems with multiple inheritance.
142 _THUNK_WORKAROUND=-fvtable-thunks
145 ifeq (,$(findstring $(MINGW32VERSION),2.8 2.9-early))
146 # Versions since 2.95.2-1 support '-shared', which makes linking
147 # a dll *much* faster; and the accompanying windres supports
148 # '--use-temp-file', which is more robust.
149 LD_SUPPORTS_SHARED=yes
150 _USE_TEMP_FILE_IF_SUPPORTED=--use-temp-file
151 # Use the WIN32 wxDirDialog only if we have a recent mingw version
155 ifeq (,$(findstring $(MINGW32VERSION),2.8 2.9-early 2.95-late))
156 # Versions since 3.0 provide win32api.h . An old comment said to
157 # define this 'if you have w32api >= 0.5', but mingw 2.95.2-1
158 # has no such header.
160 _USE_W32API_HEADER_IF_SUPPORTED = -DHAVE_W32API_H
163 # Revision 1.70.2.6 of this file suggested '--pipe' for mingw but
164 # not for cygwin, and only for version 3.0 or later. Since then,
165 # the advice given here
166 # http://mail.gnu.org/pipermail/autoconf/2000-July/005479.html
167 # is followed, and '--pipe' is not used unless you specify it on
168 # the make command line, e.g.
169 # make CXXFLAGS=--pipe CFLAGS=--pipe -f makefile.g95
173 # Define the C++ and C compiler respectively
182 # Compiler used for LEX generated C
183 # For now at least, it can be the same as the regular C compiler
184 CCLEX = $(CROSS)$(CC)
186 # This shouldn't be needed as make is supposed to define this
187 # variable itself. Uncomment it if your make complains.
190 # LEX (currently unused)
193 # YACC (currently unused)
197 # Settings for Cyginw/Mingw32
198 # Some versions of windres cannot cope with the --preprocessor
199 # option. Uncomment the RCPREPROCESSOR line below if yours can.
201 RESCOMP=$(CROSS)windres $(_USE_TEMP_FILE_IF_SUPPORTED)
207 RCINCSWITCH=--include-dir
209 # Note that this can cause windres to fail (Win95/98 problem?)
210 # but commenting out RCPREPROCESSOR then does the trick.
211 #RCPREPROCESSOR=--preprocessor "$(CXX) -c -E -xc-header -DRC_INVOKED"
213 # Don't make this too long (e.g. by adding contrib/include/wx) because it will
214 # truncate the command line
215 RESFLAGS=$(RCPREPROCESSOR) $(RCINCSWITCH) $(WXDIR)/include $(RCEXTRAINC) $(RCDEFSWITCH) __WIN32__ $(RCDEFSWITCH) __WIN95__ $(RCDEFSWITCH) __GNUWIN32__
217 # Needed to build a DLL if your linker does not support --shared option.
219 DLLTOOL = $(CROSS)dlltool
221 ########################## Compiler flags #############################
225 UNICODE_OPT = -D_UNICODE -DUNICODE -DwxUSE_UNICODE=1
230 # Miscellaneous compiler options
231 OPTIONS = -DSTRICT $(_USE_W32API_HEADER_IF_SUPPORTED)
233 # Add "-mthreads" if you want to have threads under mingw32
234 # Add "-mno-cygwin" if you want to link with msvcrt.dll in Cywin and Wine
235 # Otherwise, you link against the native runtime (cygwin.dll
236 # or libc). Having the flag in mingw32 does not hurt as you
237 # always link against msvcrt.dll By default it should be on,
238 # to minimize dependencies on Cygwin, and have more correct
239 # filename behaviour in Wine.
240 COMMON_FLAGS = -mno-cygwin # -mthreads
242 # Debugging information
244 DEBUGFLAGS = -g -D__WXDEBUG__
250 # With 3.50, Win95 will use your existing icons to show smaller ones.
251 # With 4.0, you'll have to follow Win95 procedures for icons or you'll get the
252 # default Windows icon.
254 WINVERSION=-DWINVER=0x0350 -D__GNUWIN32__ # Generic WIN32
257 # This means 'enable Windows 95 features' (in wxWindows and in the compiler).
258 WINVERSION=-DWINVER=0x0400 -D__GNUWIN32__
261 # This is never used and should be expunged.
277 ifeq ($(wxUSE_GUI),1)
286 OPT = -O2 -fno-rtti -fno-exceptions
288 OPT = -fno-rtti -fno-exceptions
291 # Options for ar archiver
294 RANLIB = $(CROSS)ranlib
296 # Extra compiler libraries
299 # Compiler or system-specific include paths
302 ########################## Directories ###############################
304 OLELIBS=-lole32 -loleaut32 -luuid
305 BASELIBS=-lstdc++ -lgcc -lodbc32 -lwsock32
306 ifeq ($(wxUSE_GUI),1)
307 WINLIBS= $(BASELIBS) \
308 -lwinspool -lwinmm -lshell32 \
309 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 \
310 -lodbc32 -lwsock32 -lopengl32 -lglu32 $(OLELIBS) # -loldnames
315 #WINLIBS=-lstdc++ -lgcc \
316 # -lwinspool -lwinmm -lshell32 \
317 # -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lwsock32 # -loldnames
319 # Shouldn't need to change these...
320 WXSRC=$(WXDIR)/src/msw
321 WXINC=$(WXDIR)/include
322 WXBASESRC=$(WXDIR)/src/common
325 #INC = -I$(WXINC) -I$(WXDIR)/contrib/include -I$(WXDIR)/src/png -I$(WXDIR)/src/jpeg -I$(WXDIR)/src/zlib -I$(WXDIR)/src/tiff $(EXTRAINC) $(COMPPATHS)
327 INC = -I$(WXDIR)/lib/$(TOOLKIT)$(INCEXT) -I$(WXINC) -I$(WXDIR)/contrib/include -I$(WXDIR)/src/regex -I$(WXDIR)/src/png -I$(WXDIR)/src/jpeg -I$(WXDIR)/src/zlib -I$(WXDIR)/src/tiff $(EXTRAINC) $(COMPPATHS) $(GNUWIN32EXTRA)
330 RCLFLAGS=-cpp "cpp -lang-c++ $(OBSOLETE_DEFINES) -DRCL_INVOKED -I$(WXWIN)/include"
333 # png, jpeg, etc are exported from wx dll, so skip and save on link time.
334 LIBS = $(EXTRALIBS) $(WXLIB) $(WINLIBS) $(COMPLIBS)
336 LIBS = $(EXTRALIBS) $(WXLIB) -lregex$(MIN_SUFFIX) -lpng$(MIN_SUFFIX) -ljpeg$(MIN_SUFFIX) -lzlib$(MIN_SUFFIX) -ltiff$(MIN_SUFFIX) $(WINLIBS) $(COMPLIBS)
339 WINFLAGS = $(OBSOLETE_DEFINES) $(WINVERSION)
346 # Directory for object files (don't change)
347 # OBJDIR = objects$(GUISUFFIX)
362 ifeq ($(WXMAKINGDLL)$(WXUSINGDLL),)
363 INCEXT=$(UNIEXT)$(DEBEXT)
365 INCEXT=dll$(UNIEXT)$(DEBEXT)
368 WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx$(TOOLKIT)$(UNIEXT)$(DEBEXT).$(LIBSUFF)
371 EXTRADLLFLAGS = -DWXMAKINGDLL=1 -D_DLL=1 -D_WINDLL=1
372 WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx$(TOOLKIT)$(WXVERSION)$(UNIEXT)$(DEBEXT)$(MIN_SUFFIX).$(LIBSUFF)
376 EXTRADLLFLAGS = -DWXUSINGDLL=1
377 WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx$(TOOLKIT)$(WXVERSION)$(UNIEXT)$(DEBEXT)$(MIN_SUFFIX).$(LIBSUFF)
381 ifeq ($(wxUSE_GUI),1)
382 WINDOWSLDFLAGS=-Wl,--subsystem,windows
383 WINDOWSLDLIBS=-mwindows
386 # Note: WIN32_LEAN_AND_MEAN is defined only for C and not for C++ compiles.
387 # Defining this macro means that a great deal of less commonly used stuff
388 # is ignored in the windows headers, resulting in faster compiles. It can't
389 # be used with some C++ source files. It just so happens that it can be
390 # used with all C source files.
392 CFLAGS = -DWIN32_LEAN_AND_MEAN
394 WXLIBDIRS = -L$(WXDIR)/lib -L$(WXDIR)/contrib/lib
396 # You shouldn't need to change these flags, which are merely composed of
397 # the options selected above. You can add more flags by specifying them on
398 # the make command line, e.g.
399 # make CXXFLAGS='-O3 -march=i686' -f makefile.g95
400 # The gnu make manual says
401 # 'Users expect to be able to specify CFLAGS freely themselves'
402 # That was unsafe with older versions of this makefile, but now it works.
404 # C preprocessor flags
405 # Some makefiles pass extra flags in $(EXTRACPPFLAGS); although earlier
406 # versions of this file used CPPFLAGS as C++ compiler flags (instead of
407 # as C preprocessor flags), it is OK to add them to the preprocessor
408 # flags, which are always used for C++ compiles. Because other makefiles
409 # use this method to override these flags, they are added after $(CPPFLAGS),
410 # which would normally come last.
411 ALL_CPPFLAGS = $(XINCLUDE) $(INC) $(CPPFLAGS) $(EXTRACPPFLAGS)
412 # C and C++ compiler flags for compatibility with old gcc versions
413 REQUIRED_GCC_FLAGS = $(_STRUCT_RETURN_WORKAROUND) $(_THUNK_WORKAROUND)
415 ALL_CXXFLAGS = $(COMMON_FLAGS) $(REQUIRED_GCC_FLAGS) $(UNICODE_OPT) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CXXFLAGS)
417 ALL_CFLAGS = $(COMMON_FLAGS) $(REQUIRED_GCC_FLAGS) $(UNICODE_OPT) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CFLAGS)
419 ALL_LDFLAGS = $(COMMON_FLAGS) $(WINDOWSLDFLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
420 # under Cygwin, Dlls must not be linked with subsystem=windows
421 ALL_LDFLAGS_DLL = $(COMMON_FLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
423 .SUFFIXES: .rc .$(RESSUFF) .$(RSCSUFF) .cpp .cxx .cc .c
426 $(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
429 $(CXX) -c $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ $*.cc
432 $(CXX) -c $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ $*.cxx
434 # This '.cpp.o' rule is apparently written this way because
435 # the 'tmake' file g95.t expects it.
436 .$(SRCSUFF).$(OBJSUFF):
437 $(CXX) -c $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ $*.$(SRCSUFF)