Created
April 29, 2020 09:38
-
-
Save quocle108/d006758d5ca939c5bacda676af3b5e90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Specify the target file and the install directory | |
OUTPUTFILE=hello | |
INSTALLDIR=binaries | |
# Default target | |
.PHONY: all | |
all: $(OUTPUTFILE) | |
# This rule tells make how to build hello from hello.cpp | |
#OUTPUTFILE: helloworld.cpp | |
# g++ -o hello hello.cpp | |
# we also can use automatic variables | |
# the variable $< represents the filename of the first prerequisite, and the variable $^ represents the sequence of prerequisites, separated by spaces | |
# https://www.gnu.org/software/make/manual/make.html#Automatic-Variables | |
$(OUTPUTFILE): helloworld.cpp | |
g++ -o $@ $< | |
# Copy hello to the binaries subdirectory | |
.PHONY: install | |
install: | |
mkdir -p $(INSTALLDIR) | |
cp -p $(OUTPUTFILE) $(INSTALLDIR) | |
# Delete hello | |
.PHONY: clean | |
clean: | |
rm -f $(OUTPUTFILE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment