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