build control
DESCRIPTION
Overview of the Build ProcessTRANSCRIPT
-
Copyright 2002 Dept. of Computer Science and Engineering, Washington University
CS 342: Build Control
Overview of the Build Process Make
reads Makefile Targets, Macros, Rules
invokes compiler and linker
Compiler Invokes preprocessor Parses result Produces object files
Linker Links references within
object files Produces executable
make
.cc.cc.cc
Makefile
preprocessor
.cc.cc.cc.cc.cc.h
linker.cc.cc.ocompiler
executableobject files
processedsource files
source files
-
Copyright 2002 Dept. of Computer Science and Engineering, Washington University
CS 342: Build Control
The make Utility Controls the build process
Enforces dependencies If something changes, update what depends on it (e.g.,
object files depend on header and body files)
Relies on file update times Can touch a file to set its time stamp to now
touch Calculator.cc
Builds targets First one declared in Makefile is the default
Usually want this to build the executable file
Can build other targets: e.g., make clean
-
Copyright 2002 Dept. of Computer Science and Engineering, Washington University
CS 342: Build Control
Example MakefileCMPL_SRCS = main.cc Calculator.cc Trace.cc
EXECUTABLE = calc_test
OBJS = $(CMPL_SRCS:.cc=.o)
$(EXECUTABLE): $(OBJS)
g++ -o $(EXECUTABLE) -Wall -W -g -DUNIX $(OBJS)
clean:
-rm -f $(OBJS) core *.bak *~
.cpp.o:
$(COMPILE.cc) -Wall -W -g -DUNIX $(OUTPUT_OPTION) $