Makefile.test/02.variables/Makefile

40 lines
1.1 KiB
Makefile

# It apparently is a somewhat odd how vairables handle quotes and single quotes
# there is the whole documentation about differnces of "=" ":=" "?=" ..
# http://www.gnu.org/software/make/manual/make.html#Reading-Makefiles
VAR1="asdas gu"
VAR2=asdas agu
VAR3=asdas agu
# according to https://stackoverflow.com/a/649255/1711186 it is not possible to
# have newlines being part of a Makefile variable
# CORRECTION there should be indeed a wat to have "newlines" be stored in a
# makefile variable see GNU make docu https://www.gnu.org/software/make/manual/html_node/Multi_002dLine.html
VAR4='asdas \
agu'
FILE:=file
all: file1 file2 file3 file4
file1:
echo $(VAR1) > $@
file2:
echo $(VAR2) > $@
file3:
echo "$(VAR3)" > $@
file4:
echo "$(VAR4)" > $@
# Variables can be used for the target of recepies
$(FILE)-li:
touch $@
# bottom line the use of variables might feel a bit annoying in
# paritcular for the bash/shell programmers as it uses the same
# "$" indicator but then oftentime $(VARNAME)
# it is possible to use ${VARNAME},
# as a "price" the use of $ in the "recipe" part of a rule the us of shell variabls requires
# to use $$SHELVAR