diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ad07d88bed..b7c1e863433 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,7 +165,7 @@ endif () if(BUILD_TESTING AND BUILD_SHARED_LIBS OR S2N_FUZZ_TEST) target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=default) else() - target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=hidden -DS2N_EXPORTS) + target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=hidden -DS2N_EXPORTS=1) endif() if(S2N_LTO) @@ -197,7 +197,7 @@ target_compile_options(${PROJECT_NAME} PRIVATE -include "${S2N_PRELUDE}") # Match on Release, RelWithDebInfo and MinSizeRel # See: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html#variable:CMAKE_BUILD_TYPE if(CMAKE_BUILD_TYPE MATCHES Rel) - add_definitions(-DS2N_BUILD_RELEASE) + add_definitions(-DS2N_BUILD_RELEASE=1) endif() if(NO_STACK_PROTECTOR) @@ -316,7 +316,7 @@ function(feature_probe_result PROBE_NAME IS_AVAILABLE) # define the probe if available if(NORMALIZED) - add_definitions(-D${PROBE_NAME}) + add_definitions(-D${PROBE_NAME}=1) endif() endfunction() @@ -426,7 +426,7 @@ if (S2N_INTERN_LIBCRYPTO) DEPENDS libcrypto.symbols ) add_dependencies(${PROJECT_NAME} s2n_libcrypto) - add_definitions(-DS2N_INTERN_LIBCRYPTO) + add_definitions(-DS2N_INTERN_LIBCRYPTO=1) if ((BUILD_SHARED_LIBS AND BUILD_TESTING) OR NOT BUILD_SHARED_LIBS) # if libcrypto needs to be interned, rewrite libcrypto references so use of internal functions will link correctly diff --git a/codebuild/bin/grep_simple_mistakes.sh b/codebuild/bin/grep_simple_mistakes.sh index ad9806ec2d7..2f2b9d29da1 100755 --- a/codebuild/bin/grep_simple_mistakes.sh +++ b/codebuild/bin/grep_simple_mistakes.sh @@ -14,6 +14,20 @@ FAILED=0 +############################################# +# Grep for command line defines without values +############################################# +EMPTY_DEFINES=$(grep -Eon "\-D[^=]+=?" CMakeLists.txt | grep -v =) +if [ ! -z "${EMPTY_DEFINES}" ]; then + FAILED=1 + printf "\e[1;34mCommand line define is missing value:\e[0m " + printf "Compilers SHOULD set a default value of 1 when no default is given, " + printf "but that behavior is not required by any official spec. Set a value just in case. " + printf "For example: -DS2N_FOO=1 instead of -DS2N_FOO.\n" + printf "Found: \n" + echo "$EMPTY_DEFINES" +fi + ############################################# # Grep for bindings methods without C documentation links. ############################################# diff --git a/s2n.mk b/s2n.mk index efc42f49920..b48a876eff8 100644 --- a/s2n.mk +++ b/s2n.mk @@ -134,7 +134,7 @@ bindir ?= $(exec_prefix)/bin libdir ?= $(exec_prefix)/lib64 includedir ?= $(exec_prefix)/include -feature_probe = $(shell $(CC) $(CFLAGS) $(shell cat $(S2N_ROOT)/tests/features/GLOBAL.flags) $(shell cat $(S2N_ROOT)/tests/features/$(1).flags) -c -o tmp.o $(S2N_ROOT)/tests/features/$(1).c > /dev/null 2>&1 && echo "-D$(1)"; rm tmp.o > /dev/null 2>&1) +feature_probe = $(shell $(CC) $(CFLAGS) $(shell cat $(S2N_ROOT)/tests/features/GLOBAL.flags) $(shell cat $(S2N_ROOT)/tests/features/$(1).flags) -c -o tmp.o $(S2N_ROOT)/tests/features/$(1).c > /dev/null 2>&1 && echo "-D$(1)=1"; rm tmp.o > /dev/null 2>&1) FEATURES := $(notdir $(patsubst %.c,%,$(wildcard $(S2N_ROOT)/tests/features/*.c))) SUPPORTED_FEATURES := $(foreach feature,$(FEATURES),$(call feature_probe,$(feature)))