makefiles.docbook 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY project "<literal>Theos</literal>">
  5. ]>
  6. <chapter>
  7. <title>Makefiles</title>
  8. <section id="intro">
  9. <title>Introduction</title>
  10. <para>&project; is a set of Makefiles designed to take away the complexity
  11. of building and organizing iPhoneOS projects without the use of Xcode (or
  12. even Mac OS X.)</para>
  13. </section>
  14. <section id="structure">
  15. <title>Structure of a Makefile</title>
  16. <para>Here is an example makefile for a project using &project;</para>
  17. <programlisting># System variables such as MODULES and TARGET.
  18. include theos/makefiles/common.mk
  19. # Instance-related variables such as xxx_FILES.
  20. TOOL_NAME = Simple
  21. Simple_FILES = simple.mm
  22. include $(THEOS_MAKE_PATH)/tool.mk
  23. # Custom rules</programlisting>
  24. </section>
  25. <section id="project-types">
  26. <title>Project Types</title>
  27. <para>Projects are divided into different types, briefly described below.
  28. To create a project of a given type, simply include its makefile. For
  29. example, to create a command-line tool:</para>
  30. <programlisting>include theos/makefiles/tool.mk</programlisting>
  31. <para>From one Makefile, you can build multiple types of project (just
  32. include both project type makefiles). An example:</para>
  33. <programlisting>include theos/makefiles/common.mk
  34. TWEAK_NAME = Simple
  35. Simple_FILES = Tweak.mm
  36. TOOL_NAME = simpleutility
  37. simpleutility_FILES = su.c
  38. include $(THEOS_MAKE_PATH)/tweak.mk
  39. include $(THEOS_MAKE_PATH)/tool.mk</programlisting>
  40. <para>You can also build multiple instances of a single project type from
  41. one Makefile.</para>
  42. <programlisting>include theos/makefiles/common.mk
  43. TWEAK_NAME = Simple Complex
  44. Simple_FILES = Tweak.mm
  45. Complex_FILES = 1.mm 2.mm 3.mm 4.mm
  46. include $(THEOS_MAKE_PATH)/tweak.mk</programlisting>
  47. <section>
  48. <title>Aggregate (<filename>aggregate.mk</filename>)</title>
  49. <para>An Aggregate project is a project that consists of several
  50. subprojects. Each subproject can be any valid type (including another
  51. Aggregate).</para>
  52. <variablelist>
  53. <varlistentry>
  54. <term><varname>SUBPROJECTS</varname></term>
  55. <listitem>
  56. <para><varname>The SUBPROJECTS</varname> variable defines the
  57. directory names that contain the subprojects this Aggregate
  58. project should build.</para>
  59. </listitem>
  60. </varlistentry>
  61. </variablelist>
  62. </section>
  63. <section>
  64. <title><systemitem class="library">UIKit</systemitem> Applications
  65. (<filename>application.mk</filename>)</title>
  66. <para>An <literal>application</literal> is an Objective-C program that includes a GUI
  67. component, and by default links against <systemitem
  68. class="library">UIKit</systemitem>.</para>
  69. </section>
  70. <section>
  71. <title>Command Line Tools (<filename>tool.mk</filename>)</title>
  72. <para>A <literal>tool</literal> is a program that does not have a GUI component, and differs from an <literal>application</literal> wherein it does
  73. not link against <systemitem class="library">UIKit</systemitem>. This
  74. project type is intended for command-line tools, daemons, etc.</para>
  75. </section>
  76. <section>
  77. <title>MobileSubstrate Tweaks (<filename>tweak.mk</filename>)</title>
  78. <para>A <literal>tweak</literal> is a dynamic library that links against <systemitem
  79. class="library">MobileSubstrate</systemitem> for the purposes of adding
  80. and replacing functions and methods at runtime.</para>
  81. <para>Tweaks in &project; are often written with the help of the Logos
  82. preprocessor.</para>
  83. <note>
  84. <para>A <literal>tweak</literal> does not, by default, link against <systemitem
  85. class="library">UIKit</systemitem>. If you want to link against
  86. <systemitem class="library">UIKit</systemitem>, add it to
  87. <varname>xxx_FRAMEWORKS</varname>.</para>
  88. </note>
  89. </section>
  90. <section>
  91. <title>Bundles (<filename>bundle.mk</filename>)</title>
  92. <para>A <literal>bundle</literal> is a dynamic library meant to be loaded into another
  93. application at runtime, using the <classname>NSBundle</classname> class.</para>
  94. </section>
  95. <section>
  96. <title>Frameworks (<filename>framework.mk</filename>)</title>
  97. <!--para>A framework is a dynamic library bundle, containing resources, meant to be linked by another
  98. application or dynamic library.</para-->
  99. </section>
  100. <section>
  101. <title>Dynamic Libraries (<filename>library.mk</filename>)</title>
  102. </section>
  103. </section>
  104. <section>
  105. <title>Variables</title>
  106. <section>
  107. <title>System Constants</title>
  108. <para>These constants are listed for use in toplevel Makefiles.</para>
  109. <variablelist>
  110. <varlistentry>
  111. <term><varname>THEOS</varname></term>
  112. <term><varname>THEOS_MAKE_PATH</varname></term>
  113. <term><varname>THEOS_BIN_PATH</varname></term>
  114. <term><varname>THEOS_LIBRARY_PATH</varname></term>
  115. <term><varname>THEOS_INCLUDE_PATH</varname></term>
  116. <term><varname>THEOS_MODULE_PATH</varname></term>
  117. <listitem>
  118. <para>Used for locating other &project; resources, such as binaries, scripts, modules and other makefiles.</para>
  119. </listitem>
  120. </varlistentry>
  121. <varlistentry>
  122. <term><varname>THEOS_PLATFORM_NAME</varname></term>
  123. <term><varname>THEOS_TARGET_NAME</varname></term>
  124. <listitem>
  125. <para>The build platform and the platform being targeted, normalized.</para>
  126. </listitem>
  127. </varlistentry>
  128. </variablelist>
  129. </section>
  130. <section>
  131. <title>System Variables</title>
  132. <para>These variables are listed for use in toplevel Makefiles, but if
  133. you really want to change them, you can.</para>
  134. <variablelist>
  135. <varlistentry>
  136. <term><varname>THEOS_BUILD_DIR</varname></term>
  137. <listitem>
  138. <para>Build directory (objects are placed in
  139. <filename><varname>THEOS_BUILD_DIR</varname>/<varname>THEOS_OBJ_DIR_NAME</varname></filename>).
  140. Defaults to the current directory.</para>
  141. </listitem>
  142. </varlistentry>
  143. <varlistentry>
  144. <term><varname>THEOS_OBJ_DIR_NAME</varname></term>
  145. <listitem>
  146. <para>Output file directory name. Defaults to
  147. <filename>.theos/obj</filename>.</para>
  148. </listitem>
  149. </varlistentry>
  150. <varlistentry>
  151. <term><varname>THEOS_STAGING_DIR</varname></term>
  152. <listitem>
  153. <para>Package staging directory. Defaults to
  154. <filename><varname>THEOS_PROJECT_DIR</varname>/_</filename>.</para>
  155. </listitem>
  156. </varlistentry>
  157. <varlistentry>
  158. <term><varname>Blah</varname></term>
  159. <listitem>
  160. <para>Description</para>
  161. </listitem>
  162. </varlistentry>
  163. </variablelist>
  164. </section>
  165. <section>
  166. <title>Local Variables</title>
  167. <para>These variables are not tied to any particular project instance,
  168. and can be set either in the toplevel Makefile or in the
  169. environment.</para>
  170. <variablelist>
  171. <varlistentry>
  172. <term><varname>ADDITIONAL_CFLAGS</varname></term>
  173. <term><varname>ADDITIONAL_CCFLAGS</varname></term>
  174. <term><varname>ADDITIONAL_OBJCFLAGS</varname></term>
  175. <term><varname>ADDITIONAL_OBJCCFLAGS</varname></term>
  176. <term><varname>ADDITIONAL_LDFLAGS</varname></term>
  177. <listitem>
  178. <para>The <varname>ADDITIONAL_FLAGS</varname> variables control
  179. additional compilation flags for an entire project. These
  180. variables are not passed into subdirectories or subprojects, but
  181. can be made to do so with <command>export</command>, as in
  182. <command>export
  183. <varname>ADDITIONAL_CFLAGS</varname></command>.</para>
  184. </listitem>
  185. </varlistentry>
  186. <varlistentry>
  187. <term><varname>CFLAGS</varname></term>
  188. <term><varname>CCFLAGS</varname></term>
  189. <term><varname>OBJCFLAGS</varname></term>
  190. <term><varname>OBJCCFLAGS</varname></term>
  191. <term><varname>LDFLAGS</varname></term>
  192. <listitem>
  193. <para>The unqualified <varname>FLAGS</varname> variables can be
  194. used for additional compilation flags stored in the environment or
  195. given on the commandline, as in <command>make
  196. <varname>CFLAGS</varname>=-funroll-loops</command>.</para>
  197. </listitem>
  198. </varlistentry>
  199. <varlistentry>
  200. <term><varname>OPTFLAG</varname></term>
  201. <listitem>
  202. <para>The <varname>OPTFLAG</varname> variable controls
  203. optimization. Its default value is <literal>-O2</literal>.</para>
  204. </listitem>
  205. </varlistentry>
  206. <varlistentry>
  207. <term><varname>DEBUG</varname></term>
  208. <listitem>
  209. <para>The <varname>DEBUG</varname> variable controls compilation
  210. of debug symbols and stripping. When set to <literal>1</literal>,
  211. <literal>-ggdb -DDEBUG</literal> is added to the compilation
  212. flags, stripping is disabled, and optimization flags are stripped
  213. from <varname>OPTFLAG</varname>. Additionally,
  214. <literal>+debug</literal> is appended to the package build
  215. identifier.</para>
  216. </listitem>
  217. </varlistentry>
  218. <varlistentry>
  219. <term><varname>Blah</varname></term>
  220. <listitem>
  221. <para>Description</para>
  222. </listitem>
  223. </varlistentry>
  224. <varlistentry>
  225. <term><varname>Blah</varname></term>
  226. <listitem>
  227. <para>Description</para>
  228. </listitem>
  229. </varlistentry>
  230. <varlistentry>
  231. <term><varname>Blah</varname></term>
  232. <listitem>
  233. <para>Description</para>
  234. </listitem>
  235. </varlistentry>
  236. <varlistentry>
  237. <term><varname>Blah</varname></term>
  238. <listitem>
  239. <para>Description</para>
  240. </listitem>
  241. </varlistentry>
  242. </variablelist>
  243. </section>
  244. <section>
  245. <title>Project Variables</title>
  246. <para>The various project type makefiles all support a common set of
  247. variables, described below. In this list, <literal>xxx</literal> is
  248. assumed to be the project instance name.</para>
  249. <variablelist>
  250. <varlistentry>
  251. <term><varname>xxx_FILES</varname></term>
  252. <listitem>
  253. <para>The <varname>FILES</varname> variables contain
  254. space-delimited lists of the source files comprising the project.
  255. Including files with the <filename>.m</filename> or <filename>.mm</filename> extensions causes the Objective-C runtime and
  256. Foundation framework to be linked with your project.</para>
  257. <para>The older type-specific <varname>FILES</varname> variables are deprecated in favour of <varname>xxx_FILES</varname>.</para>
  258. </listitem>
  259. </varlistentry>
  260. <varlistentry>
  261. <term><varname>xxx_OBJ_FILES</varname></term>
  262. <listitem>
  263. <para>The <varname>OBJ_FILES</varname> variable contains a
  264. space-delimited list of precompiled object files
  265. (<filename>.o</filename> or library/framework binaries) to be linked with the project.</para>
  266. </listitem>
  267. </varlistentry>
  268. <varlistentry>
  269. <term><varname>xxx_FRAMEWORKS</varname></term>
  270. <term><varname>xxx_PRIVATE_FRAMEWORKS</varname></term>
  271. <listitem>
  272. <para>The <varname>FRAMEWORKS</varname> variables contain
  273. space-delimited lists of frameworks to link with the project, if
  274. Objective-C source files are used. Including
  275. <varname>PRIVATE_FRAMEWORKS</varname> causes the private Framework
  276. directory to be included in the Framework search path.</para>
  277. </listitem>
  278. </varlistentry>
  279. <varlistentry>
  280. <term><varname>xxx_CFLAGS</varname></term>
  281. <term><varname>xxx_CCFLAGS</varname></term>
  282. <term><varname>xxx_OBJCFLAGS</varname></term>
  283. <term><varname>xxx_OBJCCFLAGS</varname></term>
  284. <listitem>
  285. <para>The <varname>FLAGS</varname> variables contain flags passed
  286. to the compiler for a given filetype.</para>
  287. </listitem>
  288. </varlistentry>
  289. <varlistentry>
  290. <term><varname>xxx_LDFLAGS</varname></term>
  291. <listitem>
  292. <para>The <varname>LDFLAGS</varname> variable contains flags
  293. passed to the linker for a project.</para>
  294. </listitem>
  295. </varlistentry>
  296. <varlistentry>
  297. <term><varname>Blah</varname></term>
  298. <listitem>
  299. <para>Description</para>
  300. </listitem>
  301. </varlistentry>
  302. </variablelist>
  303. </section>
  304. </section>
  305. </chapter>