include path question

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
Active Member
Posts: 50
Joined: Sat Feb 13, 2010 12:04 pm

include path question

Postby Matt » Sat Feb 20, 2010 1:41 pm


I have been playing around with the XC-2 firmware demo and cant seem to figure out how the compiler is referencing the includes for some other source files in upper and lower directories.
i.e. the webserver.xc references uip_server.h which is in a different directory.
Can someone please explain :-)
I have tried adding to the project using source located in a upper level directory in the same project and the compiler complains it can find the headers?


User avatar
Experienced Member
Posts: 104
Joined: Fri Dec 11, 2009 8:29 pm

Postby davelacey » Sat Feb 20, 2010 6:40 pm

The xc2 firmware project uses Makefiles to control the build. The Makefile at the top-level calls Makefiles in the build directory. The Makefile for the xc2 firmware is in build/xc2_firmware.

In this Makefile you will see:

Code: Select all

DEMO_SOURCE_DIRS = misc xc2_firmware xc2_firmware/config xc2_firmware/httpd \
                   xtcp_apps/mdns xc2_firmware/httpd/fsdata


These lines control which files are included for source compilation and what the include paths are. Every file within the SOURCE_DIRS directories are compiled. The directory names are relative to the src/ sub-directory (e.g. in this example every source file in src/misc will be compiled).

All the directories in the INCLUDE_DIRS list are added as include paths to the build. This explains why webserver.xc can include uip_server.h

So to add your own files, create a directory underneath src/ and then add that directory name into the Makefile.

Admittedly these Makefiles are not very well documented. This is something that will be improved in the near future (there is nothing specifically Xmos about them, however. They are just GNU Make makefiles).

It is also worth mentioning that the Makefiles are not part of the tools themselves but part of the xc2 firmware project. In general the XDE allow you to either have an eclipse managed project where eclipse takes every source file in the project and compiles it or a Makefile project where eclipse calls xmake to do the build and the project can specify how the build is done. This project is an example of the latter.

Who is online

Users browsing this forum: No registered users and 1 guest