]> git.saurik.com Git - wxWidgets.git/blame - src/makeg95.env
fix memory leak (coverity checker CID 53)
[wxWidgets.git] / src / makeg95.env
CommitLineData
75515c52 1#
2bda0e17
KB
2# makeg95.env
3# Common makefile settings for wxWindows programs
014e19de 4# This file is included by all the other makefiles, thus changes
2bda0e17 5# made here take effect everywhere (except where overriden).
f3ef286f 6# The settings are for GnuWin32-derived compilers, i.e. Cygwin and Mingw32.
2bda0e17 7#
102f951d
GRG
8# Customize this file to match your own settings.
9#
75515c52
GRG
10# CVS_ID: $Id$
11#
f3ef286f 12
78e376b5
MB
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
19
20# If using Mingw32 (any version), set this to 1.
21# If using Cygwin (any version), set this to 0.
22#
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 .
27#
28# With cygwin, there are still some problems compiling wxWindows
29# this way; './configure && make' may work better.
30#
741f371c 31MINGW32=1
1a7f3062 32
b994671d
MB
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
35# compiler
36ifeq ($(MINGW32),1)
37 MIN_SUFFIX=_min
38else
39 MIN_SUFFIX=_cyg
40endif
41
78e376b5
MB
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
46# are at least
47# 2000-01-21 for gcc.exe and
48# 2000-02-04 for ld.exe
49# then use '2.95-late'.
50#
51# gcc 2.8.x and earlier require struct-return workaround
52#MINGW32VERSION=2.8
53#
54# gcc 2.95.2 and earlier requires special thunk option
55#MINGW32VERSION=2.9-early
56#
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
60#
61# gcc 3.x provides a win32api.h header
fe5de1ea 62MINGW32VERSION=3.0
2bda0e17 63
5283098e
JS
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
67#WINE=1
68
eb76cc94
VZ
69# Set this if you are using a cross-compiler, i.e. compiling on one system
70# the program for another one
71# CROSS=i386-mingw32-
72
78e376b5
MB
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.
5283098e 78ifndef WINE
8a653baa 79#OSTYPE=msys
5283098e
JS
80else
81OSTYPE=msys
82endif
2b5f62a0 83
75515c52 84# If building DLL, the version
35af98e4 85include $(WXDIR)/src/version.mak
34b6a45a 86WXVERSION=$(wxMAJOR_VERSION)$(wxMINOR_VERSION)$(wxRELEASE_NUMBER_IFUNSTABLE)
b3bd664a
MB
87
88ifndef UNICODE
c448540d
MB
89 UNICODE=0
90endif
91
92ifndef FINAL
8a653baa 93 FINAL=0
c448540d
MB
94endif
95
96ifndef wxUSE_GUI
97 wxUSE_GUI=1
b3bd664a 98endif
75515c52 99
102f951d
GRG
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.
014e19de 102RM=rm -f
6474416b 103
102f951d 104# Set to the appropriate copy command (must support forward slashes)
a20a10fe
JS
105# You can get a suitable cp.exe from ports/mingw32/extra.zip on the ftp site.
106COPY=cp
01dba85a 107
2bda0e17
KB
108########################## Compiler ##################################
109
78e376b5
MB
110ifneq (,$(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
117# incompatibility.
118 _STRUCT_RETURN_WORKAROUND=-fno-pcc-struct-return
119# Really old versions of cygwin are thought to require extra headers.
120 ifneq ($(MINGW32),1)
121 GNUWIN32EXTRA=-I$(WXDIR)/include/wx/msw/gnuwin32
122 endif
123endif
f3ef286f 124
78e376b5
MB
125ifneq (,$(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
128# them already.
129 OBSOLETE_DEFINES = -D_X86_=1 -DWIN32 -D_WIN32 -D__WIN32__
5991550a 130endif
78e376b5
MB
131# But cygwin doesn't define them, at least through its version
132# 2.95.3-4 of gcc.
133ifneq ($(MINGW32),1)
134 OBSOLETE_DEFINES = -D_X86_=1 -DWIN32 -D_WIN32 -D__WIN32__
5991550a 135endif
46c0c2dc 136
78e376b5
MB
137ifneq (,$(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
f3ef286f 143endif
2bda0e17 144
78e376b5
MB
145ifeq (,$(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
152 RECENT_MINGW=yes
153endif
154
155ifeq (,$(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.
5283098e 159ifndef WINE
78e376b5 160 _USE_W32API_HEADER_IF_SUPPORTED = -DHAVE_W32API_H
5283098e 161endif
78e376b5
MB
162#
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
170#
171endif
172
5283098e
JS
173# Define the C++ and C compiler respectively
174ifndef WINE
eb76cc94
VZ
175CXX = $(CROSS)g++
176CC = $(CROSS)gcc
5283098e
JS
177else
178CXX = wineg++
179CC = winegcc
180endif
2bda0e17
KB
181
182# Compiler used for LEX generated C
78e376b5 183# For now at least, it can be the same as the regular C compiler
eb76cc94 184CCLEX = $(CROSS)$(CC)
2bda0e17 185
102f951d
GRG
186# This shouldn't be needed as make is supposed to define this
187# variable itself. Uncomment it if your make complains.
188#MAKE=make
2bda0e17 189
102f951d 190# LEX (currently unused)
78e376b5 191# LEX=flex # -t -L
2bda0e17 192
102f951d 193# YACC (currently unused)
78e376b5
MB
194# YACC=byacc
195# YACC=bison
2bda0e17 196
57c208c5 197# Settings for Cyginw/Mingw32
102f951d
GRG
198# Some versions of windres cannot cope with the --preprocessor
199# option. Uncomment the RCPREPROCESSOR line below if yours can.
5283098e 200ifndef WINE
eb76cc94 201RESCOMP=$(CROSS)windres $(_USE_TEMP_FILE_IF_SUPPORTED)
5283098e
JS
202else
203RESCOMP=wrc
204endif
57c208c5
JS
205RCINPUTSWITCH=-i
206RCOUTPUTSWITCH=-o
207RCINCSWITCH=--include-dir
208RCDEFSWITCH=--define
9f334bea
JS
209# Note that this can cause windres to fail (Win95/98 problem?)
210# but commenting out RCPREPROCESSOR then does the trick.
78e376b5 211#RCPREPROCESSOR=--preprocessor "$(CXX) -c -E -xc-header -DRC_INVOKED"
2bda0e17 212
f4bfe7e0
JS
213# Don't make this too long (e.g. by adding contrib/include/wx) because it will
214# truncate the command line
53fdeb16 215RESFLAGS=$(RCPREPROCESSOR) $(RCINCSWITCH) $(WXDIR)/include $(RCEXTRAINC) $(RCDEFSWITCH) __WIN32__ $(RCDEFSWITCH) __WIN95__ $(RCDEFSWITCH) __GNUWIN32__
2bda0e17 216
75515c52 217# Needed to build a DLL if your linker does not support --shared option.
eb76cc94
VZ
218AS = $(CROSS)as
219DLLTOOL = $(CROSS)dlltool
75515c52 220
2bda0e17
KB
221########################## Compiler flags #############################
222
e13f1288
MB
223# Unicode defines
224ifeq ($(UNICODE),1)
225 UNICODE_OPT = -D_UNICODE -DUNICODE -DwxUSE_UNICODE=1
226else
227 UNICODE_OPT =
228endif
229
2bda0e17 230# Miscellaneous compiler options
78e376b5 231OPTIONS = -DSTRICT $(_USE_W32API_HEADER_IF_SUPPORTED)
2bda0e17 232
a0b9e27f 233# Add "-mthreads" if you want to have threads under mingw32
2e38557f 234# Add "-mno-cygwin" if you want to link with msvcrt.dll in Cywin and Wine
d66dcb60
MB
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.
2e38557f 240COMMON_FLAGS = -mno-cygwin # -mthreads
a0b9e27f 241
2bda0e17 242# Debugging information
c448540d
MB
243ifeq ($(FINAL),0)
244 DEBUGFLAGS = -g -D__WXDEBUG__
245endif
2bda0e17 246
2bda0e17
KB
247WIN95=1
248
249ifeq ($(WIN95),0)
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.
253APPVER=3.50
78e376b5 254WINVERSION=-DWINVER=0x0350 -D__GNUWIN32__ # Generic WIN32
2bda0e17 255else
102f951d 256APPVER=4.0 # 3.50
78e376b5 257# This means 'enable Windows 95 features' (in wxWindows and in the compiler).
d66dcb60 258WINVERSION=-DWINVER=0x0400 -D__GNUWIN32__
2bda0e17
KB
259endif
260
78e376b5
MB
261# This is never used and should be expunged.
262# CPU=i386
2bda0e17
KB
263
264# Suffixes
265OBJSUFF=o
266SRCSUFF=cpp
267LIBPREFIX=lib
268LIBSUFF=a
269EXESUFF=.exe
270RESSUFF=res
271RSCSUFF=rsc
272
273# Warnings
2bda0e17
KB
274WARN = -Wall
275
c448540d
MB
276# build wxbase/wxMSW
277ifeq ($(wxUSE_GUI),1)
278 TOOLKIT=msw
d66dcb60 279 GUI =
c448540d
MB
280else
281 TOOLKIT=base
d66dcb60 282 GUI = -DwxUSE_GUI=0
c448540d
MB
283endif
284
c448540d 285ifeq ($(FINAL),1)
78e376b5 286 OPT = -O2 -fno-rtti -fno-exceptions
c448540d 287else
78e376b5 288 OPT = -fno-rtti -fno-exceptions
c448540d 289endif
2bda0e17
KB
290
291# Options for ar archiver
2bda0e17 292AROPTIONS = ruv
eb76cc94
VZ
293AR = $(CROSS)ar
294RANLIB = $(CROSS)ranlib
2bda0e17 295
b4fe5125
JS
296# Extra compiler libraries
297COMPLIBS=
2bda0e17
KB
298
299# Compiler or system-specific include paths
48d1144b 300COMPPATHS=
2bda0e17 301
2bda0e17
KB
302########################## Directories ###############################
303
ae090fdb 304OLELIBS=-lole32 -loleaut32 -luuid
c448540d
MB
305BASELIBS=-lstdc++ -lgcc -lodbc32 -lwsock32
306ifeq ($(wxUSE_GUI),1)
307 WINLIBS= $(BASELIBS) \
d66dcb60
MB
308 -lwinspool -lwinmm -lshell32 \
309 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 \
310 -lodbc32 -lwsock32 -lopengl32 -lglu32 $(OLELIBS) # -loldnames
c448540d
MB
311else
312 WINLIBS=$(BASELIBS)
313endif
b4fe5125
JS
314
315#WINLIBS=-lstdc++ -lgcc \
d66dcb60 316# -lwinspool -lwinmm -lshell32 \
b4fe5125 317# -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lwsock32 # -loldnames
2bda0e17
KB
318
319# Shouldn't need to change these...
6a570331
RR
320WXSRC=$(WXDIR)/src/msw
321WXINC=$(WXDIR)/include
322WXBASESRC=$(WXDIR)/src/common
f3ef286f 323
f6a35171 324#ifeq ($(MINGW32),1)
9d8c2f41 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)
f6a35171 326#else
78e376b5 327INC = -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)
f6a35171 328#endif
f3ef286f 329
78e376b5 330RCLFLAGS=-cpp "cpp -lang-c++ $(OBSOLETE_DEFINES) -DRCL_INVOKED -I$(WXWIN)/include"
2bda0e17 331
75515c52
GRG
332ifdef WXUSINGDLL
333 # png, jpeg, etc are exported from wx dll, so skip and save on link time.
711df835 334 LIBS = $(EXTRALIBS) $(WXLIB) $(WINLIBS) $(COMPLIBS)
75515c52 335else
b994671d 336 LIBS = $(EXTRALIBS) $(WXLIB) -lregex$(MIN_SUFFIX) -lpng$(MIN_SUFFIX) -ljpeg$(MIN_SUFFIX) -lzlib$(MIN_SUFFIX) -ltiff$(MIN_SUFFIX) $(WINLIBS) $(COMPLIBS)
75515c52 337endif
2bda0e17 338
78e376b5 339WINFLAGS = $(OBSOLETE_DEFINES) $(WINVERSION)
2bda0e17
KB
340
341#for windows 95
342XINCLUDE=$(WINFLAGS)
343XLIB=$(LIBS)
344LDLIBS = $(LIBS)
345
346# Directory for object files (don't change)
dbda9e86 347# OBJDIR = objects$(GUISUFFIX)
881eba2c 348OBJDIR = .
2bda0e17 349
c448540d
MB
350ifeq ($(FINAL),1)
351 DEBEXT=
352else
353 DEBEXT=d
354endif
355
b3bd664a
MB
356ifeq ($(UNICODE),1)
357 UNIEXT=u
358else
359 UNIEXT=
360endif
361
362ifeq ($(WXMAKINGDLL)$(WXUSINGDLL),)
c448540d 363 INCEXT=$(UNIEXT)$(DEBEXT)
b3bd664a 364else
c448540d 365 INCEXT=dll$(UNIEXT)$(DEBEXT)
b3bd664a
MB
366endif
367
c448540d
MB
368WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx$(TOOLKIT)$(UNIEXT)$(DEBEXT).$(LIBSUFF)
369
75515c52
GRG
370ifdef WXMAKINGDLL
371 EXTRADLLFLAGS = -DWXMAKINGDLL=1 -D_DLL=1 -D_WINDLL=1
b994671d 372 WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx$(TOOLKIT)$(WXVERSION)$(UNIEXT)$(DEBEXT)$(MIN_SUFFIX).$(LIBSUFF)
75515c52
GRG
373endif
374
375ifdef WXUSINGDLL
376 EXTRADLLFLAGS = -DWXUSINGDLL=1
b994671d 377 WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx$(TOOLKIT)$(WXVERSION)$(UNIEXT)$(DEBEXT)$(MIN_SUFFIX).$(LIBSUFF)
75515c52
GRG
378endif
379
380
c448540d 381ifeq ($(wxUSE_GUI),1)
78e376b5
MB
382 WINDOWSLDFLAGS=-Wl,--subsystem,windows
383 WINDOWSLDLIBS=-mwindows
c448540d 384endif
2bda0e17 385
78e376b5
MB
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.
391
392CFLAGS = -DWIN32_LEAN_AND_MEAN
393
394WXLIBDIRS = -L$(WXDIR)/lib -L$(WXDIR)/contrib/lib
395
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.
403#
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.
411ALL_CPPFLAGS = $(XINCLUDE) $(INC) $(CPPFLAGS) $(EXTRACPPFLAGS)
412# C and C++ compiler flags for compatibility with old gcc versions
413REQUIRED_GCC_FLAGS = $(_STRUCT_RETURN_WORKAROUND) $(_THUNK_WORKAROUND)
414# C++ compiler flags
2e38557f 415ALL_CXXFLAGS = $(COMMON_FLAGS) $(REQUIRED_GCC_FLAGS) $(UNICODE_OPT) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CXXFLAGS)
78e376b5 416# C compiler flags
2e38557f 417ALL_CFLAGS = $(COMMON_FLAGS) $(REQUIRED_GCC_FLAGS) $(UNICODE_OPT) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CFLAGS)
78e376b5 418# Linker flags
2e38557f 419ALL_LDFLAGS = $(COMMON_FLAGS) $(WINDOWSLDFLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
78e376b5 420# under Cygwin, Dlls must not be linked with subsystem=windows
2e38557f 421ALL_LDFLAGS_DLL = $(COMMON_FLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
78e376b5 422
2b5f62a0 423.SUFFIXES: .rc .$(RESSUFF) .$(RSCSUFF) .cpp .cxx .cc .c
2bda0e17
KB
424
425.c.o:
78e376b5 426 $(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
2bda0e17 427
2b5f62a0 428.cc.o:
78e376b5 429 $(CXX) -c $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ $*.cc
2b5f62a0 430
e828e4f7 431.cxx.o:
78e376b5 432 $(CXX) -c $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ $*.cxx
e828e4f7 433
78e376b5
MB
434# This '.cpp.o' rule is apparently written this way because
435# the 'tmake' file g95.t expects it.
9b97ee33 436.$(SRCSUFF).$(OBJSUFF):
78e376b5 437 $(CXX) -c $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ $*.$(SRCSUFF)