2 @chapter Building via Terminal
4 @c %**-------------------------------------------------------------------------
5 @anchor{terminal.checkout}
6 @section Checkout Sources
7 @include building/method.checkout.texi
9 @c %**-------------------------------------------------------------------------
10 @anchor{terminal.configure}
12 Configure the build system.
21 Create a scratch directory which will contain all files created during the build process. The directory name is arbitrary but we recommend something simple and descriptive. One directory is required for each distinctly configured build. We name our directory @file{build} for example purposes.
23 The @command{configure} utility accepts many options. It is recommended that you specify @command{--help} for the complete list of options. The following options are also documented here:
27 List available options.
30 Specify destination directory for final product install.
31 This defaults to a reasonable platform-specific value.
34 Disable driving the build through Xcode. If this option is disabled only @command{HandBrakeCLI} will be produced and Xcode will not be invoked. @value{OS.osx} only.
37 Disable building the GTK GUI on applicable platforms such as @value{OS.linux}.
40 Select debug mode. Must be one of @samp{none}, @samp{min}, @samp{std}, @samp{max}.
41 This generally maps to gcc options @samp{-g0}, @samp{-g1}, @samp{-g2}, @samp{-g3}.
44 Select optimize mode. Must be one of @samp{none}, @samp{speed}, @samp{size}.
45 This generally maps to gcc options @samp{-g0}, @samp{-O0}, @samp{-O3}, @samp{-Os}.
48 Select build architecture. The available architectures vary by platform. Most platforms support exactly one architecture except @value{OS.osx} which has support for various universal binary architectures. The available choices are hard-coded per platform and no sanity checks for the required tools are performed.
51 Specify the @command{gcc} executable to use where @b{EXE} is the executable name which is either absolute or environment @samp{PATH} is searched accordingly.
54 Clean-room procedures dictate that when certain factors change, old builds should be scrapped and new builds configured. This is the main reason for requiring a scratch directory; to promote consistent, reliable and clean software builds. The following is a short list of some of the reasons why someone may choose to scrap an existing build:
57 @item configure with different options
58 @item subversion working dir is updated and you want configure to re-evaluate working dir metadata.
59 @item build corruption is suspected
62 There are generally two methods for scrapping a build. The @file{build} directory can be recusrively removed which has the effect of loosing your existing configuration but does guarantee no residuals are left behind. The other method is to ask the build system to perform an @command{make xclean}. This is known to work well but will leave empty directories behind. However, the configuration is left intact.
64 @c %**-------------------------------------------------------------------------
65 @anchor{terminal.build}
67 Build main product. All necessary dependencies are also built if required.
73 Parallel builds may optionally be enabled. Be aware that while a parallel build may save time on systems with additional cores, the output is often mixed, overlapped and sometimes even corrupted with binary characters. Thus if you experience a build issue, you should clean and redo the build in default serial mode to produce a readable log. The following command allows for up to 4 concurrent jobs via make:
79 @c %**-------------------------------------------------------------------------
80 @anchor{terminal.targets}
83 The build system supports passing many kinds of targets some of which become very useful in normal development cycles. The targets by convention are lower-case words passed to @command{make}. Global targets are one-word targets. Scoped targets are usually two-words seperated by a period.
85 @anchor{terminal.targets.global}
90 Alias for @samp{make build}.
93 Build main product. All necessary dependencies are also built if required.
96 Clean all build output excluding contrib modules. Configuration is retained.
99 Perform final product(s) install.
100 This will install build products to a standard directory or one specified via @command{configure --prefix} option.
103 Perform final product(s) uninstall.
104 This will uninstall any products which may have been previously installed.
107 Clean all build output including contrib modules. Configuration is retained.
110 Build auto-generated project documentation. Various articles are produced and may be found in @file{build/doc/articles}.
112 @item make report.help
113 Print list of available makefile vars report targets.
114 These reports detail var definitions and expanded values used by the build system.
115 @b{For experts only}.
117 @item make report.all
118 Convenience target which aggregates all reports.
119 @b{For experts only}.
122 @anchor{terminal.targets.general}
123 @subsection General Modules
125 General modules such as @samp{libhb}, @samp{test} and @samp{gtk} have the following scoped targets:
128 @item make @i{MODULE}.build
131 @item make @i{MODULE}.clean
132 Clean build output for @i{MODULE}.
135 @anchor{terminal.targets.contrib}
136 @subsection Contrib Modules
138 Contrib modules such as @samp{a52dec}, @samp{bzip2}, @samp{faac}, @samp{faad2}, @samp{ffmpeg}, @samp{lame}, @samp{libdca}, @samp{libdvdread}, @samp{libmkv}, @samp{libmp4v2}, @samp{libogg}, @samp{libsamplerate}, @samp{libtheora}, @samp{libvorbis}, @samp{mpeg2dec}, @samp{x264}, @samp{xvidcore} and @samp{zlib} have the following scoped targets:
141 @item make @i{MODULE}.fetch
142 Download source tarball from the Internet and save to @file{TOP/downloads} directory. No checksumming is performed.
144 @item make @i{MODULE}.extract
145 Extract source tarball into @file{build} tree.
147 @item make @i{MODULE}.patch
148 Apply appropriate patches (if any) to module sources.
150 @item make @i{MODULE}.configure
151 Configure module sources.
152 This usually invokes autotool configure.
154 @item make @i{MODULE}.build
156 This usually invokes autotool build.
158 @item make @i{MODULE}.install
159 Install module products such as headers and libraries into @file{build} tree.
160 This usually invokes autotool install.
162 @item make @i{MODULE}.uninstall
163 Uninstall module products; generally the reverse of install.
164 This usually invokes autotool uninstall.
166 @item make @i{MODULE}.clean
167 Clean module; generally the reverse of build.
168 This usually invokes autotool clean.
170 @item make @i{MODULE}.xclean
171 Extra clean module; first invokes uninstall then recursively removes the module build directory.
174 @anchor{terminal.targets.contrib.aggregate}
175 @subsection Contrib Aggregates
177 For convenience, the following targets aggregate the all contrib modules' respective targets together:
180 @item make contrib.fetch
181 @item make contrib.extract
182 @item make contrib.patch
183 @item make contrib.configure
184 @item make contrib.build
185 @item make contrib.install
186 @item make contrib.uninstall
187 @item make contrib.clean
188 @item make contrib.xclean
191 @c %**-------------------------------------------------------------------------
192 @anchor{terminal.customizing}
193 @section Customizing Make
194 If the need arises to override settings in the build system (essentially gnu-make variables) the recommended method is to create/edit the optional include file @file{build/GNUmakefile.custom} which sits adjacent to the top-level makefile. @b{Do not check this file into the respository}. The sole purpose is to allow a place to store local build settings for testing, tweaking, and experimenting with build configuration without losing your settings if @command{configure} is invoked; ie: @command{configure} would overwrite @file{GNUmakefile} and any customizations contained therein would be lost. Here is a short example of what the contents of @file{build/GNUmakefile.custom} might contain:
197 ## bump to gcc-4.2 in current path
200 ## replace optimize for 'speed' with more agressive settings
201 GCC.args.O.speed = -O3 -fomit-frame-pointer -msse4.2
204 See also @command{make report.help} which displays a set of reports used to dump makefile vars.