35 lines
596 B
Makefile
35 lines
596 B
Makefile
# Syntax
|
|
# <target>: <dependencies>
|
|
# <command>
|
|
# ...
|
|
|
|
# variables
|
|
CXX = g++
|
|
CXXFLAGS = -Wall -std=c++11
|
|
|
|
# standard rule
|
|
all: main
|
|
|
|
# creating main from main.o and hello_world.a
|
|
# $@ = target
|
|
# $^ = dependencies
|
|
main: main.o hello_world.a
|
|
$(CXX) $(CXXFLAGS) -o $@ $^
|
|
|
|
# creating archive out of object
|
|
# % = filename without ending
|
|
# $@ = target
|
|
# $^ = dependencies
|
|
%.a: %.o
|
|
ar rcs $@ $^
|
|
|
|
# creating object out of cpp
|
|
# % = filename without ending
|
|
# $@ = target
|
|
# $^ = dependencies
|
|
%.o: %.cpp
|
|
$(CXX) $(CXXFLAGS) -c -o $@ $^
|
|
|
|
# remove all objects and archives
|
|
clean:
|
|
rm -f *.o *.a main
|