| | 1 | {{{ |
| | 2 | #!rst |
| | 3 | |
| | 4 | kBuild Quick Reference |
| | 5 | ====================== |
| | 6 | |
| | 7 | This is an attempt at summarizing the magic of kBuild makefiles. |
| | 8 | |
| | 9 | Note! This is work in progress and very very incomplete at the moment. |
| | 10 | |
| | 11 | |
| | 12 | The anatomy of a kBuild Makefile |
| | 13 | -------------------------------- |
| | 14 | |
| | 15 | A typical makefile:: |
| | 16 | |
| | 17 | # $Id: QuickReference-kBuild.txt 2345 2009-04-19 23:47:42Z bird $ |
| | 18 | ## @file |
| | 19 | # Makefile description. |
| | 20 | # |
| | 21 | |
| | 22 | # |
| | 23 | # Copyright (c) year name |
| | 24 | # License, disclaimer and other legal text. |
| | 25 | # |
| | 26 | |
| | 27 | SUB_DEPTH = ../.. |
| | 28 | include $(KBUILD_PATH)/subheader.kmk |
| | 29 | |
| | 30 | # |
| | 31 | # Include sub-makefiles. |
| | 32 | # |
| | 33 | include $(PATH_CURRENT)/subdir1/Makefile.kmk |
| | 34 | include $(PATH_CURRENT)/subdir2/Makefile.kmk |
| | 35 | |
| | 36 | # |
| | 37 | # Global variables. |
| | 38 | # |
| | 39 | MYPREFIX_SOMETHING = or another |
| | 40 | |
| | 41 | # |
| | 42 | # Target lists. |
| | 43 | # |
| | 44 | DLLS += mydll |
| | 45 | PROGRAMS += myprogs |
| | 46 | |
| | 47 | # |
| | 48 | # mydll - description. |
| | 49 | # |
| | 50 | mydll_TEMPLATE = MYDLL |
| | 51 | mydll_SOURCES = mydll.c |
| | 52 | mydll_SOURCES.win = $(mydll_0_OUTDIR)/mydll.def |
| | 53 | |
| | 54 | # |
| | 55 | # myprog - description. |
| | 56 | # |
| | 57 | myprog_TEMPLATE = MYPROG |
| | 58 | myprog_SOURCES = myprog.c |
| | 59 | |
| | 60 | # |
| | 61 | # Custom rules (optional of course). |
| | 62 | # |
| | 63 | $$(mydll_0_OUTDIR)/mydll.def: |
| | 64 | $(APPEND) -t $@ LIBRARY mydll.dll |
| | 65 | $(APPEND) $@ EXPORTS |
| | 66 | $(APPEND) $@ ' myfunction' |
| | 67 | |
| | 68 | include $(FILE_KBUILD_SUB_FOOTER) |
| | 69 | |
| | 70 | |
| | 71 | Target lists |
| | 72 | ------------ |
| | 73 | |
| | 74 | +-+-------------------+-------------------------------------------------------+ |
| | 75 | |#| Name | Description | |
| | 76 | +=+===================+=======================================================+ |
| | 77 | |1| ``BLDPROGS`` | Build programs, targets the host platform. | |
| | 78 | +-+-------------------+-------------------------------------------------------+ |
| | 79 | |2| ``LIBRARIES`` | Libraries (not shared). | |
| | 80 | +-+-------------------+-------------------------------------------------------+ |
| | 81 | |3| ``IMPORT_LIBS`` | Import libraries or stub shared libraries. | |
| | 82 | +-+-------------------+-------------------------------------------------------+ |
| | 83 | |4| ``DLLS`` | DLLs, Shared Libraries, DYLIBs, etc. | |
| | 84 | +-+-------------------+-------------------------------------------------------+ |
| | 85 | |5| ``PROGRAMS`` | Executable programs. | |
| | 86 | +-+-------------------+-------------------------------------------------------+ |
| | 87 | |6| ``SYSMODS`` | System modules (kexts, kernel modules, drivers, etc). | |
| | 88 | +-+-------------------+-------------------------------------------------------+ |
| | 89 | |7| ``MISCBINS`` | Miscellanceous binaries like BIOS images and such. | |
| | 90 | +-+-------------------+-------------------------------------------------------+ |
| | 91 | |8| ``INSTALLS`` | Things to install. [1]_ | |
| | 92 | +-+-------------------+-------------------------------------------------------+ |
| | 93 | |9| ``FETCHES`` | Things to fetch. [1]_ | |
| | 94 | +-+-------------------+-------------------------------------------------------+ |
| | 95 | |a| ``OTHERS`` | List of targets made during the others pass. | |
| | 96 | +-+-------------------+-------------------------------------------------------+ |
| | 97 | |
| | 98 | |
| | 99 | Target properties |
| | 100 | ----------------- |
| | 101 | |
| | 102 | The first column indicates the kind of property, S=Single, D=Deferred, |
| | 103 | Ar=Accumlate-Right and Al=Accumulate-Left. |
| | 104 | |
| | 105 | The third column should be cross referenced with the first column in the |
| | 106 | target list table above. |
| | 107 | |
| | 108 | +--+-------------------+-------+----------------------------------------------+ |
| | 109 | |K | Name | Which | Description | |
| | 110 | +==+===================+=======+==============================================+ |
| | 111 | |S | ``ARLIBSUFF`` | 2 | | |
| | 112 | +--+-------------------+-------+----------------------------------------------+ |
| | 113 | |S | ``ARTOOL`` | 2 | | |
| | 114 | +--+-------------------+-------+----------------------------------------------+ |
| | 115 | |S | ``ASOBJSUFF`` | 1-7 | | |
| | 116 | +--+-------------------+-------+----------------------------------------------+ |
| | 117 | |S | ``ASTOOL`` | 1-7 | | |
| | 118 | +--+-------------------+-------+----------------------------------------------+ |
| | 119 | |S | ``BINSUFF`` | 7 | | |
| | 120 | +--+-------------------+-------+----------------------------------------------+ |
| | 121 | |S | ``BLD_TRG`` | 1-7 | | |
| | 122 | +--+-------------------+-------+----------------------------------------------+ |
| | 123 | |S | ``BLD_TRG_ARCH`` | 1-7 | | |
| | 124 | +--+-------------------+-------+----------------------------------------------+ |
| | 125 | |S | ``BLD_TRG_CPU`` | 1-7 | | |
| | 126 | +--+-------------------+-------+----------------------------------------------+ |
| | 127 | |S | ``BLD_TYPE`` | 1-7 | | |
| | 128 | +--+-------------------+-------+----------------------------------------------+ |
| | 129 | |S | ``COBJSUFF`` | 1-7 | | |
| | 130 | +--+-------------------+-------+----------------------------------------------+ |
| | 131 | |S | ``CTOOL`` | 1-7 | | |
| | 132 | +--+-------------------+-------+----------------------------------------------+ |
| | 133 | |S | ``CXXOBJSUFF`` | 1-7 | | |
| | 134 | +--+-------------------+-------+----------------------------------------------+ |
| | 135 | |S | ``CXXTOOL`` | 1-7 | | |
| | 136 | +--+-------------------+-------+----------------------------------------------+ |
| | 137 | |S | ``DLLSUFF`` | 34 | | |
| | 138 | +--+-------------------+-------+----------------------------------------------+ |
| | 139 | |S | ``EXESUFF`` | 15 | | |
| | 140 | +--+-------------------+-------+----------------------------------------------+ |
| | 141 | |S | ``FETCHDIR`` | 9 | | |
| | 142 | +--+-------------------+-------+----------------------------------------------+ |
| | 143 | |S | ``FETCHTOOL`` | 9 | | |
| | 144 | +--+-------------------+-------+----------------------------------------------+ |
| | 145 | |S | ``GID`` | 1-7 | | |
| | 146 | +--+-------------------+-------+----------------------------------------------+ |
| | 147 | |S | ``INST`` | 1-9 | | |
| | 148 | +--+-------------------+-------+----------------------------------------------+ |
| | 149 | |S | ``LDTOOL`` | 13-7 | | |
| | 150 | +--+-------------------+-------+----------------------------------------------+ |
| | 151 | |S | ``LIBSUFF`` | 234 | | |
| | 152 | +--+-------------------+-------+----------------------------------------------+ |
| | 153 | |S | ``MODE`` | 1-7 | | |
| | 154 | +--+-------------------+-------+----------------------------------------------+ |
| | 155 | |S | ``NOINST`` | 1-8 | | |
| | 156 | +--+-------------------+-------+----------------------------------------------+ |
| | 157 | |S | ``OBJCOBJSUFF`` | 1-7 | | |
| | 158 | +--+-------------------+-------+----------------------------------------------+ |
| | 159 | |S | ``OBJCTOOL`` | 1-7 | | |
| | 160 | +--+-------------------+-------+----------------------------------------------+ |
| | 161 | |S | ``OBJSUFF`` | 1-7 | | |
| | 162 | +--+-------------------+-------+----------------------------------------------+ |
| | 163 | |S | ``PATCHTOOL`` | 9 | | |
| | 164 | +--+-------------------+-------+----------------------------------------------+ |
| | 165 | |S | ``RCOBJSUFF`` | 1-7 | | |
| | 166 | +--+-------------------+-------+----------------------------------------------+ |
| | 167 | |S | ``RCTOOL`` | 1-7 | | |
| | 168 | +--+-------------------+-------+----------------------------------------------+ |
| | 169 | |S | ``SYSSUFF`` | 6 | | |
| | 170 | +--+-------------------+-------+----------------------------------------------+ |
| | 171 | |S | ``TEMPLATE`` | 1-9 | | |
| | 172 | +--+-------------------+-------+----------------------------------------------+ |
| | 173 | |S | ``TOOL`` | 1-9 | | |
| | 174 | +--+-------------------+-------+----------------------------------------------+ |
| | 175 | |S | ``UID`` | 1-7 | | |
| | 176 | +--+-------------------+-------+----------------------------------------------+ |
| | 177 | |S | ``UNPACKTOOL`` | 9 | | |
| | 178 | +--+-------------------+-------+----------------------------------------------+ |
| | 179 | |D | ``INSTALLER`` | 1-8 | | |
| | 180 | +--+-------------------+-------+----------------------------------------------+ |
| | 181 | |D | ``INSTFUN`` | 1-8 | | |
| | 182 | +--+-------------------+-------+----------------------------------------------+ |
| | 183 | |D | ``NAME`` | 1-7 | | |
| | 184 | +--+-------------------+-------+----------------------------------------------+ |
| | 185 | |D | ``POST_CMDS`` | 1-7 | | |
| | 186 | +--+-------------------+-------+----------------------------------------------+ |
| | 187 | |D | ``PRE_CMDS`` | 1-7 | | |
| | 188 | +--+-------------------+-------+----------------------------------------------+ |
| | 189 | |D | ``SONAME`` | 13-7 | | |
| | 190 | +--+-------------------+-------+----------------------------------------------+ |
| | 191 | |Ar| ``ARFLAGS`` | 2 | | |
| | 192 | +--+-------------------+-------+----------------------------------------------+ |
| | 193 | |Ar| ``ASDEFS`` | 1-7 | | |
| | 194 | +--+-------------------+-------+----------------------------------------------+ |
| | 195 | |Ar| ``ASFLAGS`` | 1-7 | | |
| | 196 | +--+-------------------+-------+----------------------------------------------+ |
| | 197 | |Ar| ``CDEFS`` | 1-7 | | |
| | 198 | +--+-------------------+-------+----------------------------------------------+ |
| | 199 | |Ar| ``CFLAGS`` | 1-7 | | |
| | 200 | +--+-------------------+-------+----------------------------------------------+ |
| | 201 | |Ar| ``CXXDEFS`` | 1-7 | | |
| | 202 | +--+-------------------+-------+----------------------------------------------+ |
| | 203 | |Ar| ``CXXFLAGS`` | 1-7 | | |
| | 204 | +--+-------------------+-------+----------------------------------------------+ |
| | 205 | |Ar| ``DEFS`` | 1-7 | | |
| | 206 | +--+-------------------+-------+----------------------------------------------+ |
| | 207 | |Ar| ``DEPS`` | 1-8 | | |
| | 208 | +--+-------------------+-------+----------------------------------------------+ |
| | 209 | |Ar| ``FETCHFLAGS`` | 9 | | |
| | 210 | +--+-------------------+-------+----------------------------------------------+ |
| | 211 | |Ar| ``IDFLAGS`` | 1-7 | | |
| | 212 | +--+-------------------+-------+----------------------------------------------+ |
| | 213 | |Ar| ``IFDLAGS`` | 1-7 | | |
| | 214 | +--+-------------------+-------+----------------------------------------------+ |
| | 215 | |Ar| ``ISFLAGS`` | 1-7 | | |
| | 216 | +--+-------------------+-------+----------------------------------------------+ |
| | 217 | |Ar| ``LDFLAGS`` | 13-7 | | |
| | 218 | +--+-------------------+-------+----------------------------------------------+ |
| | 219 | |Ar| ``LNK_DEPS`` | 1-7 | | |
| | 220 | +--+-------------------+-------+----------------------------------------------+ |
| | 221 | |Ar| ``LNK_ORDERDEPS`` | 1-7 | | |
| | 222 | +--+-------------------+-------+----------------------------------------------+ |
| | 223 | |Ar| ``OBJCDEFS`` | 1-7 | | |
| | 224 | +--+-------------------+-------+----------------------------------------------+ |
| | 225 | |Ar| ``OBJCFLAGS`` | 1-7 | | |
| | 226 | +--+-------------------+-------+----------------------------------------------+ |
| | 227 | |Ar| ``ORDERDEPS`` | 1-8 | | |
| | 228 | +--+-------------------+-------+----------------------------------------------+ |
| | 229 | |Ar| ``PATCHFLAGS`` | 9 | | |
| | 230 | +--+-------------------+-------+----------------------------------------------+ |
| | 231 | |Ar| ``RCDEFS`` | 1-7 | | |
| | 232 | +--+-------------------+-------+----------------------------------------------+ |
| | 233 | |Ar| ``RCFLAGS`` | 1-7 | | |
| | 234 | +--+-------------------+-------+----------------------------------------------+ |
| | 235 | |Ar| ``UNPACKFLAGS`` | 9 | | |
| | 236 | +--+-------------------+-------+----------------------------------------------+ |
| | 237 | |Al| ``ASINCS`` | 1-7 | | |
| | 238 | +--+-------------------+-------+----------------------------------------------+ |
| | 239 | |Al| ``BLDDIRS`` | 1-7 | | |
| | 240 | +--+-------------------+-------+----------------------------------------------+ |
| | 241 | |Al| ``CINCS`` | 1-7 | | |
| | 242 | +--+-------------------+-------+----------------------------------------------+ |
| | 243 | |Al| ``CLEAN`` | 1-9 | | |
| | 244 | +--+-------------------+-------+----------------------------------------------+ |
| | 245 | |Al| ``CXXINCS`` | 1-7 | | |
| | 246 | +--+-------------------+-------+----------------------------------------------+ |
| | 247 | |Al| ``DIRS`` | 8 | | |
| | 248 | +--+-------------------+-------+----------------------------------------------+ |
| | 249 | |Al| ``INCS`` | 1-7 | | |
| | 250 | +--+-------------------+-------+----------------------------------------------+ |
| | 251 | |Al| ``INTERMEDIATES`` | 1-7 | | |
| | 252 | +--+-------------------+-------+----------------------------------------------+ |
| | 253 | |Al| ``LIBPATH`` | 13-7 | | |
| | 254 | +--+-------------------+-------+----------------------------------------------+ |
| | 255 | |Al| ``LIBS`` | 13-7 | | |
| | 256 | +--+-------------------+-------+----------------------------------------------+ |
| | 257 | |Al| ``OBJCINCS`` | 1-7 | | |
| | 258 | +--+-------------------+-------+----------------------------------------------+ |
| | 259 | |Al| ``RCINCS`` | 1-7 | | |
| | 260 | +--+-------------------+-------+----------------------------------------------+ |
| | 261 | |Al| ``SDKS`` | 1-7 | | |
| | 262 | +--+-------------------+-------+----------------------------------------------+ |
| | 263 | |Al| ``SOURCES`` | 1-9 | | |
| | 264 | +--+-------------------+-------+----------------------------------------------+ |
| | 265 | |Al| ``SRC_HANDLERS`` | 1-7 | | |
| | 266 | +--+-------------------+-------+----------------------------------------------+ |
| | 267 | |Al| ``USES`` | 1-7 | | |
| | 268 | +--+-------------------+-------+----------------------------------------------+ |
| | 269 | |
| | 270 | |
| | 271 | ----- |
| | 272 | |
| | 273 | .. [1] Normally not one of the default passes. |
| | 274 | |
| | 275 | ----- |
| | 276 | |
| | 277 | :Status: $Id: QuickReference-kBuild.txt 2345 2009-04-19 23:47:42Z bird $ |
| | 278 | :Copyright: Copyright (c) 2009 knut st. osmundsen |
| | 279 | |
| | 280 | }}} |