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