Fall 2019 CSCE-221 Data Structures and Algorithms

Lab Sections 501 - 504


Makefile


Check eCampus for lab slides.

Rules:

<target>: <Dependency list>
<tab><command>

Here's a sample Makefile

output.out: driver.o Airplane.o
	g++ -Wall -std=c++11 driver.o Airplane.o -o output.out
driver.o: driver.cpp Airplane.h
	g++ -Wall -std=c++11 -c driver.cpp
Airplane.o: Airplane.cpp Airplane.h
	g++ -Wall -std=c++11 -c Airplane.cpp

clean:
	rm *.o
	rm output.out

run:
	./output.out

Notes:

  1. The filename should be exactly Makefile, no extention name like .txt. The filename is case sensitive.
  2. Your output executable target should match the name of the -o option for our simple examples. Or the checking of "up to date" may fail.
  3. Be care with the clean and run tags, your code should precisely delete or run your output binary file.

Resources

https://wiki.cse.tamu.edu/index.php/Makefiles_C_C++

https://www.gnu.org/software/make/manual/html_node/Simple-Makefile.html#Simple-Makefile