blob: 00bbbcb45958b823d419738d77f9914df6ed65b4 [file] [log] [blame]
Benny Prijono9033e312005-11-21 02:08:39 +00001/* $Id$ */
2/*
Benny Prijono32177c02008-06-20 22:44:47 +00003 * Copyright (C)2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono9033e312005-11-21 02:08:39 +00004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJ_DOXYGEN_H__
20#define __PJ_DOXYGEN_H__
21
22/**
23 * @file doxygen.h
24 * @brief Doxygen's mainpage.
25 */
26
27/*////////////////////////////////////////////////////////////////////////// */
28/*
29 INTRODUCTION PAGE
30 */
31
32/**
33 * @mainpage Welcome to PJLIB!
34 *
35 * @section intro_sec What is PJLIB
36 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +000037 * PJLIB is an Open Source, small footprint framework library written in C for
38 * making scalable applications. Because of its small footprint, it can be used
39 * in embedded applications (we hope so!), but yet the library is also aimed for
40 * facilitating the creation of high performance protocol stacks.
Benny Prijono9033e312005-11-21 02:08:39 +000041 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +000042 * PJLIB is released under GPL terms.
Benny Prijono9033e312005-11-21 02:08:39 +000043 *
44 * @section download_sec Download
45 *
46 * PJLIB and all documentation can be downloaded from
Benny Prijono97b87172006-08-24 14:25:14 +000047 * http://www.pjsip.org.
Benny Prijono9033e312005-11-21 02:08:39 +000048 *
49 *
50 * @section how_to_use_sec About This Documentation
51 *
52 * This document is generated directly from PJLIB source file using
53 * \a doxygen (http://www.doxygen.org). Doxygen is a great (and free!)
54 * tools for generating such documentation.
55 *
Benny Prijono9033e312005-11-21 02:08:39 +000056 *
57 * @subsection find_samples_subsec How to Read This Document
58 *
59 * This documentation is laid out more to be a reference guide instead
60 * of tutorial, therefore first time users may find it difficult to
61 * grasp PJLIB by reading this document alone.
62 *
63 * However, we've tried our best to make this document easy to follow.
64 * For first time users, we would suggest that you follow these steps
65 * when reading this documentation:
66 *
67 * - continue reading this introduction chapter. At the end of this
68 * chapter, you'll find section called \ref pjlib_fundamentals_sec
69 * which should guide you to understand basic things about PJLIB.
70 *
71 * - find information about specific features that you want to use
72 * in PJLIB. Use the <b>Module Index</b> to find out about all
73 * features in PJLIB (if you're browsing the HTML documentation,
74 * click on the \a Module link on top of the page, or if you're
75 * reading the PDF documentation, click on \a Module \a Documentation
76 * on the navigation pane on the left).
77 *
78 * @subsection doc_organize_sec How To's
79 *
80 * Please find below links to specific tasks that you probably
81 * want to do:
82 *
83 * - <b>How to Build PJLIB</b>
84 *\n
85 * Please refer to \ref pjlib_build_sys_pg page for more information.
86 *
87 * - <b>How to Use PJLIB in My Application</b>
88 *\n
89 * Please refer to \ref configure_app_sec for more information.
90 *
91 * - <b>How to Port PJLIB</b>
92 *\n
93 * Please refer to \ref porting_pjlib_pg page.
94 *
95 * - <b>Where to Read Samples Documentation</b>
96 *\n
97 * Most of the modules provide link to the corresponding sample file.
98 * Alternatively, to get the list of all examples, you can click on
99 * <b>Related Pages</b> on the top of HTML document or on
100 * <b>PJLIB Page Documentation</b> on navigation pane of your PDF reader.
101 *
102 * - <b>How to Submit Code to PJLIB Project</b>
103 *\n
104 * Please read \ref pjlib_coding_convention_page before submitting
105 * your code. Send your code as patch against current Subversion tree
106 * to the appropriate mailing list.
107 *
108 *
109 * @section features_sec Features
110 *
111 * @subsection open_source_feat It's Open Source!
112 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000113 * PJLIB is currently released on GPL license, but other arrangements
114 * can be made with the author.
Benny Prijono9033e312005-11-21 02:08:39 +0000115 *
116 * @subsection extreme_portable_feat Extreme Portability
117 *
118 * PJLIB is designed to be extremely portable. It can run on any kind
119 * of processors (16-bit, 32-bit, or 64-bit, big or little endian, single
120 * or multi-processors) and operating systems. Floating point or no
121 * floating point. Multi-threading or not.
122 * It can even run in environment where no ANSI LIBC is available.
123 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000124 * Currently PJLIB is known to run on these platforms:
125 * - Win32/x86 (Win95/98/ME, NT/2000/XP/2003, mingw).
126 * - arm, WinCE and Windows Mobile.
127 * - Linux/x86, (user mode and as <b>kernel module</b>(!)).
128 * - Linux/alpha
129 * - Solaris/ultra.
130 * - MacOS X/powerpc
131 * - RTEMS (x86 and powerpc).
Benny Prijono9033e312005-11-21 02:08:39 +0000132 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000133 * And efforts is under way to port PJLIB on:
134 * - Symbian OS
135 *
Benny Prijono9033e312005-11-21 02:08:39 +0000136 *
137 * @subsection small_size_feat Small in Size
138 *
139 * One of the primary objectives is to have library that is small in size for
140 * typical embedded applications. As a rough guidance, we aim to keep the
141 * library size below 100KB for it to be considered as small.
142 * As the result, most of the functionalities in the library can be tailored
143 * to meet the requirements; user can enable/disable specific functionalities
144 * to get the desired size/performance/functionality balance.
145 *
146 * For more info, please see @ref pj_config.
147 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000148 *
149 * @subsection big_perform_feat Big in Performance
150 *
151 * Almost everything in PJLIB is designed to achieve the highest possible
152 * performance out of the target platform.
153 *
154 *
Benny Prijono9033e312005-11-21 02:08:39 +0000155 * @subsection no_dyn_mem No Dynamic Memory Allocations
156 *
157 * The central idea of PJLIB is that for applications to run as fast as it can,
158 * it should not use \a malloc() at all, but instead should get the memory
159 * from a preallocated storage pool. There are few things that can be
160 * optimized with this approach:
161 *
162 * - \a alloc() is a O(1) operation.
163 * - no mutex is used inside alloc(). It is assumed that synchronization
164 * will be used in higher abstraction by application anyway.
165 * - no \a free() is required. All chunks will be deleted when the pool is
166 * destroyed.
167 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000168 * The performance gained on some systems can be as high as 30x speed up
169 * against \a malloc() and \a free() on certain configurations, but of
170 * course your mileage may vary.
Benny Prijono9033e312005-11-21 02:08:39 +0000171 *
172 * For more information, see \ref PJ_POOL_GROUP
173 *
174 *
175 * @subsection os_abstract_feat Operating System Abstraction
176 *
177 * PJLIB has abstractions for features that are normally not portable
178 * across operating systems:
179 * - @ref PJ_THREAD
180 *\n
181 * Portable thread manipulation.
182 * - @ref PJ_TLS
183 *\n
184 * Storing data in thread's private data.
185 * - @ref PJ_MUTEX
186 *\n
187 * Mutual exclusion protection.
188 * - @ref PJ_SEM
189 *\n
190 * Semaphores.
191 * - @ref PJ_ATOMIC
192 *\n
193 * Atomic variables and their operations.
194 * - @ref PJ_CRIT_SEC
195 *\n
196 * Fast locking of critical sections.
197 * - @ref PJ_LOCK
198 *\n
199 * High level abstraction for lock objects.
200 * - @ref PJ_EVENT
201 *\n
202 * Event object.
203 * - @ref PJ_TIME
204 *\n
205 * Portable time manipulation.
206 * - @ref PJ_TIMESTAMP
207 *\n
208 * High resolution time value.
209 * - etc.
210 *
211 *
212 * @subsection ll_network_io_sec Low-Level Network I/O
213 *
214 * PJLIB has very portable abstraction and fairly complete set of API for
215 * doing network I/O communications. At the lowest level, PJLIB provides:
216 *
217 * - @ref PJ_SOCK
218 *\n
219 * A highly portable socket abstraction, runs on all kind of
220 * network APIs such as standard BSD socket, Windows socket, Linux
221 * \b kernel socket, PalmOS networking API, etc.
222 *
223 * - @ref pj_addr_resolve
224 *\n
225 * Portable address resolution, which implements #pj_gethostbyname().
226 *
227 * - @ref PJ_SOCK_SELECT
228 *\n
229 * A portable \a select() like API (#pj_sock_select()) which can be
230 * implemented with various back-end.
231 *
232 *
Benny Prijono9033e312005-11-21 02:08:39 +0000233 *
234 * @subsection timer_mgmt_sec Timer Management
235 *
236 * A passive framework for managing timer, see @ref PJ_TIMER for more info.
237 * There is also function to retrieve high resolution timestamp
238 * from the system (see @ref PJ_TIMESTAMP).
239 *
240 *
241 * @subsection data_struct_sec Various Data Structures
242 *
243 * Various data structures are provided in the library:
244 *
245 * - @ref PJ_PSTR
246 * - @ref PJ_ARRAY
247 * - @ref PJ_HASH
248 * - @ref PJ_LIST
249 * - @ref PJ_RBTREE
250 *
251 *
252 * @subsection exception_sec Exception Construct
253 *
254 * A convenient TRY/CATCH like construct to propagate errors, which by
255 * default are used by the @ref PJ_POOL_GROUP "memory pool" and
256 * the lexical scanner in pjlib-util. The exception
257 * construct can be used to write programs like below:
258 *
259 * <pre>
260 * #define SYNTAX_ERROR 1
261 *
262 * PJ_TRY {
263 * msg = NULL;
264 * msg = parse_msg(buf, len);
265 * }
266 * PJ_CATCH ( SYNTAX_ERROR ) {
267 * .. handle error ..
268 * }
269 * PJ_END;
270 * </pre>
271 *
272 * Please see @ref PJ_EXCEPT for more information.
273 *
274 *
275 * @subsection logging_sec Logging Facility
276 *
277 * PJLIB @ref PJ_LOG consists of macros to write logging information to
278 * some output device. Some of the features of the logging facility:
279 *
280 * - the verbosity can be fine-tuned both at compile time (to control
281 * the library size) or run-time (to control the verbosity of the
282 * information).
283 * - output device is configurable (e.g. stdout, printk, file, etc.)
284 * - log decoration is configurable.
285 *
286 * See @ref PJ_LOG for more information.
287 *
288 *
289 * @subsection guid_gen_sec Random and GUID Generation
290 *
291 * PJLIB provides facility to create random string
292 * (#pj_create_random_string()) or globally unique identifier
293 * (see @ref PJ_GUID).
294 *
295 *
296 *
297 * @section configure_app_sec Configuring Application to use PJLIB
298 *
299 * @subsection pjlib_compil_sec Building PJLIB
300 *
301 * Follow the instructions in \ref pjlib_build_sys_pg to build
302 * PJLIB.
303 *
304 * @subsection pjlib_compil_app_sec Building Applications with PJLIB
305 *
306 * Use the following settings when building applications with PJLIB.
307 *
308 * @subsubsection compil_inc_dir_sec Include Search Path
309 *
310 * Add this to your include search path ($PJLIB is PJLIB root directory):
311 * <pre>
312 * $PJLIB/include
313 * </pre>
314 *
315 * @subsubsection compil_inc_file_sec Include PJLIB Header
316 *
317 * To include all PJLIB headers:
318 * \verbatim
319 #include <pjlib.h>
320 \endverbatim
321 *
322 * Alternatively, you can include individual PJLIB headers like this:
323 * \verbatim
324 #include <pj/log.h>
325 #include <pj/os.h>
326 \endverbatim
327 *
328 *
329 * @subsubsection compil_lib_dir_sec Library Path
330 *
331 * Add this to your library search path:
332 * <pre>
333 * $PJLIB/lib
334 * </pre>
335 *
336 * Then add the appropriate PJLIB library to your link specification. For
337 * example, you would add \c libpj-i386-linux-gcc.a when you're building
338 * applications in Linux.
339 *
340 *
341 * @subsection pjlib_fundamentals_sec Principles in Using PJLIB
342 *
343 * Few things that you \b MUST do when using PJLIB, to make sure that
344 * you create trully portable applications.
345 *
346 * @subsubsection call_pjlib_init_sec Call pj_init()
347 *
348 * Before you do anything else, call \c pj_init(). This would make sure that
349 * PJLIB system is properly set up.
350 *
351 * @subsubsection no_ansi_subsec Do NOT Use ANSI C
352 *
353 * Contrary to popular teaching, ANSI C (and LIBC) is not the most portable
354 * library in the world, nor it's the most ubiquitous. For example, LIBC
355 * is not available in Linux kernel. Also normally LIBC will be excluded
356 * from compilation of RTOSes to reduce size.
357 *
358 * So for maximum portability, do NOT use ANSI C. Do not even try to include
359 * any other header files outside <include/pj>. Stick with the functionalities
360 * provided by PJLIB.
361 *
362 *
363 * @subsubsection string_rep_subsubsec Use pj_str_t instead of C Strings
364 *
365 * PJLIB uses pj_str_t instead of normal C strings. You SHOULD follow this
366 * convention too. Remember, ANSI string-h is not always available. And
367 * PJLIB string is faster!
368 *
369 * @subsubsection mem_alloc_subsubsec Use Pool for Memory Allocations
370 *
371 * You MUST NOT use \a malloc() or any other memory allocation functions.
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000372 * Use PJLIB @ref PJ_POOL_GROUP instead! It's faster and most portable.
Benny Prijono9033e312005-11-21 02:08:39 +0000373 *
374 * @subsection logging_subsubsec Use Logging for Text Display
375 *
Benny Prijonoc78c3a32006-06-16 15:54:43 +0000376 * DO NOT use <stdio.h> for text output. Use PJLIB @ref PJ_LOG instead.
Benny Prijono9033e312005-11-21 02:08:39 +0000377 *
378 *
379 * @section porting_pjlib_sec0 Porting PJLIB
380 *
381 * Please see \ref porting_pjlib_pg page on more information to port
382 * PJLIB to new target.
383 *
384 * @section enjoy_sec Enjoy Using PJLIB!
385 *
386 * We hope that you find PJLIB usefull for your application. If you
387 * have any questions, suggestions, critics, bug fixes, or anything
388 * else, we would be happy to hear it.
389 *
390 * Enjoy using PJLIB!
391 *
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +0000392 * Benny Prijono < bennylp at pjsip dot org >
Benny Prijono9033e312005-11-21 02:08:39 +0000393 */
394
395
396
397/*////////////////////////////////////////////////////////////////////////// */
398/*
399 CODING CONVENTION
400 */
401
402/**
403 * @page pjlib_coding_convention_page Coding Convention
404 *
405 * Before you submit your code/patches to be included with PJLIB, you must
406 * make sure that your code is compliant with PJLIB coding convention.
407 * <b>This is very important!</b> Otherwise we would not accept your code.
408 *
409 * @section coding_conv_editor_sec Editor Settings
410 *
411 * The single most important thing in the whole coding convention is editor
412 * settings. It's more important than the correctness of your code (bugs will
413 * only crash the system, but incorrect tab size is mental!).
414 *
415 * Kindly set your editor as follows:
416 * - tab size to \b 8.
417 * - indentation to \b 4.
418 *
419 * With \c vi, you can do it with:
420 * <pre>
421 * :se ts=8
422 * :se sts=4
423 * </pre>
424 *
425 * You should replace tab with eight spaces.
426 *
427 * @section coding_conv_detail_sec Coding Style
428 *
429 * Coding style MUST strictly follow K&R style. The rest of coding style
430 * must follow current style. You SHOULD be able to observe the style
431 * currently used by PJLIB from PJLIB sources, and apply the style to your
432 * code. If you're not able to do simple thing like to observe PJLIB
433 * coding style from the sources, then logic dictates that your ability to
434 * observe more difficult area in PJLIB such as memory allocation strategy,
435 * concurrency, etc is questionable.
436 *
437 * @section coding_conv_comment_sec Commenting Your Code
438 *
439 * Public API (e.g. in header files) MUST have doxygen compliant comments.
440 *
441 */
442
443
444/*////////////////////////////////////////////////////////////////////////// */
445/*
446 BUILDING AND INSTALLING PJLIB
447 */
448
449
450
451/**
452 * @page pjlib_build_sys_pg Building, and Installing PJLIB
453 *
454 * @section build_sys_install_sec Build and Installation
455 *
Benny Prijono5ee1f2e2006-09-22 20:43:00 +0000456 * \note
457 * <b>The most up-to-date information on building and installing PJLIB
458 * should be found in the website, under "Getting Started" document.
459 * More over, the new PJLIB build system is now based on autoconf,
460 * so some of the information here might not be relevant anymore
461 * (although most still are, since the autoconf script still use
462 * the old Makefile system as the backend).</b>
463 *
Benny Prijono9033e312005-11-21 02:08:39 +0000464 * @subsection build_sys_install_win32_sec Visual Studio
465 *
466 * The PJLIB Visual Studio workspace supports the building of PJLIB
467 * for Win32 target. Although currently only the Visual Studio 6 Workspace is
468 * actively maintained, developers with later version of Visual Studio
469 * can easily imports VS6 workspace into their IDE.
470 *
471 * To start building PJLIB projects with Visual Studio 6 or later, open
472 * the \a workspace file in the corresponding \b \c build directory. You have
473 * several choices on which \a dsw file to open:
474 \verbatim
Benny Prijono294c2532006-06-16 16:52:51 +0000475 $PJPROJECT/pjlib/build/pjlib.dsw
476 $PJPROJECT/pjsip/build/pjsip.dsw
Benny Prijono9033e312005-11-21 02:08:39 +0000477 ..etc
478 \endverbatim
479 *
Benny Prijono294c2532006-06-16 16:52:51 +0000480 * The easiest way is to open <tt>pjsip_apps.dsw</tt> file in \b \c $PJPROJECT/pjsip-apps/build
481 * directory, and build pjsua project or the samples project.
482 * However this will not build the complete projects.
483 * For example, the PJLIB test is not included in this workspace.
484 * To build the complete projects, you must
Benny Prijono9033e312005-11-21 02:08:39 +0000485 * open and build each \a dsw file in \c build directory in each
486 * subprojects. For example, to open the complete PJLIB workspace, open
487 * <tt>pjlib.dsw</tt> in <tt>$PJPROJECT/pjlib/build</tt> directory.
488 *
489 *
490 * @subsubsection config_site_create_vc_sec Create config_site.h
491 *
492 * The file <tt><b>$PJPROJECT/pjlib/include/pj/config_site.h</b></tt>
493 * is supposed to contain configuration that is specific to your site/target.
494 * This file is not part of PJLIB, so you must create it yourself. Normally
495 * you just need to create a blank file.
496 *
497 * The reason why it's not included in PJLIB is so that you would not accidently
498 * overwrite your site configuration.
499 *
500 * If you fail to do this, Visual C will complain with error like:
501 *
502 * <b>"fatal error C1083: Cannot open include file: 'pj/config_site.h': No such file
503 * or directory"</b>.
504 *
505 * @subsubsection build_vc_subsubsec Build the Projects
506 *
507 * Just hit the build button!
508 *
509 *
510 * @subsection build_sys_install_unix_sec Make System
511 *
512 * For other targets, PJLIB provides a rather comprehensive build system
513 * that uses GNU \a make (and only GNU \a make will work).
514 * Currently, the build system supports building * PJLIB for these targets:
515 * - i386/Win32/mingw
516 * - i386/Linux
517 * - i386/Linux (kernel)
518 * - alpha/linux
519 * - sparc/SunOS
520 * - etc..
521 *
522 *
523 * @subsubsection build_req_sec Requirements
524 *
525 * In order to use the \c make based build system, you MUST have:
526 *
527 * - <b>GNU make</b>
528 *\n
529 * The Makefiles heavily utilize GNU make commands which most likely
530 * are not available in other \c make system.
531 * - <b>bash</b> shell is recommended.
532 *\n
533 * Specificly, there is a command <tt>"echo -n"</tt> which may not work
534 * in other shells. This command is used when generating dependencies
535 * (<tt>make dep</tt>) and it's located in
536 * <tt>$PJPROJECT/build/rules.mak</tt>.
537 * - <b>ar</b>, <b>ranlib</b> from GNU binutils
538 *\n
539 * In your system has different <tt>ar</tt> or <tt>ranlib</tt> (e.g. they
540 * may have been installed as <tt>gar</tt> and <tt>granlib</tt>), then
541 * either you create the relevant symbolic links, <b>or</b> modify
542 * <tt>$PJPROJECT/build/cc-gcc.mak</tt> and rename <tt>ar</tt> and
543 * <tt>ranlib</tt> to the appropriate names.
544 * - <b>gcc</b> to generate dependency.
545 *\n
546 * Currently the build system uses <tt>"gcc -MM"</tt> to generate build
547 * dependencies. If <tt>gcc</tt> is not desired to generate dependency,
548 * then either you don't run <tt>make dep</tt>, <b>or</b> edit
549 * <tt>$PJPROJECT/build/rules.mak</tt> to calculate dependency using
550 * your prefered method. (And let me know when you do so so that I can
551 * update the file. :) )
552 *
553 * @subsubsection build_overview_sec Building the Project
554 *
555 * Generally, steps required to build the PJLIB are:
556 *
557 \verbatim
Benny Prijono294c2532006-06-16 16:52:51 +0000558 $ cd /home/user/pjproject
559 $ ./configure
Benny Prijono9033e312005-11-21 02:08:39 +0000560 $ touch pjlib/include/pj/config_site.h
Benny Prijono294c2532006-06-16 16:52:51 +0000561 $ make dep
562 $ make
Benny Prijono9033e312005-11-21 02:08:39 +0000563 \endverbatim
564 *
Benny Prijono294c2532006-06-16 16:52:51 +0000565 * The above process will build all static libraries and all applications.
566 *
567 * \note the <tt>configure</tt> script is not a proper autoconf script,
568 * but rather a simple shell script to detect current host. This script
569 * currently does not support cross-compilation.
Benny Prijono9033e312005-11-21 02:08:39 +0000570 *
571 * \note For Linux kernel target, there are additional steps required, which
572 * will be explained in section \ref linux_kern_target_subsec.
573 *
Benny Prijono294c2532006-06-16 16:52:51 +0000574 * @subsubsection build_mak_sec Cross Compilation
Benny Prijono9033e312005-11-21 02:08:39 +0000575 *
Benny Prijono294c2532006-06-16 16:52:51 +0000576 * For cross compilation, you will need to edit the \c build.mak file in
577 * \c $PJPROJECT root directory manually. Please see <b>README-configure</b> file
578 * in the root directory for more information.
Benny Prijono9033e312005-11-21 02:08:39 +0000579 *
580 * For Linux kernel target, you are also required to declare the following
581 * variables in this file:
582 * - \c KERNEL_DIR: full path of kernel source tree.
583 * - \c KERNEL_ARCH: kernel ARCH options (e.g. "ARCH=um"), or leave blank
584 * for default.
585 * - \c PJPROJECT_DIR: full path of PJPROJECT source tree.
586 *
587 * Apart from these, there are also additional steps required to build
588 * Linux kernel target, which will be explained in \ref linux_kern_target_subsec.
589 *
590 * @subsubsection build_dir_sec Files in "build" Directory
591 *
592 * The <tt>*.mak</tt> files in \c $PJPROJECT/build directory are used to specify
593 * the configuration for the specified compiler, target machine target
594 * operating system, and host options. These files will be executed
595 * (included) by \a make during building process, depending on the values
596 * specified in <b>$PJPROJECT/build.mak</b> file.
597 *
598 * Normally you don't need to edit these files, except when you're porting
599 * PJLIB to new target.
600 *
601 * Below are the description of some files in this directory:
602 *
603 * - <tt>rules.mak</tt>: contains generic rules always included during make.
604 * - <tt>cc-gcc.mak</tt>: rules when gcc is used for compiler.
605 * - <tt>cc-vc.mak</tt>: rules when MSVC compiler is used.
606 * - <tt>host-mingw.mak</tt>: rules for building in mingw host.
607 * - <tt>host-unix.mak</tt>: rules for building in Unix/Posix host.
608 * - <tt>host-win32.mak</tt>: rules for building in Win32 command console
609 * (only valid when VC is used).
610 * - <tt>m-i386.mak</tt>: rules when target machine is an i386 processor.
611 * - <tt>m-m68k.mak</tt>: rules when target machine is an m68k processor.
612 * - <tt>os-linux.mak</tt>: rules when target OS is Linux.
613 * - <tt>os-linux-kernel.mak</tt>: rules when PJLIB is to be build as
614 * part of Linux kernel.
615 * - <tt>os-win32.mak</tt>: rules when target OS is Win32.
616 *
617 *
618 * @subsubsection config_site_create_sec Create config_site.h
619 *
620 * The file <tt><b>$PJPROJECT/pjlib/include/pj/config_site.h</b></tt>
621 * is supposed to contain configuration that is specific to your site/target.
622 * This file is not part of PJLIB, so you must create it yourself.
623 *
624 * The reason why it's not included in PJLIB is so that you would not accidently
625 * overwrite your site configuration.
626 *
627 *
628 * @subsubsection invoking_make_sec Invoking make
629 *
630 * Normally, \a make is invoked in \c build directory under each project.
631 * For example, to build PJLIB, you would invoke \a make in
632 * \c $PJPROJECT/pjlib/build directory like below:
633 *
634 \verbatim
635 $ cd pjlib/build
636 $ make
637 \endverbatim
638 *
639 * Alternatively you may invoke <tt>make</tt> in <tt>$PJPROJECT</tt>
640 * directory, to build all projects under that directory (e.g.
641 * PJLIB, PJSIP, etc.).
642 *
643 *
644 * @subsubsection linux_kern_target_subsec Linux Kernel Target
645 *
646 * \note
647 * <b>BUILDING APPLICATIONS IN LINUX KERNEL MODE IS A VERY DANGEROUS BUSINESS.
648 * YOU MAY CRASH THE WHOLE OF YOUR SYSTEM, CORRUPT YOUR HARDISK, ETC. PJLIB
649 * KERNEL MODULES ARE STILL IN EXPERIMENTAL PHASE. DO NOT RUN IT IN PRODUCTION
650 * SYSTEMS OR OTHER SYSTEMS WHERE RISK OF LOSS OF DATA IS NOT ACCEPTABLE.
651 * YOU HAVE BEEN WARNED.</b>
652 *
653 * \note
654 * <b>User Mode Linux (UML)</b> provides excellent way to experiment with Linux
655 * kernel without risking the stability of the host system. See
656 * http://user-mode-linux.sourceforge.net for details.
657 *
658 * \note
659 * I only use <b>UML</b> to experiment with PJLIB kernel modules.
660 * <b>I wouldn't be so foolish to use my host Linux machine to experiment
661 * with this.</b>
662 *
663 * \note
664 * You have been warned.
665 *
666 * For building PJLIB for Linux kernel target, there are additional steps required.
667 * In general, the additional tasks are:
668 * - Declare some more variables in <b><tt>build.mak</tt></b> file (this
669 * has been explained in \ref build_mak_sec above).
670 * - Perform these two small modifications in kernel source tree.
671 *
672 * There are two small modification need to be applied to the kernel tree.
673 *
674 * <b>1. Edit <tt>Makefile</tt> in kernel root source tree.</b>
675 *
676 * Add the following lines at the end of the <tt>Makefile</tt> in your
677 * <tt>$KERNEL_SRC</tt> dir:
678 \verbatim
679script:
680 $(SCRIPT)
681 \endverbatim
682 *
683 * \note Remember to replace spaces with <b>tab</b> in the Makefile.
684 *
685 * The modification above is needed to capture kernel's \c $CFLAGS and
686 * \c $CFLAGS_MODULE which will be used for PJLIB's compilation.
687 *
688 * <b>2. Add Additional Exports.</b>
689 *
690 * We need the kernel to export some more symbols for our use. So we declare
691 * the additional symbols to be exported in <tt>extra-exports.c</tt> file, and add
692 * a this file to be compiled into the kernel:
693 *
694 * - Copy the file <tt>extra-exports.c</tt> from <tt>pjlib/src/pj</tt>
695 * directory to <tt>$KERNEL_SRC/kernel/</tt> directory.
696 * - Edit <tt>Makefile</tt> in that directory, and add this line
697 * somewhere after the declaration of that variable:
698 \verbatim
699obj-y += extra-exports.o
700 \endverbatim
701 *
702 * To illustrate what have been done in your kernel source tree, below
703 * is screenshot of my kernel source tree _after_ the modification.
704 *
705 \verbatim
706[root@vpc-linux linux-2.6.7]# pwd
707/usr/src/linux-2.6.7
708[root@vpc-linux linux-2.6.7]#
709[root@vpc-linux linux-2.6.7]#
710[root@vpc-linux linux-2.6.7]# tail Makefile
711
712endif # skip-makefile
713
714FORCE:
715
716.PHONY: script
717
718script:
719 $(SCRIPT)
720
721[root@vpc-linux linux-2.6.7]#
722[root@vpc-linux linux-2.6.7]#
723[root@vpc-linux linux-2.6.7]# head kernel/extra-exports.c
724#include <linux/module.h>
725#include <linux/syscalls.h>
726
727EXPORT_SYMBOL(sys_select);
728
729EXPORT_SYMBOL(sys_epoll_create);
730EXPORT_SYMBOL(sys_epoll_ctl);
731EXPORT_SYMBOL(sys_epoll_wait);
732
733EXPORT_SYMBOL(sys_socket);
734[root@vpc-linux linux-2.6.7]#
735[root@vpc-linux linux-2.6.7]#
736[root@vpc-linux linux-2.6.7]# head -15 kernel/Makefile
737#
738# Makefile for the linux kernel.
739#
740
741obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
742 exit.o itimer.o time.o softirq.o resource.o \
743 sysctl.o capability.o ptrace.o timer.o user.o \
744 signal.o sys.o kmod.o workqueue.o pid.o \
745 rcupdate.o intermodule.o extable.o params.o posix-timers.o \
746 kthread.o
747
748obj-y += extra-exports.o
749
750obj-$(CONFIG_FUTEX) += futex.o
751obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
752[root@vpc-linux linux-2.6.7]#
753
754 \endverbatim
755 *
756 * Then you must rebuild the kernel.
757 * If you fail to do this, you won't be able to <b>insmod</b> pjlib.
758 *
759 * \note You will see a lots of warning messages during pjlib-test compilation.
760 * The warning messages complain about unresolved symbols which are defined
761 * in pjlib module. You can safely ignore these warnings. However, you can not
762 * ignore warnings about non-pjlib unresolved symbols.
763 *
764 *
765 * @subsection makefile_explained_sec Makefile Explained
766 *
767 * The \a Makefile for each project (e.g. PJLIB, PJSIP, etc) should be
768 * very similar in the contents. The Makefile is located under \c build
769 * directory in each project subdir.
770 *
771 * @subsubsection pjlib_makefile_subsec PJLIB Makefile.
772 *
773 * Below is PJLIB's Makefile:
774 *
775 * \include build/Makefile
776 *
777 * @subsubsection pjlib_os_makefile_subsec PJLIB os-linux.mak.
778 *
779 * Below is file <tt><b>os-linux.mak</b></tt> file in
780 * <tt>$PJPROJECT/pjlib/build</tt> directory,
781 * which is OS specific configuration file for Linux target that is specific
782 * for PJLIB project. For \b global OS specific configuration, please see
783 * <tt>$PJPROJECT/build/os-*.mak</tt>.
784 *
785 * \include build/os-linux.mak
786 *
787 */
788
789
790/*////////////////////////////////////////////////////////////////////////// */
791/*
792 PORTING PJLIB
793 */
794
795
796
797/**
798 * @page porting_pjlib_pg Porting PJLIB
799 *
Benny Prijono5ee1f2e2006-09-22 20:43:00 +0000800 * \note
801 * <b>Since version 0.5.8, PJLIB build system is now based on autoconf, so
802 * most of the time we shouldn't need to apply the tweakings below to get
803 * PJLIB working on a new platform. However, since the autoconf build system
804 * still uses the old Makefile build system, the information below may still
805 * be useful for reference.
806 * </b>
Benny Prijono9033e312005-11-21 02:08:39 +0000807 *
808 * @section new_arch_sec Porting to New CPU Architecture
809 *
810 * Below is step-by-step guide to add support for new CPU architecture.
811 * This sample is based on porting to Alpha architecture; however steps for
812 * porting to other CPU architectures should be pretty similar.
813 *
814 * Also note that in this example, the operating system used is <b>Linux</b>.
815 * Should you wish to add support for new operating system, then follow
816 * the next section \ref porting_os_sec.
817 *
818 * Step-by-step guide to port to new CPU architecture:
819 * - decide the name for the new architecture. In this case, we choose
820 * <tt><b>alpha</b></tt>.
821 * - edit file <tt>$PJPROJECT/build.mak</tt>, and add new section for
822 * the new target:
823 * <pre>
824 * #
825 * # Linux alpha, gcc
826 * #
827 * export MACHINE_NAME := <b>alpha</b>
828 * export OS_NAME := linux
829 * export CC_NAME := gcc
830 * export HOST_NAME := unix
831 * </pre>
832 *
833 * - create a new file <tt>$PJPROJECT/build/<b>m-alpha</b>.mak</tt>.
834 * Alternatively create a copy from other file in this directory.
835 * The contents of this file will look something like:
836 * <pre>
837 * export M_CFLAGS := $(CC_DEF)<b>PJ_M_ALPHA=1</b>
838 * export M_CXXFLAGS :=
839 * export M_LDFLAGS :=
840 * export M_SOURCES :=
841 * </pre>
842 * - create a new file <tt>$PJPROJECT/pjlib/include/pj/compat/<b>m_alpha.h</b></tt>.
843 * Alternatively create a copy from other header file in this directory.
844 * The contents of this file will look something like:
845 * <pre>
846 * #define PJ_HAS_PENTIUM 0
847 * #define PJ_IS_LITTLE_ENDIAN 1
848 * #define PJ_IS_BIG_ENDIAN 0
849 * </pre>
850 * - edit <tt>pjlib/include/pj/<b>config.h</b></tt>. Add new processor
851 * configuration in this header file, like follows:
852 * <pre>
853 * ...
854 * #elif defined (PJ_M_ALPHA) && PJ_M_ALPHA != 0
855 * # include <pj/compat/m_alpha.h>
856 * ...
857 * </pre>
858 * - done. Build PJLIB with:
859 * <pre>
860 * $ cd $PJPROJECT/pjlib/build
861 * $ make dep
862 * $ make clean
863 * $ make
864 * </pre>
865 *
866 * @section porting_os_sec Porting to New Operating System Target
867 *
868 * This section will try to give you rough guideline on how to
869 * port PJLIB to a new target. As a sample, we give the target a name tag,
870 * for example <tt><b>xos</b></tt> (for X OS).
871 *
872 * @subsection new_compat_os_h_file_sec Create New Compat Header File
873 *
874 * You'll need to create a new header file
875 * <b><tt>include/pj/compat/os_xos.h</tt></b>. You can copy as a
876 * template other header file and edit it accordingly.
877 *
878 * @subsection modify_config_h_file_sec Modify config.h
879 *
880 * Then modify file <b><tt>include/pj/config.h</tt></b> to include
881 * this file accordingly (e.g. when macro <tt><b>PJ_XOS</b></tt> is
882 * defined):
883 *
884 \verbatim
885 ...
886 #elif defined(PJ_XOS)
887 # include <pj/compat/os_xos.h>
888 #else
889 #...
890 \endverbatim
891 *
892 * @subsection new_target_mak_file_sec Create New Global Make Config File
893 *
894 * Then you'll need to create global configuration file that
895 * is specific for this OS, i.e. <tt><b>os-xos.mak</b></tt> in
896 * <tt><b>$PJPROJECT/build</b></tt> directory.
897 *
898 * At very minimum, the file will normally need to define
899 * <tt><b>PJ_XOS=1</b></tt> in the \c CFLAGS section:
900 *
901 \verbatim
902#
903# $PJPROJECT/build/os-xos.mak:
904#
905export OS_CFLAGS := $(CC_DEF)PJ_XOS=1
906export OS_CXXFLAGS :=
907export OS_LDFLAGS :=
908export OS_SOURCES :=
909 \endverbatim
910 *
911 *
912 * @subsection new_target_prj_mak_file_sec Create New Project's Make Config File
913 *
914 * Then you'll need to create xos-specific configuration file
915 * for PJLIB. This file is also named <tt><b>os-xos.mak</b></tt>,
916 * but its located in <tt><b>pjlib/build</b></tt> directory.
917 * This file will specify source files that are specific to
918 * this OS to be included in the build process.
919 *
920 * Below is a sample:
921 \verbatim
922#
923# pjlib/build/os-xos.mak:
924# XOS specific configuration for PJLIB.
925#
926export PJLIB_OBJS += os_core_xos.o \
927 os_error_unix.o \
928 os_time_ansi.o
929export TEST_OBJS += main.o
930export TARGETS = pjlib pjlib-test
931 \endverbatim
932 *
933 * @subsection new_target_src_sec Create and Edit Source Files
934 *
935 * You'll normally need to create at least these files:
936 * - <tt><b>os_core_xos.c</b></tt>: core OS specific
937 * functionality.
938 * - <tt><b>os_timestamp_xos.c</b></tt>: how to get timestamp
939 * in this OS.
940 *
941 * Depending on how things are done in your OS, you may need
942 * to create these files:
943 * - <tt><b>os_error_*.c</b></tt>: how to manipulate
944 * OS error codes. Alternatively you may use existing
945 * <tt>os_error_unix.c</tt> if the OS has \c errno and
946 * \c strerror() function.
947 * - <tt><b>ioqueue_*.c</b></tt>: if the OS has specific method
948 * to perform asynchronous I/O. Alternatively you may
949 * use existing <tt>ioqueue_select.c</tt> if the OS supports
950 * \c select() function call.
951 * - <tt><b>sock_*.c</b></tt>: if the OS has specific method
952 * to perform socket communication. Alternatively you may
953 * use existing <tt>sock_bsd.c</tt> if the OS supports
954 * BSD socket API, and edit <tt>include/pj/compat/socket.h</tt>
955 * file accordingly.
956 *
957 * You will also need to check various files in
958 * <tt><b>include/pj/compat/*.h</b></tt>, to see if they're
959 * compatible with your OS.
960 *
961 * @subsection new_target_build_file_sec Build The Project
962 *
963 * After basic building blocks have been created for the OS, then
964 * the easiest way to see which parts need to be fixed is by building
965 * the project and see the error messages.
966 *
967 * @subsection new_target_edit_vs_new_file_sec Editing Existing Files vs Creating New File
968 *
969 * When you encounter compatibility errors in PJLIB during porting,
970 * you have three options on how to fix the error:
971 * - edit the existing <tt>*.c</tt> file, and give it <tt>#ifdef</tt>
972 * switch for the new OS, or
973 * - edit <tt>include/pj/compat/*.h</tt> instead, or
974 * - create a totally new file.
975 *
976 * Basicly there is no strict rule on which approach is the best
977 * to use, however the following guidelines may be used:
978 * - if the file is expected to be completely different than
979 * any existing file, then perhaps you should create a completely
980 * new file. For example, file <tt>os_core_xxx.c</tt> will
981 * normally be different for each OS flavour.
982 * - if the difference can be localized in <tt>include/compat</tt>
983 * header file, and existing <tt>#ifdef</tt> switch is there,
984 * then preferably you should edit this <tt>include/compat</tt>
985 * header file.
986 * - if the existing <tt>*.c</tt> file has <tt>#ifdef</tt> switch,
987 * then you may add another <tt>#elif</tt> switch there. This
988 * normally is used for behaviors that are not totally
989 * different on each platform.
990 * - other than that above, use your own judgement on whether
991 * to edit the file or create new file etc.
992 */
993
994#endif /* __PJ_DOXYGEN_H__ */
995