/
gmake-manual.tex
252 lines (205 loc) · 7.69 KB
/
gmake-manual.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
%//////////////////////////////////////////////////////////////////////////////
%
% Copyright (c) 2007,2009 Daniel Adler <dadler@uni-goettingen.de>,
% Tassilo Philipp <tphilipp@potion-studios.com>
%
% Permission to use, copy, modify, and distribute this software for any
% purpose with or without fee is hereby granted, provided that the above
% copyright notice and this permission notice appear in all copies.
%
% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
%
%//////////////////////////////////////////////////////////////////////////////
\documentclass{article}
\newcommand{\var}[1]{{\tt #1}}
\newcommand{\val}[1]{"{\tt #1}"}
\newcommand{\file}[1]{{\tt #1}}
\begin{document}
\title{buildsys/gmake}
\author{Daniel Adler}
\maketitle
\section{Usage}
\subsection{Configuring the project}
Before building a project, one has to configure the project.
\begin{verbatim}
./configure
.\configure.bat
\end{verbatim}
The configure script creates a top-level \file{ConfigVars} that
specifies a list of \var{CONIFG\_*} variables.
Here's a sample \file{ConfigVars} file:
\begin{verbatim}
CONFIG_OS=windows
CONFIG_ARCH=x86
CONFIG_TOOL=gcc
BUILD_ASM=as
INSTALL_DIR=/usr/local
\end{verbatim}
\subsection{Building the project}
Type {\tt gmake} or {\tt make}\footnote{some platforms use a different Make tool which is accessible as
{\tt make} from the command-line. Platforms that need to use {\tt gmake} are: Solaris and all BSD platforms.} on the shell.
\subsection{Phony targets}
\begin{tabular}{ll}
Target & Description \\
\hline
\val{default} & Default rule, depends on build \\
\val{dirs} & Traverse sub-directories \\
\val{build} & Build project, depends on dirs \\
\val{install} & Install project, depends on build and dirs \\
\val{clean} & Clean project, depends on dirs \\
\end{tabular}
\subsection{Project directory setup}
Write up a \file{GNUmakefile} file in some project folder. Specify the
relative path to the top-level project directory which contains the \file{buildsys} folder
using the \var{TOP} variable. Your project settings are embedded between
two includes, namely the prolog and the epilog files.
\begin{verbatim}
# Sample GNUmakefile for buildsys/gmake
TOP = ../..
include $(TOP)/buildsys/gmake/prolog.gmake
# ... project directory settings goes here ...
include $(TOP)/buildsys/gmake/epilog.gmake
\end{verbatim}
\pagebreak
\section{Configuration variables}
\subsection{BUILD\_OS}
Specifies the target operating system or embedded run-time platform:
\begin{tabular}{ll}
Value & Description \\
\hline
\val{windows} & Microsoft Windows \\
\val{macosx} & Mac OS X \\
\val{iphoneos}& iPhone OS \\
\val{linux} & Linux \\
\val{sunos} & SunOS \\
\val{freebsd} & FreeBSD \\
\val{openbsd} & OpenBSD \\
\val{netbsd} & NetBSD \\
\val{psp} & Playstation Portable \\
\val{nds} & Nintendo DS \\
\end{tabular}
\subsection{BUILD\_ARCH}
Specifies the processor architecture:
\begin{tabular}{ll}
Value & Description \\
\hline
\val{x86} & X86 32-bit Architecture \\
\val{x64} & X86 64-bit Architecture \\
\val{ppc32} & PowerPC 32-bit Architecture \\
\val{arm32} & ARM32 Architecture \\
\val{mips32} & MIPS 32-bit Architecture \\
\end{tabular}
\subsection{BUILD\_TOOL}
Specifies the build tool chain:
\begin{tabular}{ll}
Value & Description \\
\hline
\val{gcc} & GNU Compiler Collection \\
\val{msvc} & Microsoft Visual C++ (windows) \\
\val{pspsdk} & Playstation Portable SDK \\
\val{llvm_gcc} & LLVM with GCC Front-end \\
\end{tabular}
\subsection{BUILD\_ASM}
Specifies the assembler tool:
\begin{tabular}{ll}
Value & Description \\
\hline
\val{as} & GNU Assembler \\
\val{nasm} & NASM Assembler (x86/x64) \\
\val{ml} & Micrsoft Macro Assembler (x86/x64)\\
\end{tabular}
\subsection{Others}
\begin{tabular}{ll}
Variable name & Description \\
\hline
\var{BUILD\_CONFIG} & Build configuration ("release", "debug") \\
\var{INSTALL\_PREFIX} & Installation prefix directory \\
\end{tabular}
\section{Predefined variables}
\begin{tabular}{ll}
Variable name & Description \\
\hline
\var{GMAKE\_TOP} & Relative path to folder \file{buildsys/gmake} \\
\var{BUILD\_DIR} & Build directory (e.g. "out-$<$os$>$-$<$arch$>$-$<$tool$>$-$<$config$>$")\\
\hline
& OS-specific \\
\hline
\var{APP\_SUFFIX} & Application suffix \\
\var{LIB\_SUFFIX} & Static library suffix \\
\var{DLL\_SUFFIX} & Dynamic linked library suffix \\
\hline
& Tool-specific \\
\hline
\var{LIB\_PREFIX} & Static library prefix \\
\var{OBJ\_SUFFIX} & Object file suffix \\
\end{tabular}
All suffixes should include the "." (dot) .
\section{Project variables}
\begin{tabular}{ll}
Variable name & Description \\
\hline
\var{TOP} & Relative path to top directory \\
\var{DIRS} & Sub-project directory names \\
\var{UNITS} & List of units to link for target \\
\hline
& targets \\
\hline
\var{TARGET\_APP} & Build application name \\
\var{TARGET\_LIB} & Build static library name \\
\var{TARGET\_DLL} & Build dynamic library name \\
\var{TARGET\_PDF} & Build PDF manual (sources in latex) \\
\hline
& build related \\
\hline
\var{ASFLAGS} & Assembler flags \\
\var{CPPFLAGS} & C Preprocessor flags \\
\var{CFLAGS} & C Compiler flags \\
\var{CXXFLAGS} & C++ Compiler flags \\
\var{LINK} & Application linker: \val{c}, \val{c++} or empty (default linker)\\
\var{LINK\_PATHS} & List of library paths \\
\var{LINK\_LIBS} & List of library names \\
\var{CXX\_EXCEPTIONS} & If set to \val{1}, use C++ Exceptions \\
\var{CXX\_RTTI} & If set to \val{1}, use C++ Run-time Type Information \\
\hline
& installation related \\
\hline
\var{INSTALL\_APP} & If set to \val{1}, install executable to bin install-directory \\
\var{INSTALL\_LIB} & If set to \val{1}, install library to lib install-directory \\
\var{INSTALL\_HEADERS} & List of header files to copy to include install-directory \\
\end{tabular}
\pagebreak
\section{Inclusion order}
\begin{enumerate}
\item \file{prolog.gmake}
\begin{itemize}
\item Set \var{GMAKE\_TOP} variable
\item Define \val{default} rule
\item Include \file{ConfigVars}
\item Define build value variables (\var{BUILD\_*\_*} variables)
\item Define \var{BUILD\_DIR} variable and a mkdir rule.
\end{itemize}
\item \file{epilog.gmake}
\begin{itemize}
\item Include \file{os/\$(\var{BUILD\_OS}).gmake}
\item If \var{BUILD\_ASM\_nasm} is defined then include \file{tool/nasm.gmake}
\item Include \file{tool/latex.gmake}
\item Include \file{targets.gmake}
\end{itemize}
\end{enumerate}
The os-specific gmake files will typically include
\file{tool/\$(\var{BUILD\_TOOL}).gmake} file.
The tool-specific gmake file will typically include configuration specific files driven by the \var{BUILD\_CONFIG} define.
Other more-specific platforms such as psp and nds might preclude and append additional information
depending on platform and tool quirks.
\section{OS notes}
\begin{description}
\item [windows] gcc and msvc tool-chain support
\item [psp] gcc only
\end{description}
\end{document}