buildsys/gmake

Daniel Adler January 23, 2013

1 Introduction

The GNU Make-based build system of dyncall was one of the first build systems that we have developed side-by-side with the dyncall release. This document gives details on the configuration and build .

Note The number of supported build tools for dyncall has grown. In partic- ular the plain Makefile.embedded make files work across GNU,BSD and SUN make tools (see README.Embedded) and the CMake-based (see README.CMake) are recommented because of simplicty and portability.

2 Usage 2.1 Configuring the project Before building a project, one has to configure the project.

./configure .\configure.bat The configure script creates a top-level ConfigVars that specifies a list of CONIFG * variables. Here’s a sample ConfigVars file: CONFIG_OS=windows CONFIG_ARCH= CONFIG_TOOL=gcc BUILD_ASM=as INSTALL_DIR=/usr/local

2.2 Building the project Type gmake or make1 on the .

1some platforms use a different Make tool which is accessible as make from the command- line. Platforms that need to use gmake are: Solaris and many BSD platforms.

1 2.3 Phony targets The following targets refer to top-level tasks and should be usable from within the command via make . Target Description ”default” Default rule, depends on build ”dirs” Traverse sub-directories ”build” Build project, depends on dirs ”install” Install project, depends on build and dirs ”clean” Clean project, depends on dirs

2.4 Creating new build task Create a task folder with sources that include the file GNUmakefile. Specify the variable TOP that gives the relative path to the top-level project directory which contains the buildsys folder (in which buildsys/gmake lives in). Your project settings are embedded between two includes, namely the prolog and the epilog files.

# Sample GNUmakefile for buildsys/gmake TOP = ../.. include $(TOP)/buildsys/gmake/prolog.gmake # ... project directory settings goes here ... include $(TOP)/buildsys/gmake/epilog.gmake

2 3 Configuration variables 3.1 BUILD OS Specifies the target or embedded run-time platform: Value Description ”android” Google Android ” ”cygwin” Cygwin on Microsoft Windows ”darwin” Apple Mac OS X/iOS ”dragonfly” DragonFly BSD ”” FreeBSD or GNU/kFreeBSD ”iphoneos” iPhone OS ”linux” Linux ”macosx” Mac OS X ”minix” Minix ”msys” MinGW on Microsoft Windows ”nds” Nintendo DS ”netbsd” NetBSD ”openbsd” OpenBSD ”psp” Playstation Portable Homebrew SDK ”sunos” SunOS ”windows” Microsoft Windows

3.2 BUILD ARCH Specifies the processor architecture: Value Description ”arm” ARM ”arm32” ARM 32-bit ”arm32 arm” ARM 32-bit ARM ISA ”arm32 thumb” ARM 32-bit Thumb ISA ”ia64” Itanium ”mips32” MIPS 32-bit ”mips32el” MIPS 32-bit (Little-Endian) ”mips64el” MIPS 64-bit (Little-Endian) ”ppc32” PowerPC 32-bit ”ppc64” PowerPC 64-bit ”” SPARC 32-bit ”sparc64” SPARC 64-bit ”universal” Mac OS X Universal Binaries ”x86” X86 32-bit ”x64” X86 64-bit

3.3 BUILD TOOL Specifies the build tool chain:

3 Value Description ”androidndk” Android NDK ”llvm gcc” LLVM with GCC Front-end ”gcc” GNU Collection ”pcc” Portable C Compiler ”msvc” Microsoft Visual C++ (windows) ”pspsdk” Playstation Portable Homebrew SDK

3.4 BUILD ASM Specifies the assembler tool: Value Description ”as” GNU Assembler ”nasm” NASM Assembler (x86/x64) ”ml” Micrsoft Macro Assembler (x86/x64)

3.5 Others Variable name Description BUILD CONFIG Build configuration (”release”, ”debug”) INSTALL PREFIX Installation prefix directory

4 Predefined variables Variable name Description GMAKE TOP Relative path to folder buildsys/gmake BUILD DIR Build directory (e.g. ”out----”) OS-specific APP SUFFIX Application suffix LIB SUFFIX Static library suffix DLL SUFFIX Dynamic linked library suffix Tool-specific LIB PREFIX Static library prefix OBJ SUFFIX Object file suffix All suffixes should include the ”.” (dot) .

4 5 Project variables

Variable name Description TOP Relative path to top directory DIRS Sub-project directory names UNITS List of units to link for target targets TARGET APP Build application name TARGET LIB Build static library name TARGET DLL Build dynamic library name TARGET PDF Build PDF manual (sources in latex) build related ASFLAGS Assembler flags CPPFLAGS C Preprocessor flags CFLAGS C Compiler flags CXXFLAGS C++ Compiler flags LINK Application linker: ”c”, ”c++” or empty (default linker) LINK PATHS List of library paths LINK LIBS List of library names CXX EXCEPTIONS If set to ”1”, use C++ Exceptions CXX RTTI If set to ”1”, use C++ Run-time Type Information installation related INSTALL APP If set to ”1”, install executable to bin install-directory INSTALL LIB If set to ”1”, install library to lib install-directory INSTALL HEADERS List of header files to copy to include install-directory

5 6 Inclusion order

1. prolog.gmake • Set GMAKE TOP variable • Define ”default” rule • Include ConfigVars • Define build value variables (BUILD * * variables) • Define BUILD DIR variable and a mkdir rule. 2. epilog.gmake

• Include os/$(BUILD OS).gmake • If BUILD ASM nasm is defined then include tool/nasm.gmake • Include tool/latex.gmake • Include targets.gmake

The os-specific gmake files will typically include tool/$(BUILD TOOL).gmake file. The tool-specific gmake file will typically include configuration specific files driven by the BUILD CONFIG define. Other more-specific platforms such as psp and nds might preclude and append additional information depending on platform and tool quirks.

7 OS notes windows gcc and msvc tool-chain support psp gcc only

6