Understanding the Make Utility: Automating Project Compilation and Management
The make utility is an essential command in Linux, designed to automate the compilation and management of projects by determining when files need recompilation based on changes. Governed by a makefile containing rules, targets, and commands, it simplifies complex builds. For instance, the clean target helps manage directories efficiently by removing specified object files. The use of variables and comments within makefiles enhances readability and maintainability. This tutorial serves as an introductory guide to harnessing make for effective project management.
Understanding the Make Utility: Automating Project Compilation and Management
E N D
Presentation Transcript
makefile M.A Doman
What is the make utility? • make is a standard linux command to automatically determine when parts of a large project require recompilation • Governed by a set of rules built in a makefile • # indicates comment line target: prerequisite list [TAB] construction command
make clean target • Used to clean up the directory • In makefile: Clean: rmlist the object files you want removed. \ continue on next line.
make: using variables and comments You can also use variables when writing makefiles. # Comment that will say I’m creating a variable for compiler CC = g++ # Comment for a set of option flags used for compilation CFLAGS = -c # Link final program final: main.odeck.obox.o $(CC) –o final main.odeck.obox.o #compile main main.o: main.cpp $(CC) $(CFLAGS) main.cpp
make: using variables and comments You can also use variables when writing makefiles. # Comments that help me remember what I’m doing #clean directory # -f ignores nonexistent files without prompt # -r removes directories and contents recursively clean: rm–fr *.o final
Makefile lab • Continue now with makefile lab
UNIX Tutorial The following comes from the site: UNIX Tutorial for Beginners By the University of Surrey
Files and Processes • Everything in UNIX is either a file or a process. • A process is an executing program identified by a unique PID (process identifier). • A file is a collection of data. They are created by users using text editors, running compilers etc.