Building a Project
1. All code - libraries and programs using those libraries - resides under a single directory.
That location is defined with an environment variable, TOT. E.g. if that directory is /home/code, and you're using a tcsh shell, do: setenv TOT /home/code 2. All helper Makefiles reside under a single directory. That location is defined with an environment variable, MAKEFILES_DIR. E.g. if that directory is /home/code/makefiles, and you're using a tcsh shell, do: setenv MAKEFILES_DIR /home/code/makefiles 3. The code of a single project resides under a single directory under TOT, e.g. tinyproj project is in: TOT/tinyproj . 4. Common header files reside under a single directory, header. E.g. TOT/tinyproj/header . 5. A project contains one or more components - all of which reside under a single directory, src. E.g. TOT/tinyproj/src . 6. A project is built in a test directory: E.g. TOT/tinyproj/test 7. Each project component resides in its own directory. E.g. component xyz is under TOT/tinyproj/src/xyz . Component's top-level Makefile, obj.mk, source and header files reside there. obj.mk defines an object (a component): This is where the object's source files and directory are listed. This information is used while building this object, and to find its header files when building other objects and programs. A component that relies on other components, also includes those components' obj.mk files, so that their header files can be found. 8. Each project component has an accompanying test directory which is under the component's directory. E.g. TOT/tinyproj/src/xyz/test . Component test's top-level Makefile, prog.mk, source and header files reside there. prog.mk defines a program (an executable): This is where the program's source files and directory are listed. This information is used while building this program. A program that relies on other objects or components, also includes those corresponding obj.mk files, so that their header files can be found. 9. The top-level Makefile, that builds a component or its test, is called from the source directory. The corresponding built objects or program are placed in a build directory under the source directory. There can be multiple build directories, one for each build type: debug, release or profile. E.g. component xyz's object debug build directory is TOT/tinyproj/src/xyz/build/debug . Component xyz's test program release build directory is TOT/tinyproj/src/xyz/test/build/release . |
|