]> git.saurik.com Git - wxWidgets.git/blame - docs/tech/tn0016.txt
Intel C++ needs time.h before sys/stat.h
[wxWidgets.git] / docs / tech / tn0016.txt
CommitLineData
cf615ebb
VS
1 How to add new files and libraries to wxWindows build system
2 ============================================================
3
4
51. Regenerating makefiles
6-------------------------
7
b6e20cff
VS
8wxWindows now uses Bakefile (http://bakefile.sourceforge.net) to generate
9native makefiles. You must have bakefile installed if you want to regenerate
10the makefiles. Bakefile currently runs on Unix and Windows systems. You will
11need Python >= 2.2 installed on Unix and either use Bakefile installer or have
12Python on Windows.
13
14Once you have installed Bakefile, you can easily regenerate the makefiles using
15the makefile in $(wx)/build/bakefiles directory. The makefile uses Unix make
16syntax and works on Unix or using either Borland Make or GNU Make (including
17native Win32 port called mingw32-make from http://www.mingw.org) on Windows.
18It is possible that other Windows make utilities work as well, but it wasn't
19tested. "make clean" only works on Unix or Cygwin or MSYS emulation layer on
20Windows.
21
22You can use following commands when generating the makefiles (must be run from
23$(wx)/build/bakefiles directory):
24
25make <filename> generates one makefile (e.g. "make ../makefile.gcc")
26make all regenerates all makefiles that are out of date
27make library only makefiles for the main library
28make <compiler> only makefiles for given compiler; possible values
29 are "borland", "watcom", "mingw", "autoconf", "msvc"
30 and "mvsc6prj" (Visual C++ project files)
31make clean deletes all generated files (Unix shell only)
32
33Note that it generates makefiles for samples and contrib libraries, too.
34
35IMPORTANT NOTE: Don't forget to run autoconf in wxWindows root directory if
36 you changed any conditional variable or target condition
37 in .bkl files! You will know that this happened if
38 $(wx)/autoconf_inc.m4 content changed.
39
055f8a8b
VS
40You can use Bakefile to generate makefiles or projects customized to your
41needs, too. See Makefile for details on bakefile commands used to generate
42makefiles. For example, you can use this command to generate VC++ project
43files without wxUniversal configurations:
44 bakefile -v -fmsvc6prj -o../wxmy.dsw -DRUNTIME_LIBS=dynamic
f2131574 45 -DDEBUG_INFO=default -DDEBUG_FLAG=default
055f8a8b
VS
46 -DOFFICIAL_BUILD=0 -DUSE_HTML=1 -DUSE_OPENGL=1
47 -DMONOLITHIC=0 -DUSE_GUI=1 -DWXUNIV=0 wx.bkl
48Or monolithic instead of multilib (the default):
49 bakefile -v -fmsvc6prj -o../wxmono.dsw -DRUNTIME_LIBS=dynamic
f2131574 50 -DDEBUG_INFO=default -DDEBUG_FLAG=default
055f8a8b
VS
51 -DOFFICIAL_BUILD=0 -DUSE_HTML=1 -DUSE_OPENGL=1
52 -DMONOLITHIC=1 -DUSE_GUI=1 wx.bkl
53Or monolithic wxBase:
54 bakefile -v -fmsvc6prj -o../wxBase.dsw -DRUNTIME_LIBS=dynamic
f2131574 55 -DDEBUG_INFO=default -DDEBUG_FLAG=default
055f8a8b
VS
56 -DOFFICIAL_BUILD=0 -DUSE_HTML=0 -DUSE_OPENGL=0
57 -DMONOLITHIC=1 -DUSE_GUI=0 wx.bkl
58
cf615ebb
VS
59
602. Bakefile files organization
61------------------------------
62
b6e20cff
VS
63Makefile are generated from .bkl files ("bakefiles") from three places:
64 - $(wx)/build/bakefiles directory
65 - $(wx)/contrib/build/* directories
66 - samples directories
67$(wx)/build/bakefiles contains bakefiles for main library and support files
68that simplify writing bakefiles for contrib and samples.
69
70Support files are:
71 wxwin.py - helper functions
72 common.bkl
73 common_samples.bkl
74 common_contrib.bkl - shared definitions and templates
75 config.bkl - user-configurable build options
76
77Files used to build the library are:
78 wx.bkl - main file
79 files.bkl - lists of source files
80 monolithic.bkl - targets for wxWin built as single big library
81 multilib.bkl - targets for multilib build
82 opengl.bkl - GL library with wxGLCanvas (this one is not
83 included in monolithic library for historical
84 reasons, so "monolithic" really means "two libs")
85 {expat,jpeg,png,tiff,
86 regex,zlib,odbc}.bkl - 3rd party libraries makefiles
87
cf615ebb
VS
88
893. Adding files to existing library
90-----------------------------------
91
b6e20cff
VS
92All files used by main libraries are listed in files.bkl. The file is
93organized into variables for toolkits, platforms and libraries. The variables
94come in pairs: there's always FOO_SRC for source files and FOO_HDR for header
95files. Platform or toolkit specific files are grouped together in variable
96with platform or tookit name in them, e.g. BASE_WIN32_SRC, BASE_UNIX_SRC,
97GTK_SRC, MOTIF_SRC.
cf615ebb 98
b6e20cff
VS
99Note: A side effect of this toolkit-centric organization is that one file may
100 be present several times in files.bkl in different contenxt.
101
102When you are adding a file, you must put it into appropriate variable. This is
103easy if you are adding the file to library that is always built from same
104sources on all platforms (e.g. wxXml or wxXML) -- simply add the file to e.g.
105HTML_SRC or HTML_HDR.
106
107If the file is used only on one platform and is part of wxBase, add it to
108BASE_{platform}_SRC/HDR. If it is used on all platforms, add it to BASE_CMN.
109If it is built on more than one platform but not on all of them, add the file
110to *all platforms that use it*!
111
112If a file is not wxBase file, but GUI file, then the variables are named after
113toolkits/ports, not platforms. Same rules as for wxBase files apply
114(substitute "platform" with "toolkit"). Make sure you correctly choose between
115{port}_LOWLEVEL_SRC and {port}_SRC -- the former is for files used by
116wxUniversal, e.g. GDI classes. Files shared by all X Window System ports
117should be put into XWIN_LOWLEVEL_SRC.
118
119
1204. Adding sample
121----------------
122
123Copy the bakefile from another sample, change the ID and files accordingly.
124If the sample uses some data files, make sure to have <wx-data> node
125in the sample's bakefile (see e.g. samples/image/image.bkl for an example).
126Make sure to add <wx-lib> statements for all libraries from multilib build
127that are required by the sample.
128
129Run Python script regenMakefile.py in $(wx)/build/bakefiles to update Makefile
130and commit $(wx)/build/bakefiles/Makefile.
131
132
1335. Adding contrib library
134-------------------------
135
136Contrib library bakefiles are located in $(wx)/contrib/build/name-of-contrib
137directory, together with generated makefiles. Copy the bakefile from another
138contrib library, change the IDs and files accordingly. Note that there must be
139two targets for contrib wxFoo: foodll and foolib.
140
141foodll definition must contain <wx-lib> statements for all libraries it
142depends on. WXUSINGDLL and WXMAKINGDLL_FOO must be defined and symbols from
143the library should use WXDLLIMPEXP_FOO defined in wxFoo's headers analogically
144to WXDLLIMPEXP_{BASE,CORE,HTML,...} in the main library (see 5g below for
145additional details).
146
147Run Python script regenMakefile.py in $(wx)/build/bakefiles to update Makefile
148and commit $(wx)/build/bakefiles/Makefile.
cf615ebb
VS
149
150
b6e20cff 1516. Adding new core library
cf615ebb
VS
152--------------------------
153
154When adding new library to the core set of libraries, the files must be
155added to both a newly added library in multilib build and into the single
156library built in monolithic mode. We will assume that the new library is
157called wxFoo.
158
b6e20cff
VS
159a) Add files to files.bkl:
160 * If wxFoo builds from same files on all platforms (e.g. wxNet),
161 add FOO_SRC and FOO_HDR variables with lists of sources and headers.
162 * If wxFoo have no files in common (e.g. wxGL), add FOO_SRC and FOO_HDR
163 with toolkit or platform conditions. Have a look at OPENGL_SRC for an
164 example.
165 * Otherwise add FOO_CMN_SRC and FOO_CMN_HDR for common files and
166 FOO_{platform}_{SRC,HDR} or FOO_{toolkit}_{SRC,HDR} as appropriate. Add
167 FOO_PLATFORM_{SRC,HDR} into "Define sources for specific libraries"
168 section that is conditionally set to one of FOO_xxx_{SRC,HDR} based on
169 target platform/toolkit (see NET_PLATFORM_SRC definition for an example).
170 Finally, define FOO_SRC and FOO_HDR to contain both
171 FOO_PLATFORM_{SRC,HDR} and FOO_{SRC,HDR} (see NET_SRC definition for an
172 example).
173 * Add FOO_HDR to ALL_HEADERS
174
175 (You can apply different approaches to HDR and SRC variables, if e.g.
176 headers are all common but sources are not.)
177
178 Note that the conditions can only test for equality, due to limitations of
179 native make tools.
cf615ebb
VS
180
181b) Modify bakefile system in build/bakefiles/ to recognize wxFoo:
182 * Add 'foo'to MAIN_LIBS and LIBS_NOGUI or LIBS_GUI (depending on whether
183 the library depends on wxCore or not) to wxwin.py file.
184 * Add WXLIB_FOO definition to common.bkl (into the "Names of component
185 libraries" section). It looks like this:
186 <set var="WXLIB_FOO">
187 <if cond="MONOLITHIC=='0'">$(mk.evalExpr(wxwin.mkLibName('foo')))</if>
188 </set>
189
b6e20cff
VS
190c) Add files to monolithic build: it's enough to add FOO_SRC to MONOLIB_GUI_SRC
191 or MONOLIB_SRC, depending on whether wxFoo uses GUI or not.
cf615ebb 192
b6e20cff
VS
193d) Add files to multilib build: add foolib and foodll targets. Don't use
194 wxBase targets as the template, use e.g. wxXML or wxHTML. Make sure
195 WXMAKINGDLL_FOO is defined in foodll.
cf615ebb
VS
196
197e) Regenerate all makefiles (don't forget to run autoconf)
198
199f) Update wx-config.in to contain information about the library and needed
200 linker flags:
201 * Add "foo" to either CORE_BASE_LIBS or CORE_GUI_LIBS so that wxFoo is
202 not treated as contrib library in monolithic build.
203 * If wxFoo links against additional libraries, add neccessary linker
204 flags and libraries to ldflags_foo and ldlibs_foo variables (both are
205 optional).
206
207g) Update defs.h to define WXMAKINGDLL_FOO if WXMAKINGDLL is defined (add
208 #define WXMAKINGDLL_FOO inside first "#ifdef WXMAKINGDLL" block in defs.h)
209 and to define WXDLLIMPEXP_FOO and WXDLLIMPEXP_DATA_FOO. You can copy
210 e.g. WXDLLIMPEXP_NET definition, it is something like this:
211 #ifdef WXMAKINGDLL_NET
212 #define WXDLLIMPEXP_NET WXEXPORT
213 #define WXDLLIMPEXP_DATA_NET(type) WXEXPORT type
214 #elif defined(WXUSINGDLL)
215 #define WXDLLIMPEXP_NET WXIMPORT
216 #define WXDLLIMPEXP_DATA_NET(type) WXIMPORT type
217 #else // not making nor using DLL
218 #define WXDLLIMPEXP_NET
219 #define WXDLLIMPEXP_DATA_NET(type) type
220 #endif
b6e20cff 221 Use WXDLLIMPEXP_FOO when declaring wxFoo classes and functions.
cf615ebb 222
44aaf7da
VS
223i) Add information about wxFoo to the manual ("Libraries list" section
224 in libs.tex).
cf615ebb
VS
225
226
227=== EOF ===
228
229Version: $Id$