Skip to content

Build process explained

Daniele Lacamera edited this page Jan 6, 2016 · 11 revisions

Overview

The official build process for picoTCP is a Makefile. This section will explain how this works, how modules are enabled or disabled, how a specific compiler or architecture is chosen.

Native build (e.g. under Linux)

make

This is the default build process. A static picoTCP library will be built, using the default configuration. It makes use of configurable variables, which will be explained later.

What will happen is this:

  1. Compile selected picoTCP modules (mod target in Makefile)
  2. Compile picoTCP core (core target in Makefile)
  3. Archive all objects into a static library (lib target in Makefile)

The build process will make use of the GNU compiler tools (gcc, ranlib ...). This will result in a library, found in $(PREFIX)/lib/, called $(LIBNAME)

  • PREFIX is 'build' by default
  • LIBNAME is libpicotcp.a by default

The generated library can be statically linked together with your picoTCP application, on your host machine (be that 32 or 64bit Linux, OSX or Windows). You application should use the include files generated and copied to the PREFIX directory.

Configuring the build

The most useful build options are set using Makefile variables, which can also be edited using environment variables.

E.g. if you want to change the PREFIX, previously mentioned, you can invoke make like this:

PREFIX=myprefix make

Other build options are explained below.

Cross-compiling with GCC

CROSS_COMPILE is a variable that will be prepended to all the GNU compiler tools (gcc, as, ld, ranlib ...)

Running make like this:

CROSS_COMPILE=arm-none-eabi- make

Will therefor call:

  • arm-none-eabi-gcc
  • arm-none-eabi-ranlib
  • etc ...

Selecting an architecture

CROSS_COMPILE=arm-none-eabi ARCH=cortexm3 make

To select a different architecture, the ARCH variable has to be set. ARCH has to be defined in:

  • the Makefile, if there are any special compiler flags needed for this architecture
  • include/pico_config.h, to include the right port header files (include/arch/*).

Porting to a new architecture or target is easy, and is explained in [Porting picoTCP to your favorite embedded target] (Porting-picoTCP-HW)

Selecting modules

Modules can be configured by setting variables to 0 or 1.

E.g.:

IPV4=1 IPV6=1 TCP=1 UDP=1 IPFILTER=0 DHCP_SERVER=0 make

Be aware that there might be dependencies between modules; e.g. you cannot use IPV4FRAG without enabling IPV4. For a complete list of modules, please see [Configuring and compiling] (Configuring-and-compiling)

Selecting a different compiler

If you just want to swap GCC for another compiler, accepting the same format of arguments, you can do that by replacing the CC variable defined in the Makefile, by your own compiler.

E.g. to replace GCC with Clang:

CC:=$(CROSS_COMPILE)clang

However, if your compiler is not compatible with GCC syntax, you can do two things:

Clone this wiki locally