You are here: Standards / General / Tutorials / Software / Home | ||||||
| ||||||
Make Files 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. A description of the various parts of the class makefile follows:# 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 This gives the filename and path of the makefile. Every file in our environment (not just makefiles) has this type of header.# file: math/io/sof/GNUmakefile # this make file builds the object files using GNU make # the isip make template 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 source files # ISIP_FILES = *.cc 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.# 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 compiler flags. Adding a -O turns on optimization while a -g adds debugging information to the object code.# compilation flags: optimize and debug # ISIP_CFLAGS = -O -g 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.# define the output library # ISIP_OLIB = lib_math_io.a 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.# include the isip standard make template # include $(ISIP)/scripts/make/compile.make This signals the end of the makefile.# # end of file 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. 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 # # 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 This gives the filename and path of the makefile. Every file in our environment (not just makefiles) has this type of header.# file: GNUmakefile # # this make file builds the main driver program using GNU make and # the isip make template # 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 source files # ISIP_FILES = *.cc 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 files these source files depend on (usually include files) # ISIP_DEPS = lk_idle.h 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 local include file path # ISIP_IFLAGS = -I $(LINKON)/include This defines the compiler flags. Adding a -O turns on optimization while a -g adds debugging information to the object code.# define the compilation flags: optimize # ISIP_CFLAGS = -g 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 additional include libraries # ISIP_LFLAGS_BEFORE = -L $(LINKON)/lib/$(ISIP_BINARY) -l_isip As stated, this defines the location to install the binary created.# define directory where binaries have to be dumped # ISIP_BIN = $(LINKON)/bin/$(ISIP_BINARY) This defines the executable name. The extension for the executable is .exe. This will be stripped before the executable is installed.# define the name of the executable file (*.exe) # ISIP_EXE = lk_idle.exe 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.# include the isip standard make template # include $(LINKON)/scripts/compile_and_link.make This signals the end of the makefile.# # end of file 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. Possible values of target are:$ISIP_MAKE <target>
| ||||||
Help / Support / Site Map / Contact Us / ISIP Home |