Home Software Docs Tutorials Demos Databases Dictionaries Models Research Support Mailing Lists What's New
You are here: Standards / General / Tutorials / Software / Home  

 
  Make Files
black fading line


In our environment, there are two basic types of makefiles: one for compiling classes and one for compiling programs. The difference between the two is that the makefile for classes is used to compile objects into libraries whereas the makefile for programs is used to compile objects and libraries into executables. Rarely should you have need to write a makefile from scratch since all of our makefiles follow these specific templates. Simply copy one into your directory and change the appropriate settings as defined below. Note that calling make is done through and environment variable $ISIP_MAKE. This variable is set to the make utility we use and should be used instead of directly calling the make utility. See the section, Make options, for the targets for $ISIP_MAKE.

Makefiles for classes:

The makefile for a class is in a file named GNUmakefile and resides in the same directory as the rest of the class files. It follows the following structure.

   # file: class/io/sof/GNUmakefile
   #
   
   # source files
   #
   ISIP_FILES = *.cc
   
   # dependencies
   #
   ISIP_DEPS = sof.h sof_constants.h \
               sof_symbol.h sof_symbol_constants.h \
               sof_list.h sof_list_constants.h
   
   # compilation flags: optimize and debug
   # 
   ISIP_CFLAGS = -O -g
   
   # output library
   # 
   ISIP_OLIB = lib_math_io.a
   
   # make template
   #
   include $(ISIP)/scripts/make/compile.make
   
   #
   # end of file
A description of the various parts of the class makefile follows:
   # file: math/io/sof/GNUmakefile
   # this make file builds the object files using GNU make
   # the isip make template
This gives the filename and path of the makefile. Every file in our environment (not just makefiles) has this type of header.

   # define the source files
   #
   ISIP_FILES = *.cc
This defines all of the files which should be compiled. This should always be set to *.cc indicating that all files with the extension .cc should be compiled.

   # define the files these source files depend on (usually include files)
   #
   ISIP_DEPS = sof.h sof_constants.h \
               sof_symbol.h sof_symbol_constants.h \
               sof_list.h sof_list_constants.h
This defines the dependencies for each source file. In other words if any of the files listed as dependencies changes, then all files which list it as a dependency should be re-compiled. Note that pathnames are not necessary: the pathname is automatically determined from the specified header file locations. This works closely with the
version control setup in that local copies of software are referenced before the system version.

   # compilation flags: optimize and debug
   # 
   ISIP_CFLAGS = -O -g
This defines the compiler flags. Adding a -O turns on optimization while a -g adds debugging information to the object code.

   # define the output library
   # 
   ISIP_OLIB = lib_math_io.a
This defines the name of the library to compile the code into. Compilation into libraries is caused by doing a "$ISIP_MAKE install." Again no pathname is specified, system builds automatically go into $ISIP/lib/$ISIP_BINARY/, local builds to $ISIP_WORK/lib/$ISIP_BINARY. For more information on local builds, view the version control documentation.

   # include the isip standard make template
   #
   include $(ISIP)/scripts/make/compile.make
This is the standard makefile used in our environment for compiling classes. It uses the variables set above to compile all of the code as desired.
   #
   # end of file
This signals the end of the makefile.

Makefiles for programs:

The makefile for a program is in a file named GNUmakefile and resides in the same directory as the rest of the program files. It follows the following structure.

   # file: GNUmakefile
   #
   # this make file builds the main driver program using GNU make and
   # the isip make template
   # 
   
   # define the source files
   #
   ISIP_FILES = *.cc
   
   # define the files these source files depend on (usually include files)
   #
   ISIP_DEPS = lk_idle.h
   
   # define the local include file path
   # 
   ISIP_IFLAGS = -I $(LINKON)/include
   
   # define the compilation flags: optimize
   # 
   ISIP_CFLAGS = -g
   
   # define additional include libraries
   #
   ISIP_LFLAGS_BEFORE = -L $(LINKON)/lib/$(ISIP_BINARY) -l_isip
   
   # define directory where binaries have to be dumped
   #
   ISIP_BIN = $(LINKON)/bin/$(ISIP_BINARY)
   
   # define the name of the executable file (*.exe)
   #
   ISIP_EXE = lk_idle.exe
   
   # include the isip standard make template
   #
   include $(LINKON)/scripts/compile_and_link.make
   
   #
   # end of file
A description of the various parts of the program makefile follows:
   # file: GNUmakefile
   #
   # this make file builds the main driver program using GNU make and
   # the isip make template
   # 
This gives the filename and path of the makefile. Every file in our environment (not just makefiles) has this type of header.

   # define the source files
   #
   ISIP_FILES = *.cc
This defines all of the files which should be compiled. This should always be set to *.cc indicating that all files with the extension .cc should be compiled.

   # define the files these source files depend on (usually include files)
   #
   ISIP_DEPS = lk_idle.h
This defines the dependencies for each source file. In other words if any of the files listed as dependencies changes, then all files which list it as a dependency should be re-compiled. Note that this is usually set the the header file for the program, but may contain additional dependencies such as libraries or external header files.

   # define the local include file path
   # 
   ISIP_IFLAGS = -I $(LINKON)/include
This tells the compiler where to look for header files which are referenced by angle brackets in the code. This is the primary include file path.

   # define the compilation flags: optimize
   # 
   ISIP_CFLAGS = -g
This defines the compiler flags. Adding a -O turns on optimization while a -g adds debugging information to the object code.

   # define additional include libraries
   #
   ISIP_LFLAGS_BEFORE = -L $(LINKON)/lib/$(ISIP_BINARY) -l_isip
The -L flag tells the compiler where to look for libraries that are required for compilation. The -l flag tells the compiler that the given library should be used for compilation. In this case the library included with the -l flag is lib_isip.a. Notice that the "lib" and ".a" are stripped when setting this.

   # define directory where binaries have to be dumped
   #
   ISIP_BIN = $(LINKON)/bin/$(ISIP_BINARY)
As stated, this defines the location to install the binary created.

   # define the name of the executable file (*.exe)
   #
   ISIP_EXE = lk_idle.exe
This defines the executable name. The extension for the executable is .exe. This will be stripped before the executable is installed.

   # include the isip standard make template
   #
   include $(LINKON)/scripts/compile_and_link.make
This is the standard makefile used in our environment for compiling and linking programs. It uses the variables set above to compile all of the code as desired.
   #
   # end of file
This signals the end of the makefile.

Make options:

The following options are valid make targets. Note that some only apply when using the compile_and_link.make script. Each target can be accessed by using a command of the form.

$ISIP_MAKE <target>
Possible values of target are:
  • all: makes all objects.

  • install: makes all objects, then either installs the library defined by ISIP_OLIB or installs the binary defined by ISIP_EXE into ISIP_BIN then removing the file extension.

  • link: makes all objects, then links all of the objects into an executable defined by ISIP_EXE. Note that this executable is not installed, it is simply deposited into the given directory.
    ***This target is only available when using compile_and_link.make.

  • clean: removes all object files associated with the program or class. If using compile_and_link.make this target also removes the local copy of the executable if it exists.

  • check: checks for the existence of the source files given by ISIP_FILES

   
   
    Help / Support / Site Map / Contact Us / ISIP Home