Skip to content

Instantly share code, notes, and snippets.

@Sonophoto
Created November 30, 2016 04:30
Show Gist options
  • Save Sonophoto/eb98f0710d6bc4148ac3836dc8880996 to your computer and use it in GitHub Desktop.
Save Sonophoto/eb98f0710d6bc4148ac3836dc8880996 to your computer and use it in GitHub Desktop.
Demonstrate templating with Makefile target and /bin/echo
#****************************************************************************
#
# GNU/ __ __ _ __ _ _
# /gmake | \/ | __ _| | _____ / _(_) | ___
# / | |\/| |/ _` | |/ / _ \ |_| | |/ _ \
# /BSD-2c | | | | (_| | < __/ _| | | __/
# |_| |_|\__,_|_|\_\___|_| |_|_|\___|
#
# HEREDOC
#
# FILENAME: Makefile AUTHOR: "Brig Young"
# COPYRIGHT: "2016 Brig Young" LICENSE: "BSD-2c"
# PURPOSE: Deomonstrate templating with Makefile target and /bin/echo
#
# This file probably requires GNU gmake.
#****************************************************************************
MAKE_VARIABLE = --std=c11 --pedantic -fpcc-struct-return
OUTPUT_DIR = .
OUTPUT_FILENAME = heredoc.output
heredoc:
@/bin/echo -e \
This is some text followed by a newline\\n\
and this is an interpolated make variable: $(MAKE_VARIABLE).\\n\
and this is not: MAKE_VARIABLE.\\n\
See man echo for details. >> $(OUTPUT_DIR)/$(OUTPUT_FILENAME)
clean:
rm heredoc.output
brig@something ~/src/makefile_HEREDOC $ ls
Makefile
brig@something ~/src/makefile_HEREDOC $ make
brig@something ~/src/makefile_HEREDOC $ ls
heredoc.output Makefile
brig@something ~/src/makefile_HEREDOC $ cat heredoc.output
This is some text followed by a newline
and this is an interpolated make variable: --std=c11 --pedantic -fpcc-struct-return.
and this is not: MAKE_VARIABLE.
See man echo for details.
brig@something ~/src/makefile_HEREDOC $ make clean
rm heredoc.output
brig@something ~/src/makefile_HEREDOC $ ls
Makefile
brig@something ~/src/makefile_HEREDOC $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment