]> git.saurik.com Git - wxWidgets.git/blame - src/makeg95.env
Applied patch [ 667563 ] Wine: compile fix for using glibc/msvcrt
[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
78e376b5
MB
33# Set to your gcc version. Generally 'gcc --version' tells you
34# which version you have. But it cannot distinguish between
35# 2.95.2-1 and earlier suffix versions of 2.95 . In that case,
36# inspect the dates of bin/gcc.exe and bin/ld.exe ; if they
37# are at least
38# 2000-01-21 for gcc.exe and
39# 2000-02-04 for ld.exe
40# then use '2.95-late'.
41#
42# gcc 2.8.x and earlier require struct-return workaround
43#MINGW32VERSION=2.8
44#
45# gcc 2.95.2 and earlier requires special thunk option
46#MINGW32VERSION=2.9-early
47#
48# mingw gcc-2.95.2-1 supports '-shared'
49# windres provided with gcc-2.95.2-1 supports temp file option
50#MINGW32VERSION=2.95-late
51#
52# gcc 3.x provides a win32api.h header
fe5de1ea 53MINGW32VERSION=3.0
2bda0e17 54
5283098e
JS
55# If you want to compile on Wine, simply uncomment this variable
56# If you don't want to edit the file, you can simply define it
57# on the command line like so: make WINE=1 -f makefile.g95
58#WINE=1
59
78e376b5
MB
60# If we're using MSYS, or other utilities that use forward slashes,
61# you need to set this when invoking the makefile from DOS, or the
62# wrong separators will be assumed. However, if you're using MSYS,
63# you really ought to invoke the makefile from MSYS--or, even better,
64# use the './configure && make' technique that MSYS is designed for.
5283098e 65ifndef WINE
8a653baa 66#OSTYPE=msys
5283098e
JS
67else
68OSTYPE=msys
69endif
2b5f62a0 70
75515c52 71# If building DLL, the version
c31752da 72WXVERSION=250
b3bd664a
MB
73
74ifndef UNICODE
c448540d
MB
75 UNICODE=0
76endif
77
78ifndef FINAL
8a653baa 79 FINAL=0
c448540d
MB
80endif
81
82ifndef wxUSE_GUI
83 wxUSE_GUI=1
b3bd664a 84endif
75515c52 85
102f951d
GRG
86# Set to the appropriate remove command (must support forward slashes)
87# You can get a suitable rm.exe from ports/mingw32/extra.zip on the ftp site.
014e19de 88RM=rm -f
6474416b 89
102f951d 90# Set to the appropriate copy command (must support forward slashes)
a20a10fe
JS
91# You can get a suitable cp.exe from ports/mingw32/extra.zip on the ftp site.
92COPY=cp
01dba85a 93
2bda0e17
KB
94########################## Compiler ##################################
95
78e376b5
MB
96ifneq (,$(findstring $(MINGW32VERSION),2.8))
97# According to Guillermo Rodriguez Garcia <guille@iies.es>, the
98# -fno-pcc-struct-return option is needed to make the standard div()
99# function work - otherwise it returns absolutely incorrect results
100# which breaks the wxImage class. This was fixed on 1998-08-14 for
101# mingw and cygwin. It is preferable not to use this option where it
102# is not required, because it is documented to cause binary API
103# incompatibility.
104 _STRUCT_RETURN_WORKAROUND=-fno-pcc-struct-return
105# Really old versions of cygwin are thought to require extra headers.
106 ifneq ($(MINGW32),1)
107 GNUWIN32EXTRA=-I$(WXDIR)/include/wx/msw/gnuwin32
108 endif
109endif
f3ef286f 110
78e376b5
MB
111ifneq (,$(findstring $(MINGW32VERSION),2.8 2.9-early))
112# Earlier versions of this makefile defined the following macros
113# explicitly; mingw versions since at least '2.95-late' define
114# them already.
115 OBSOLETE_DEFINES = -D_X86_=1 -DWIN32 -D_WIN32 -D__WIN32__
5991550a 116endif
78e376b5
MB
117# But cygwin doesn't define them, at least through its version
118# 2.95.3-4 of gcc.
119ifneq ($(MINGW32),1)
120 OBSOLETE_DEFINES = -D_X86_=1 -DWIN32 -D_WIN32 -D__WIN32__
5991550a 121endif
46c0c2dc 122
78e376b5
MB
123ifneq (,$(findstring $(MINGW32VERSION),2.8 2.9-early 2.95-late))
124# Versions prior to 3.0 require -fvtable-thunks for OLE support.
125# All code must be built with this option, even C++ libraries you
126# only link to, including system libraries. This option can cause
127# subtle problems with multiple inheritance.
128 _THUNK_WORKAROUND=-fvtable-thunks
f3ef286f 129endif
2bda0e17 130
78e376b5
MB
131ifeq (,$(findstring $(MINGW32VERSION),2.8 2.9-early))
132# Versions since 2.95.2-1 support '-shared', which makes linking
133# a dll *much* faster; and the accompanying windres supports
134# '--use-temp-file', which is more robust.
135 LD_SUPPORTS_SHARED=yes
136 _USE_TEMP_FILE_IF_SUPPORTED=--use-temp-file
137# Use the WIN32 wxDirDialog only if we have a recent mingw version
138 RECENT_MINGW=yes
139endif
140
141ifeq (,$(findstring $(MINGW32VERSION),2.8 2.9-early 2.95-late))
142# Versions since 3.0 provide win32api.h . An old comment said to
143# define this 'if you have w32api >= 0.5', but mingw 2.95.2-1
144# has no such header.
5283098e 145ifndef WINE
78e376b5 146 _USE_W32API_HEADER_IF_SUPPORTED = -DHAVE_W32API_H
5283098e 147endif
78e376b5
MB
148#
149# Revision 1.70.2.6 of this file suggested '--pipe' for mingw but
150# not for cygwin, and only for version 3.0 or later. Since then,
151# the advice given here
152# http://mail.gnu.org/pipermail/autoconf/2000-July/005479.html
153# is followed, and '--pipe' is not used unless you specify it on
154# the make command line, e.g.
155# make CXXFLAGS=--pipe CFLAGS=--pipe -f makefile.g95
156#
157endif
158
5283098e
JS
159# Define the C++ and C compiler respectively
160ifndef WINE
78e376b5 161CXX = g++
78e376b5 162CC = gcc
5283098e
JS
163else
164CXX = wineg++
165CC = winegcc
166endif
2bda0e17
KB
167
168# Compiler used for LEX generated C
78e376b5
MB
169# For now at least, it can be the same as the regular C compiler
170CCLEX = $(CC)
2bda0e17 171
102f951d
GRG
172# This shouldn't be needed as make is supposed to define this
173# variable itself. Uncomment it if your make complains.
174#MAKE=make
2bda0e17 175
102f951d 176# LEX (currently unused)
78e376b5 177# LEX=flex # -t -L
2bda0e17 178
102f951d 179# YACC (currently unused)
78e376b5
MB
180# YACC=byacc
181# YACC=bison
2bda0e17 182
57c208c5 183# Settings for Cyginw/Mingw32
102f951d
GRG
184# Some versions of windres cannot cope with the --preprocessor
185# option. Uncomment the RCPREPROCESSOR line below if yours can.
5283098e 186ifndef WINE
78e376b5 187RESCOMP=windres $(_USE_TEMP_FILE_IF_SUPPORTED)
5283098e
JS
188else
189RESCOMP=wrc
190endif
57c208c5
JS
191RCINPUTSWITCH=-i
192RCOUTPUTSWITCH=-o
193RCINCSWITCH=--include-dir
194RCDEFSWITCH=--define
9f334bea
JS
195# Note that this can cause windres to fail (Win95/98 problem?)
196# but commenting out RCPREPROCESSOR then does the trick.
78e376b5 197#RCPREPROCESSOR=--preprocessor "$(CXX) -c -E -xc-header -DRC_INVOKED"
2bda0e17 198
f4bfe7e0
JS
199# Don't make this too long (e.g. by adding contrib/include/wx) because it will
200# truncate the command line
53fdeb16 201RESFLAGS=$(RCPREPROCESSOR) $(RCINCSWITCH) $(WXDIR)/include $(RCEXTRAINC) $(RCDEFSWITCH) __WIN32__ $(RCDEFSWITCH) __WIN95__ $(RCDEFSWITCH) __GNUWIN32__
2bda0e17 202
75515c52 203# Needed to build a DLL if your linker does not support --shared option.
8a653baa
JS
204AS = as
205DLLTOOL = dlltool
75515c52 206
2bda0e17
KB
207########################## Compiler flags #############################
208
e13f1288
MB
209# Unicode defines
210ifeq ($(UNICODE),1)
211 UNICODE_OPT = -D_UNICODE -DUNICODE -DwxUSE_UNICODE=1
212else
213 UNICODE_OPT =
214endif
215
2bda0e17 216# Miscellaneous compiler options
78e376b5 217OPTIONS = -DSTRICT $(_USE_W32API_HEADER_IF_SUPPORTED)
2bda0e17 218
a0b9e27f 219# Add "-mthreads" if you want to have threads under mingw32
2e38557f
JS
220# Add "-mno-cygwin" if you want to link with msvcrt.dll in Cywin and Wine
221# Otherwise, you link against the native runtime (cygwin.dll or libc)
222# Having the flag in mingw32 does not hurt as you always link against msvcrt.dll
223# By default it should be on, to minimize dependencies on Cygwin, and
224# have more correct filename behaviour in Wine.
225COMMON_FLAGS = -mno-cygwin # -mthreads
a0b9e27f 226
2bda0e17 227# Debugging information
c448540d
MB
228ifeq ($(FINAL),0)
229 DEBUGFLAGS = -g -D__WXDEBUG__
230endif
2bda0e17 231
2bda0e17
KB
232WIN95=1
233
234ifeq ($(WIN95),0)
235# With 3.50, Win95 will use your existing icons to show smaller ones.
236# With 4.0, you'll have to follow Win95 procedures for icons or you'll get the
237# default Windows icon.
238APPVER=3.50
78e376b5 239WINVERSION=-DWINVER=0x0350 -D__GNUWIN32__ # Generic WIN32
2bda0e17 240else
102f951d 241APPVER=4.0 # 3.50
78e376b5
MB
242# This means 'enable Windows 95 features' (in wxWindows and in the compiler).
243WINVERSION=-DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__
2bda0e17
KB
244endif
245
78e376b5
MB
246# This is never used and should be expunged.
247# CPU=i386
2bda0e17
KB
248
249# Suffixes
250OBJSUFF=o
251SRCSUFF=cpp
252LIBPREFIX=lib
253LIBSUFF=a
254EXESUFF=.exe
255RESSUFF=res
256RSCSUFF=rsc
257
258# Warnings
2bda0e17
KB
259WARN = -Wall
260
c448540d
MB
261# build wxbase/wxMSW
262ifeq ($(wxUSE_GUI),1)
263 TOOLKIT=msw
264 GUI = -D__WXMSW__ -D__WINDOWS__
265else
266 TOOLKIT=base
267 GUI = -D__WXMSW__ -D__WINDOWS__ -DwxUSE_GUI=0
268endif
269
c448540d 270ifeq ($(FINAL),1)
78e376b5 271 OPT = -O2 -fno-rtti -fno-exceptions
c448540d 272else
78e376b5 273 OPT = -fno-rtti -fno-exceptions
c448540d 274endif
2bda0e17
KB
275
276# Options for ar archiver
2bda0e17 277AROPTIONS = ruv
78e376b5 278AR = ar
8a653baa 279RANLIB = ranlib
2bda0e17 280
b4fe5125
JS
281# Extra compiler libraries
282COMPLIBS=
2bda0e17
KB
283
284# Compiler or system-specific include paths
48d1144b 285COMPPATHS=
2bda0e17 286
2bda0e17
KB
287########################## Directories ###############################
288
ae090fdb 289OLELIBS=-lole32 -loleaut32 -luuid
c448540d
MB
290BASELIBS=-lstdc++ -lgcc -lodbc32 -lwsock32
291ifeq ($(wxUSE_GUI),1)
292 WINLIBS= $(BASELIBS) \
293 -lwinspool -lwinmm -lshell32 \
294 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 \
295 -lodbc32 -lwsock32 -lopengl32 -lglu32 $(OLELIBS) # -loldnames
296else
297 WINLIBS=$(BASELIBS)
298endif
b4fe5125
JS
299
300#WINLIBS=-lstdc++ -lgcc \
301# -lwinspool -lwinmm -lshell32 \
302# -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lwsock32 # -loldnames
2bda0e17
KB
303
304# Shouldn't need to change these...
6a570331
RR
305WXSRC=$(WXDIR)/src/msw
306WXINC=$(WXDIR)/include
307WXBASESRC=$(WXDIR)/src/common
f3ef286f 308
f6a35171 309#ifeq ($(MINGW32),1)
9d8c2f41 310#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 311#else
78e376b5 312INC = -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 313#endif
f3ef286f 314
78e376b5 315RCLFLAGS=-cpp "cpp -lang-c++ $(OBSOLETE_DEFINES) -DRCL_INVOKED -I$(WXWIN)/include"
2bda0e17 316
75515c52
GRG
317ifdef WXUSINGDLL
318 # png, jpeg, etc are exported from wx dll, so skip and save on link time.
711df835 319 LIBS = $(EXTRALIBS) $(WXLIB) $(WINLIBS) $(COMPLIBS)
75515c52 320else
08e0d1cc 321 LIBS = $(EXTRALIBS) $(WXLIB) -lregex -lpng -ljpeg -lzlib -ltiff $(WINLIBS) $(COMPLIBS)
75515c52 322endif
2bda0e17 323
78e376b5 324WINFLAGS = $(OBSOLETE_DEFINES) $(WINVERSION)
2bda0e17
KB
325
326#for windows 95
327XINCLUDE=$(WINFLAGS)
328XLIB=$(LIBS)
329LDLIBS = $(LIBS)
330
331# Directory for object files (don't change)
dbda9e86 332# OBJDIR = objects$(GUISUFFIX)
881eba2c 333OBJDIR = .
2bda0e17 334
c448540d
MB
335ifeq ($(FINAL),1)
336 DEBEXT=
337else
338 DEBEXT=d
339endif
340
b3bd664a
MB
341ifeq ($(UNICODE),1)
342 UNIEXT=u
343else
344 UNIEXT=
345endif
346
347ifeq ($(WXMAKINGDLL)$(WXUSINGDLL),)
c448540d 348 INCEXT=$(UNIEXT)$(DEBEXT)
b3bd664a 349else
c448540d 350 INCEXT=dll$(UNIEXT)$(DEBEXT)
b3bd664a
MB
351endif
352
c448540d
MB
353WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx$(TOOLKIT)$(UNIEXT)$(DEBEXT).$(LIBSUFF)
354
75515c52
GRG
355ifdef WXMAKINGDLL
356 EXTRADLLFLAGS = -DWXMAKINGDLL=1 -D_DLL=1 -D_WINDLL=1
c448540d 357 WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx$(TOOLKIT)$(WXVERSION)$(UNIEXT)$(DEBEXT).$(LIBSUFF)
75515c52
GRG
358endif
359
360ifdef WXUSINGDLL
361 EXTRADLLFLAGS = -DWXUSINGDLL=1
c448540d 362 WXLIB=$(WXDIR)/lib/$(LIBPREFIX)wx$(TOOLKIT)$(WXVERSION)$(UNIEXT)$(DEBEXT).$(LIBSUFF)
75515c52
GRG
363endif
364
365
c448540d 366ifeq ($(wxUSE_GUI),1)
78e376b5
MB
367 WINDOWSLDFLAGS=-Wl,--subsystem,windows
368 WINDOWSLDLIBS=-mwindows
c448540d 369endif
2bda0e17 370
78e376b5
MB
371# Note: WIN32_LEAN_AND_MEAN is defined only for C and not for C++ compiles.
372# Defining this macro means that a great deal of less commonly used stuff
373# is ignored in the windows headers, resulting in faster compiles. It can't
374# be used with some C++ source files. It just so happens that it can be
375# used with all C source files.
376
377CFLAGS = -DWIN32_LEAN_AND_MEAN
378
379WXLIBDIRS = -L$(WXDIR)/lib -L$(WXDIR)/contrib/lib
380
381# You shouldn't need to change these flags, which are merely composed of
382# the options selected above. You can add more flags by specifying them on
383# the make command line, e.g.
384# make CXXFLAGS='-O3 -march=i686' -f makefile.g95
385# The gnu make manual says
386# 'Users expect to be able to specify CFLAGS freely themselves'
387# That was unsafe with older versions of this makefile, but now it works.
388#
389# C preprocessor flags
390# Some makefiles pass extra flags in $(EXTRACPPFLAGS); although earlier
391# versions of this file used CPPFLAGS as C++ compiler flags (instead of
392# as C preprocessor flags), it is OK to add them to the preprocessor
393# flags, which are always used for C++ compiles. Because other makefiles
394# use this method to override these flags, they are added after $(CPPFLAGS),
395# which would normally come last.
396ALL_CPPFLAGS = $(XINCLUDE) $(INC) $(CPPFLAGS) $(EXTRACPPFLAGS)
397# C and C++ compiler flags for compatibility with old gcc versions
398REQUIRED_GCC_FLAGS = $(_STRUCT_RETURN_WORKAROUND) $(_THUNK_WORKAROUND)
399# C++ compiler flags
2e38557f 400ALL_CXXFLAGS = $(COMMON_FLAGS) $(REQUIRED_GCC_FLAGS) $(UNICODE_OPT) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CXXFLAGS)
78e376b5 401# C compiler flags
2e38557f 402ALL_CFLAGS = $(COMMON_FLAGS) $(REQUIRED_GCC_FLAGS) $(UNICODE_OPT) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRADLLFLAGS) $(CFLAGS)
78e376b5 403# Linker flags
2e38557f 404ALL_LDFLAGS = $(COMMON_FLAGS) $(WINDOWSLDFLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
78e376b5 405# under Cygwin, Dlls must not be linked with subsystem=windows
2e38557f 406ALL_LDFLAGS_DLL = $(COMMON_FLAGS) $(WINDOWSLDLIBS) $(WXLIBDIRS) $(EXTRALDFLAGS) $(LDFLAGS)
78e376b5 407
2b5f62a0 408.SUFFIXES: .rc .$(RESSUFF) .$(RSCSUFF) .cpp .cxx .cc .c
2bda0e17
KB
409
410.c.o:
78e376b5 411 $(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
2bda0e17 412
2b5f62a0 413.cc.o:
78e376b5 414 $(CXX) -c $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ $*.cc
2b5f62a0 415
e828e4f7 416.cxx.o:
78e376b5 417 $(CXX) -c $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ $*.cxx
e828e4f7 418
78e376b5
MB
419# This '.cpp.o' rule is apparently written this way because
420# the 'tmake' file g95.t expects it.
9b97ee33 421.$(SRCSUFF).$(OBJSUFF):
78e376b5 422 $(CXX) -c $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ $*.$(SRCSUFF)