Added LDFLAGS to embedded version info for hello-omp. Tweaked

Makefile to be more maintainable and to use common CFLAGS/LDFLAGS
variable names.
This commit is contained in:
Ed Braaten 2015-04-24 13:44:53 -07:00 committed by Ed Braaten
parent e213617d4e
commit 6538e6034d

View file

@ -1,8 +1,10 @@
# Sample makefile to add version/compiler info via an extra # Sample makefile to add version/compiler info via an extra
# object module linked to final binary. # object module linked to final binary.
# #
COMPILER_VER:=$(shell gcc --version) CC=gcc
COMPILER_OPTS=-fopenmp COMPILER_VER:=$(shell $(CC) --version)
CFLAGS=-fopenmp
LDFLAGS=
GIT_DESCRIBE:=$(shell git describe --abbrev=7 --dirty --always --tags --long) GIT_DESCRIBE:=$(shell git describe --abbrev=7 --dirty --always --tags --long)
GIT_AUTHOR:=$(shell git --no-pager log -1 --pretty=format:"%an <%ae>") GIT_AUTHOR:=$(shell git --no-pager log -1 --pretty=format:"%an <%ae>")
BUILD_DATE:=$(shell date +"%F %H:%M:%S") BUILD_DATE:=$(shell date +"%F %H:%M:%S")
@ -13,7 +15,8 @@ all: hello-omp
versioninfo.txt: versioninfo.txt:
@echo "@(#) Build date: ${BUILD_DATE}." >versioninfo.txt @echo "@(#) Build date: ${BUILD_DATE}." >versioninfo.txt
@echo "@(#) Compiler version: ${COMPILER_VER}." >>versioninfo.txt @echo "@(#) Compiler version: ${COMPILER_VER}." >>versioninfo.txt
@echo "@(#) Compiler options: ${COMPILER_OPTS}." >>versioninfo.txt @echo "@(#) Compiler options: '${CFLAGS}'." >>versioninfo.txt
@echo "@(#) Linker options: '${LDFLAGS}'." >>versioninfo.txt
@echo "@(#) Git info: ${GIT_DESCRIBE}" >>versioninfo.txt @echo "@(#) Git info: ${GIT_DESCRIBE}" >>versioninfo.txt
@echo "@(#) Commit author: ${GIT_AUTHOR}" >>versioninfo.txt @echo "@(#) Commit author: ${GIT_AUTHOR}" >>versioninfo.txt
@ -26,8 +29,8 @@ versioninfo.o: versioninfo.txt
versioninfo.txt versioninfo.o versioninfo.txt versioninfo.o
hello-omp: hello-omp.c Makefile versioninfo.o hello-omp: hello-omp.c Makefile versioninfo.o
gcc $(COMPILER_OPTS) -DVERSIONINFO="\"$(GIT_DESCRIBE)\"" hello-omp.c \ gcc $(CFLAGS) $(LDFLAGS) -DVERSIONINFO="\"$(GIT_DESCRIBE)\"" \
versioninfo.o -o hello-omp hello-omp.c versioninfo.o -o hello-omp
.PHONY: test .PHONY: test
test: test: