aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2022-07-15 04:15:05 -0700
committerGitHub <noreply@github.com>2022-07-15 04:15:05 -0700
commit0c620ce212d92d009f47293ea5e0b676c3380fbb (patch)
tree03513e3b5253c9925f124ad8ca8932fec8f9145c
parent1d17532d70d0b93032de4ada17c1787ee8939f15 (diff)
parent684ebfd4be59edc50ab7dc1475eed36a66deef63 (diff)
downloadlz4-0c620ce212d92d009f47293ea5e0b676c3380fbb.tar.gz
Merge pull request #1116 from lz4/standardMakeVars
Test support of Standard Makefile Variables
-rw-r--r--.github/workflows/ci.yml10
-rw-r--r--Makefile39
2 files changed, 48 insertions, 1 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0b1650ca..abc7600c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -207,6 +207,16 @@ jobs:
run: make V=1 -C tests test-fuzzer32
+ lz4-standard-makefile-variables:
+ name: LZ4 Makefile - support for standard variables
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2 # https://github.com/actions/checkout
+
+ - name: make standard_variables
+ run: make V=1 standard_variables
+
+
lz4-versions:
name: LZ4 versions test
runs-on: ubuntu-latest
diff --git a/Makefile b/Makefile
index fd629458..9e12ae77 100644
--- a/Makefile
+++ b/Makefile
@@ -233,6 +233,43 @@ c_standards_c99: clean
.PHONY: c_standards_c11
c_standards_c11: clean
- $(MAKE) clean; CFLAGS="-std=c11 -Werror" $(MAKE) all
+ $(MAKE) clean; CFLAGS="-std=c11 -Werror" $(MAKE) all
+
+# The following test ensures that standard Makefile variables set through environment
+# are correctly transmitted at compilation stage.
+# This test is meant to detect issues like https://github.com/lz4/lz4/issues/958
+.PHONY: standard_variables
+standard_variables: clean
+ @echo =================
+ @echo Check support of Makefile Standard variables through environment
+ @echo note : this test requires V=1 to work properly
+ @echo =================
+ CC="cc -DCC_TEST" \
+ CFLAGS=-DCFLAGS_TEST \
+ CPPFLAGS=-DCPPFLAGS_TEST \
+ LDFLAGS=-DLDFLAGS_TEST \
+ LDLIBS=-DLDLIBS_TEST \
+ $(MAKE) V=1 > tmpsv
+ # Note: just checking the presence of custom flags
+ # would not detect situations where custom flags are
+ # supported in some part of the Makefile, and missed in others.
+ # So the test checks if they are present the _right nb of times_.
+ # However, checking static quantities makes this test brittle,
+ # because quantities (7, 2 and 1) can still evolve in future,
+ # for example when source directories or Makefile evolve.
+ if [ $$(grep CC_TEST tmpsv | wc -l) -ne 7 ]; then \
+ echo "CC environment variable missed" && False; fi
+ if [ $$(grep CFLAGS_TEST tmpsv | wc -l) -ne 7 ]; then \
+ echo "CFLAGS environment variable missed" && False; fi
+ if [ $$(grep CPPFLAGS_TEST tmpsv | wc -l) -ne 7 ]; then \
+ echo "CPPFLAGS environment variable missed" && False; fi
+ if [ $$(grep LDFLAGS_TEST tmpsv | wc -l) -ne 2 ]; then \
+ echo "LDFLAGS environment variable missed" && False; fi
+ if [ $$(grep LDLIBS_TEST tmpsv | wc -l) -ne 1 ]; then \
+ echo "LDLIBS environment variable missed" && False; fi
+ @echo =================
+ @echo all custom variables detected
+ @echo =================
+ $(RM) tmpsv
endif # MSYS POSIX