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}.
113 @anchor{terminal.targets.general}
114 @subsection General Modules
116 General modules such as @samp{libhb}, @samp{test} and @samp{gtk} have the following scoped targets:
119 @item make @i{MODULE}.build
122 @item make @i{MODULE}.clean
123 Clean build output for @i{MODULE}.
126 @anchor{terminal.targets.contrib}
127 @subsection Contrib Modules
129 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:
132 @item make @i{MODULE}.fetch
133 Download source tarball from the Internet and save to @file{TOP/downloads} directory. No checksumming is performed.
135 @item make @i{MODULE}.extract
136 Extract source tarball into @file{build} tree.
138 @item make @i{MODULE}.patch
139 Apply appropriate patches (if any) to module sources.
141 @item make @i{MODULE}.configure
142 Configure module sources.
143 This usually invokes autotool configure.
145 @item make @i{MODULE}.build
147 This usually invokes autotool build.
149 @item make @i{MODULE}.install
150 Install module products such as headers and libraries into @file{build} tree.
151 This usually invokes autotool install.
153 @item make @i{MODULE}.uninstall
154 Uninstall module products; generally the reverse of install.
155 This usually invokes autotool uninstall.
157 @item make @i{MODULE}.clean
158 Clean module; generally the reverse of build.
159 This usually invokes autotool clean.
161 @item make @i{MODULE}.xclean
162 Extra clean module; first invokes uninstall then recursively removes the module build directory.
165 @anchor{terminal.targets.contrib.aggregate}
166 @subsection Contrib Aggregates
168 For convenience, the following targets aggregate the all contrib modules' respective targets together:
171 @item make contrib.fetch
172 @item make contrib.extract
173 @item make contrib.patch
174 @item make contrib.configure
175 @item make contrib.build
176 @item make contrib.install
177 @item make contrib.uninstall
178 @item make contrib.clean
179 @item make contrib.xclean
182 @c %**-------------------------------------------------------------------------
183 @anchor{terminal.customizing}
184 @section Customizing Make
185 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:
188 ## bump to gcc-4.2 in current path
191 ## replace optimize for 'speed' with more agressive settings
192 GCC.args.O.speed = -O3 -fomit-frame-pointer -msse4.2