We have packaged a variety of functions in to the same couplet of makefile fragments that you parameterize and extend to create modules, libraries, interfaces, and manage a hierarchical directory structure. The first fragment, installed as $UTILS_DIR/include/maketools/MakeDefs sets up some basic definitions, and the second, $UTILS_DIR/include/maketools/MakeTail actually takes the parameterizations you provide and fill out the various makefile functions. Caution: as is true with most sophisticated make systems, actually examining these fragments in detail might cause your head to explode.
The magical makefiles provide a set of standard targets:
all - the default, make all standard targets in this directory and any subdirectories
install - make the standard targets and install what is necessary from this directory and any subdirectories
clean - clean up most everything in this directory
cleanall - clean up most everything in this directory and any subdirectories
cleaner - try to be even more thorough about cleaning this directory
uninstall - try to reverse the effects of an install
The magical makefile system has a variety of parameters you can set which affect things across a wide variety usages.
UTILS_DIR - root directory where we will look for things. Usually defined as an environment variable, not in the Makefile.
INSTALL_DIR - root directory where we will install things we build. Usually defined as an environment variable, not in the Makefile.
SRC_MODULE - the root name of what we are compiling. When building a library, it will be lib$(SRC_MODULE).so. When installing header files they will go in include/$(SRC_MODULE). When building a reconfigurable interface library, the base name will be $(SRC_MODULE).
HEADERS - install the list of include files (e.g., .h files) in $(INSTALL_DIR)/include/$(SRC_MODULE) with the install target.
SUBDIRS - the list of subdirectories managed by this makefile (i.e., where the makefile will go on install, cleanall targets, etc).
EXTRA_INC_DIRS - list of -I flags to pass to the compiler to tell it where to look for header files other than $(UTILS_DIR)/include and $(INSTALL_DIR)/include.
EXTRA_OPTS - extra optimization flags for object compilation
EXTRA_DEFS - extra preprocessor definitions for object compilation
EXTRA_BUILDS - extra generic makefile targets to add when performing the all target.
EXTRA_INSTALLS - extra executables to be build in the all target and installed in $(INSTALL_DIR)/bin as a result of the install target.
EXTRA_UNINSTALLS - extra targets to invoke when doing an uninstall
EXTRA_DEPENDS - extra object files that we need to build dependencies for outside of the normal library or module objects. For example, if you have "extra" executables built from "extra" source files, you will want to list the objects built from these "extra" source files so that the header file dependencies will be extracted from the "extra" source files so that these "extra" executables get recompiled and relinked appropriately when relevant header files included by the "extra" source files are changed.
NO_MKFILE - if this parameter is set to anything, do not install $(SRC_MODULE).mk into $(INSTALL_DIR)/include/$(SRC_MODULE).mk. This can be very useful when you are building a set of reconfigurable interface extensions and you need to install header files in $(INSTALL_DIR)/include/$(SRC_MODULE), so you have to define SRC_MODULE to be the name of the reconfigurable interface library, but you do not want to overwrite $(INSTALL_DIR)/include/$(SRC_MODULE)/$(SRC_MODULE).mk.
If you set the variable TARGET, then it is assumed you will be building an executable module. The following parameters then come into play:
TARGET - the name of the executable we will be building and installing in $(INSTALL_DIR)/bin
TARGET_OBJS - object files we will compile and link into the target.
EXTRA_TARGET_OBJS - object files we will link into the target without compilation.
TARGET_LIBS - This is a list of locally built (within the code tree) libraries, each preceeded by the normal library flag (-l), needed to build the target module. For each -lLibraryName, the makefile will include $(INSTALL_DIR)/include/LibraryName/LibraryName.mk. Any necessary libraries and supporting libraries needed to link with the target as specified by these helper makefile fragments will automatically be linked in with the target.
EXTRA_TARGET_LIBS - A list of real libraries to be linked in with the target in addition to any libraries specified or derived from the TARGET_LIBS line.
If you set the variables OBJS or EXTRA_OBJS to be lists of object files, these object files will be linked together into a dynamically loadable library named lib$(SRC_MODULE).so that will be installed into $(INSTALL_DIR)/lib
OBJS - List of objects to be compiled from source and linked together into the output library.
EXTRA_OBJS - List of extra object files which will be linked (but not compiled) together into the output library.
SUPPORT_LIBS - This is a list of locally built (within the code tree) libraries, each preceeded by the normal library flag (-l), needed to support programs linking with the target library. For each -lLibraryName, the makefile will include $(INSTALL_DIR)/include/LibraryName/LibraryName.mk. Any necessary libraries and supporting libraries referenced by the result library will be linked in with the generated library so all you should have to reference to use this library is the generated shared library itself.
EXTRA_SUPPORT_LIBS - A list of real libraries to be linked in with the output library in addition to any libraries specified or derived from the SUPPORT_LIBS line.
If you set the variable INTERFACE_DEST then it is assumed you will be building a reconfigurable interface.
INTERFACE_DEST - The directory where the plug-ins will be installed. This directory will be created if necessary
INTF_OBJS - The list of object files that will go into all of the plug-ins. These are mostly included to make sure all the header file dependencies are generated properly.
In addition two macros are defined to help define rules for reconfigurable interface plug-ins
MAKE_INTF - build the plug-in defined by the output of the rule ($@) from all of the elements on the dependency line ($\^) and link in the local library (lib$(SRC_MODULE).so). You can add extra libraries on the end of the macro in the rule.
MAKE_INTF_EXTERNAL - build the plug-in defined by the output of the rule ($@) from all of the elements on the dependency line ($\^) and don't link in the local library. You will add extra libraries on the end of the macro in the rule.
Generated on Fri Jun 16 13:21:26 2006 for ModUtils by
1.4.4