Skip to content

Commit ddc2b30

Browse files
committed
fixup makefiles
1 parent 8385fac commit ddc2b30

2 files changed

Lines changed: 14 additions & 17 deletions

File tree

Makefile-variables

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ CPPFLAGS := -MMD -MP
2727

2828
COMPILER_VERSION := $(shell $(CXX) --version | grep version | grep -o -m 1 "[0-9]\+\.[0-9]\+\.*[0-9]*" | head -n 1)
2929
COMPILER_VERSION_NUMBER := $(shell echo $(COMPILER_VERSION) | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
30-
CLANG_16_OR_MORE := $(shell expr $(COMPILER_VERSION_NUMBER) \>= 160000)
31-
CLANG_13_OR_MORE := $(shell expr $(COMPILER_VERSION_NUMBER) \>= 130106)
32-
ifneq ($(CLANG_16_OR_MORE),0)
30+
CLANG_16_OR_MORE := $(shell test $(COMPILER_VERSION_NUMBER) -ge 160000 && echo true)
31+
CLANG_13_OR_MORE := $(shell test $(COMPILER_VERSION_NUMBER) -ge 130106 && echo true)
32+
ifeq ($(CLANG_16_OR_MORE),true)
3333
# supported: c++11, c++14, c++17, c++20, c++23
3434
# future: c++2c/c++26
3535
CXXFLAGS ?= --std=c++23 -O3 -Iinclude $(shell pkg-config --cflags getargv)
36-
else ifneq ($(CLANG_13_OR_MORE),0)
36+
else ifeq ($(CLANG_13_OR_MORE),true)
3737
CXXFLAGS ?= --std=c++20 -O3 -Iinclude $(shell pkg-config --cflags getargv)
3838
else
3939
CXXFLAGS ?= --std=c++17 -O3 -Iinclude $(shell pkg-config --cflags getargv)
@@ -79,3 +79,6 @@ PKG_VERSION_FLAG :=
7979
else
8080
PKG_VERSION_FLAG := --min-os-version $(MACOSX_DEPLOYMENT_TARGET)
8181
endif
82+
83+
version:
84+
@echo $(COMPILER_VERSION_NUMBER) $(CLANG_16_OR_MORE) $(CLANG_13_OR_MORE)

test/Makefile

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
CXX := clang++
1+
include ../Makefile-variables
2+
23
PRIMARY_SOURCEFILE := $(wildcard ../src/*.cpp)
34
EXECUTABLE_NAME := lib_unit_tests
4-
OBJ_DIR := obj
5-
LIB_DIR := lib
65
BIN_DIR := bin
7-
SRC_DIR := src
8-
LIB_SHORT_NAME := getargv++
96
INCLUDE_DIR := include/$(LIB_SHORT_NAME)
107
COV_DIR := coverage
118
PREFIX := $(PWD)
129

13-
COMPILER_VERSION := $(shell $(CXX) --version | grep version | grep -o -m 1 "[0-9]\+\.[0-9]\+\.*[0-9]*" | head -n 1)
14-
COMPILER_VERSION_NUMBER := $(shell echo $(COMPILER_VERSION) | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
15-
CLANG_13_OR_MORE := $(shell expr $(COMPILER_VERSION_NUMBER) \>= 130106)
16-
ifneq ($(CLANG_13_OR_MORE),0)
17-
CXXFLAGS := --std=c++23
18-
# supported: c++11, c++14, c++17, c++20, c++23
19-
# future: c++2c
10+
ifeq ($(CLANG_16_OR_MORE),true)
11+
CXXFLAGS := --std=c++23
12+
else ifeq ($(CLANG_13_OR_MORE),true)
13+
CXXFLAGS := --std=c++20
2014
else
21-
CXXFLAGS := --std=c++17
15+
CXXFLAGS := --std=c++17
2216
endif
2317

2418
LDFLAGS :=

0 commit comments

Comments
 (0)