Skip to content

Porting the build to another compiler IDE

Maxime Vincent edited this page Jan 5, 2016 · 5 revisions

Use your compiler from our Makefile

As explained in Build process explained it is possible to use your compiler from our Makefile, as long as it is mostly compatible with the GNU tools' syntax. E.g. clang works just fine. However, if this is not an option, you can easily create your own picoTCP build. But you need to pay attention a few important details. See the next paragraph.

Bear in mind that some compilers have GNU compatibility modes:

  • ARM DS-5
  • ARMCC
  • Keil MDK-ARM

All have the --gnu option ARM Information Center

Create your custom build process

If you can't, or don't want to use picoTCP's original Makefile, you can easily integrate it into you current build system or IDE. There are a few details to pay attention to:

  • Generating pico_defines.h
  • Files to include
  • Compiler options

Generating pico_defines.h

This file is normally auto-generated, and contains all the options that picoTCP was configured with. It is important when compiling picoTCP objects/modules, but also when using the library in your applications. E.g. the size of structs can change, depending on which modules are enabled. If you are not using our Makefile, you should generate a pico_defines.h file manually.

A minimal version could look like this:

/* PicoTCP - Definition file */
#ifndef PICO_DEFINES_H
#define PICO_DEFINES_H

#define PICO_SUPPORT_ETH
#define PICO_SUPPORT_IPV4
#define PICO_SUPPORT_UDP

#endif

Files to include (mandatory)

A bunch of files are mandatory for the picoTCP core. These are located in stack/*.

From our Makefile, you can file these are the files:

CORE_OBJ= stack/pico_stack.o \
          stack/pico_frame.o \
          stack/pico_device.o \
          stack/pico_protocol.o \
          stack/pico_socket.o \
          stack/pico_socket_multicast.o \
          stack/pico_tree.o \
          stack/pico_md5.o

Files to include (optional)

Again, depending on which modules you will be using, and you have enabled, certain files must or must not be included in the build. Some files have portions under IFDEF, to account for options that are enabled/disabled.

Normally, there is a logical link between the name of the module, and the name of the files to be included. If you are not sure, you can check the Makefile or the makefiles in rules/ to see which files are conditionally included.

An example for UDP (rules/udp.mk):

OPTIONS+=-DPICO_SUPPORT_UDP
MOD_OBJ+=$(LIBBASE)modules/pico_udp.o
MOD_OBJ+=$(LIBBASE)modules/pico_socket_udp.o

Or directly from the Makefile (TFTP):

ifeq ($(TFTP),1)
  MOD_OBJ+=$(LIBBASE)modules/pico_strings.o $(LIBBASE)modules/pico_tftp.o
  OPTIONS+=-DPICO_SUPPORT_TFTP
endif

Compiler options

When using a compiler that does not understand the GCC syntax, you will need to adapt the options used for our build, to you compiler.

These are the CFLAGS we use by default:

CFLAGS:= -I$(PREFIX)/include -Iinclude -Imodules 
CFLAGS+= -Wall -Wdeclaration-after-statement -W -Wextra -Wshadow -Wcast-qual 
CFLAGS+= -Wwrite-strings -Wunused-variable -Wundef -Wunused-function
CFLAGS+= -Wconversion Wcast-align -Wmissing-prototypes -Wno-missing-field-initializers

The first are the include paths used for building the picoTCP library; these should be easy to include in your own compiler/IDE. The other flags are mostly to have strict warnings when things are going wrong. We strongly advice to translate these to the equivalent for your compiler.

Platform specific flags

And then of course there are platform specific CFLAGS, depending on the selected ARCH. For example, the PIC24 needs these options:

ifeq ($(ARCH),pic24)
  CFLAGS+=-DPIC24 -c -mcpu=24FJ256GA106  -MMD -MF -g -omf=elf \
  -mlarge-code -mlarge-data -msmart-io=1 -msfr-warn=off
endif
Clone this wiki locally