next up previous contents
Next: Standard Macros Up: HEADAS Makefiles Previous: Introduction   Contents

Simplest case: A Makefile for a single task

Suppose one wishes to build a task called sample for the Swift mission from the files sample1.c and sample2.c. This task has a help file called sample.html, and a parameter file called sample.par. Furthermore, this task has a unit test in the form of a perl script named ut-sample, which produces a FITS file ut-sample.fits. The following Makefile would supply all the necessary targets and macros to make the task behave (build, install, clean, test, etc.) like all other HEADAS tasks:

# Component (mission) name. Developers need not change/delete this.
HD_COMPONENT_NAME	= swift

# Software release version number. Developers need not change/delete this.
HD_COMPONENT_VERS	=

# If this directory needs to build a task, list its name here.
HD_CTASK		= sample

# C language source files (.c) to use for the task.
HD_CTASK_SRC_c		= sample1.c sample2.c

# C flags to use in every compilation.
HD_CFLAGS		= ${HD_STD_CFLAGS}

# Library flags to use when linking C task.
HD_CLIBS		= ${HD_STD_CLIBS}

# Task(s) to be installed.
HD_INSTALL_TASKS	= ${HD_CTASK}

# Help file(s) to install.
HD_INSTALL_HELP		= ${HD_CTASK}.html

# Parameter file(s) to install.
HD_INSTALL_PFILES	= ${HD_CTASK}.par

# Perl unit test script(s) to install.
HD_TEST_PERL_SCRIPTS	= ut-sample

# Extra item(s) to remove during a clean or distclean.
HD_CLEAN		= ut-sample.fits

# Include the standard HEADAS Makefile to do the real work.
include ${HD_STD_MAKEFILE}

Note that, as in all UNIX Makefiles, macro definitions must start at the beginning of a line, with no whitespace of any kind before the macro name.

This Makefile will in effect provide the following targets, which will have the stated behaviors:

In general the best way to create a new Makefile for a directory is to copy a Makefile from the most similar example possible. This way, if there are component-specific features which are present in one component's Makefiles and not others, the new Makefile will remain as similar as possible to others in its same component group. In other words, when starting a new task for the SWIFT mission, start with another SWIFT task Makefile. For a new library for Hitomi, start with an existing Hitomi library Makefile, etc.


next up previous contents
Next: Standard Macros Up: HEADAS Makefiles Previous: Introduction   Contents
Bryan Irby 2018-06-27