hsk-libs-dev  270
High Speed Karlsruhe XC878 library collection
The Project Makefile

The project Makefile offers access to all the UNIX command line facilities of the project. The file is written for the FreeBSD make, which is a descendant of PMake. Some convenience and elegance was sacrificed to make the Makefile GNU Make compatible.

Generating the Documentation

The Makefile can invoke Doxygen with the make targets html and pdf:

# make html pdf
Searching for include files...
Searching for example files...
Searching for images...
[...]

The html target creates the directories html/user/ and html/dev/, which contain the HTML version of this documentation.

The pdf target creates the directory pdf/ with the PDF versions of this documentation.

The targets create a Users' and a Developers' Manual. The first only includes documentation for public interfaces (i.e. headers). The second also includes the documentation of the implementation and some additional tidbits in this chapter that are only of interest when developing the libraries instead of building applications with them.

Dependencies

In order to build the documentation the following tools need to be installed on the system:

Building

The Makefile uses SDCC to build. This can be changed in the first lines of the Makefile. The default target build builds all the .c files. Each .c file containing a main() function will also be linked, resulting in a .hex file:

# make
sdcc -mmcs51 [...] -o bin.sdcc/hsk_adc/hsk_adc.rel -c src/hsk_adc/hsk_adc.c
sdcc -mmcs51 [...] -o bin.sdcc/hsk_boot/hsk_boot.rel -c src/hsk_boot/hsk_boot.c
sdcc -mmcs51 [...] -o bin.sdcc/hsk_can/hsk_can.rel -c src/hsk_can/hsk_can.c
sdcc -mmcs51 [...] -o bin.sdcc/hsk_wdt/hsk_wdt.rel -c src/hsk_wdt/hsk_wdt.c
sdcc -mmcs51 [...] -o bin.sdcc/hsk_icm7228/hsk_icm7228.rel -c src/hsk_icm7228/hsk_icm7228.c
sdcc -mmcs51 [...] -o bin.sdcc/hsk_isr/hsk_isr.rel -c src/hsk_isr/hsk_isr.c
sdcc -mmcs51 [...] -o bin.sdcc/hsk_pwc/hsk_pwc.rel -c src/hsk_pwc/hsk_pwc.c
sdcc -mmcs51 [...] -o bin.sdcc/hsk_pwm/hsk_pwm.rel -c src/hsk_pwm/hsk_pwm.c
sdcc -mmcs51 [...] -o bin.sdcc/hsk_timers/hsk_timer01.rel -c src/hsk_timers/hsk_timer01.c
sdcc -mmcs51 [...] -o bin.sdcc/hsk_flash/hsk_flash.rel -c src/hsk_flash/hsk_flash.c
sdcc -mmcs51 [...] -o bin.sdcc/main.rel -c src/main.c
sdcc -mmcs51 [...] -o bin.sdcc/main.hex bin.sdcc/hsk_timers/hsk_timer01.rel [...]

All compiler output is dumped into the bin.sdcc/ directory. All the .c files are built, independent of whether they are linked into a .hex file.

Implementation Details

The Makefile consits of three parts:

Building

The Makefile declares the target build first to make it the default target. None of the build targets are manually defined. Instead with every invocation of make the script scripts/build.sh is invoked to regenerate the file build.mk.

The build.sh script searches the source directory for .c files and runs scripts/depends.awk in -compile mode to generate a dependency tree.

In the next stage build.sh generates the build instructions for each .c file.

The last step is to create the linking instructions. For that the script searches for .c files that appear to contain a main() function. The scripts/depends.awk script in -link mode is used to determine all the libraries that have to be linked with each of the main() containing .c files.

Documentation

The targets doc and doc-private build the user and the developer documentation. The html target simply copies them to the html/ directory.

The pdf target copies the PDF versions of the manuals to pdf/, but first a PDF needs to be generated by running make in the doc/latex/ and doc-private/latex/ directories, which is done by the respective targets.

Clean

The clean-doc target removes the directory doc/, the clean-doc-private target removes the directory doc-private/ and the target clean-build removes the directory BUILDDIR, which defaults to bin.sdcc/.

The meta-target clean invokes all these targets.

Cygwin

Using a combination of native Binaries and Cygwin, the complete set of build and generator facilities can be used from Microsoft Windows.

The followin downloads are required:

Additionally to the defaults the following Cygwin packages have to be installed:

After the installation the PATH variable should reference SDCC and Cygwin:

cygwin_PATH.png
Cygwin and SDCC PATH environment

The libraries provide simple batch files to execute uVisionupdate.sh and call make. For ease of use the table of make targets is displayed:

cygwin_cygwin-make.png
Make and available targets in Cygwin