Set Some Variables
Now that we have a base framework file, rules.mk, we can start declaring some variables we will need for common automation tasks later. Since the Makefile or build script is required to set the TOP variable, most path variables will be based on the TOP variable.
# The WORKDIR is the root of all output files. WORKDIR?=$(TOP)/work # The OBJDIR contains C/C++ object files. OBJDIR?=$(WORKDIR)/obj # The GENDIR contains all generated files. GENDIR?=$(WORKDIR)/gen # The GENSOURCEDIR contains all generated source files. GENSOURCEDIR?=$(GENDIR)/src # The TESTDIR contains executables for C++ unit tests. TESTDIR?=$(WORKDIR)/test # This DISTDIR contains the final distribution image. Just about everything # except intermediate objects and test files will go somewhere under DISTDIR. DISTDIR?=$(TOP)/dist # The LIBDIR contains all build library files. LIBDIR?=$(DISTDIR)/lib # The BINDIR contains all built binary executable files. BINDIR?=$(DISTDIR)/bin # The SHRDIR contains all built shared libraries. Note that the SHRDIR is # different between Windows and non-Windows platforms. SHRDIR?=$(if $(ISWINDOWS),$(BINDIR),$(LIBDIR)) # The DOCDIR contains all DOCDIR?=$(DISTDIR)/share/doc # Common tools. MKDIR=mkdir -p RM=rm -rf CP=cp
If you were paying attention, you may have noticed the yet undefined ISWINDOWS variable. Looks like it’s time to move on to OS identification.