guides:software:make:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
guides:software:make:start [2020/07/20 17:30] – [Makefiles for Multiple File Compilation] wikiadmin | guides:software:make:start [2024/07/25 15:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
Make is a build automation tool that is designed to automatically construct executable programs from source code. | Make is a build automation tool that is designed to automatically construct executable programs from source code. | ||
+ | |||
+ | Make simplifies the build process for projects at all levels. | ||
===== Simple Use ===== | ===== Simple Use ===== | ||
Line 291: | Line 293: | ||
One of the most powerful uses of make is to compile multiple files into a single executable. | One of the most powerful uses of make is to compile multiple files into a single executable. | ||
+ | |||
+ | ==== Example ==== | ||
For this example the code is decomposed into the following files: | For this example the code is decomposed into the following files: | ||
Line 379: | Line 383: | ||
OBJS = hello | OBJS = hello | ||
- | .PHONY: all | ||
all: ${OBJS} | all: ${OBJS} | ||
Line 388: | Line 391: | ||
stringTools.o: | stringTools.o: | ||
- | .PHONY: clean | ||
clean: | clean: | ||
rm -f ${OBJS} *.o | rm -f ${OBJS} *.o | ||
Line 416: | Line 418: | ||
</ | </ | ||
- | Note that all components are compiled and the final executable is produced. | + | Note that all components are compiled and the final executable is produced. |
+ | |||
+ | < | ||
+ | $ touch greeting.cpp | ||
+ | $ make | ||
+ | g++ -g -O3 -Wpedantic -Wall -Wextra -Wmisleading-indentation -Wunused -Wuninitialized -Wshadow -Wconversion -std=c++14 | ||
+ | g++ -g -O3 -Wpedantic -Wall -Wextra -Wmisleading-indentation -Wunused -Wuninitialized -Wshadow -Wconversion -std=c++14 | ||
+ | </ | ||
+ | |||
+ | ==== The Makefile ==== | ||
+ | |||
+ | In order to build this project using make, you need to inform make of the dependencies built into the project. | ||
+ | |||
+ | <code make> | ||
+ | hello: | ||
+ | </ | ||
+ | |||
+ | You do not need to tell make that //hello// depends on // | ||
+ | |||
+ | You also do not need to tell make that //hello// depends on // | ||
+ | |||
+ | <code make> | ||
+ | stringTools.o: | ||
+ | </ | ||
+ | |||
+ | This line tells make that // | ||
+ | |||
+ | <code make> | ||
+ | greeting.o: greeting.h stringTools.h | ||
+ | </ | ||
+ | |||
+ | This line tells make that // |
guides/software/make/start.1595266248.txt.gz · Last modified: 2024/07/25 15:01 (external edit)