doxygen.h 34 KB

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