@@ -7,18 +7,21 @@ PYTHON ?= python
77PYTEST ?= pytest
88EXTRA_INCLUDE_DIRS ?=
99
10- MAJOR_VERSION := 1
11- MINOR_VERSION := 0
12- MICRO_VERSION := 0
10+ CLANG_TIDY ?= clang-tidy
11+ CLANG_FORMAT ?= clang-format
12+ GTEST_BREAK ?= 1
13+
14+ # not using $(file <version) because it was added in GNU Make 4.2 which is
15+ # newer that what is on macos and our github actions workers
16+ VERSION_PARTS := $(subst ., ,$(shell cat version) )
17+ MAJOR_VERSION := $(word 1,$(VERSION_PARTS ) )
18+ MINOR_VERSION := $(word 2,$(VERSION_PARTS ) )
19+ MICRO_VERSION := $(word 3,$(VERSION_PARTS ) )
1320
1421PY_VERSION := $(shell $(PYTHON ) etc/python_version.py)
1522PY_MAJOR_VERSION := $(word 1,$(PY_VERSION ) )
1623PY_MINOR_VERSION := $(word 2,$(PY_VERSION ) )
1724
18- CLANG_TIDY ?= clang-tidy
19- CLANG_FORMAT ?= clang-format
20- GTEST_BREAK ?= 1
21-
2225COMPILER := $(shell CXX=$(CXX ) ./etc/build-and-run etc/detect-compiler.cc)
2326ifeq ($(COMPILER ) ,UNKNOWN)
2427 $(warning Could not detect which compiler is being used, assuming gcc.)
@@ -49,7 +52,10 @@ BASE_CXXFLAGS = -std=gnu++17 -g -O$(OPTLEVEL) \
4952 -fvisibility=hidden \
5053 $(WARNINGS ) \
5154 -DPY_MAJOR_VERSION=$(PY_MAJOR_VERSION ) \
52- -DPY_MINOR_VERSION=$(PY_MINOR_VERSION )
55+ -DPY_MINOR_VERSION=$(PY_MINOR_VERSION ) \
56+ -DLIBPY_MAJOR_VERSION=$(MAJOR_VERSION ) \
57+ -DLIBPY_MINOR_VERSION=$(MINOR_VERSION ) \
58+ -DLIBPY_MICRO_VERSION=$(MICRO_VERSION )
5359GCC_FLAGS = -fmax-errors=$(MAX_ERRORS )
5460CLANG_FLAGS = -ferror-limit=$(MAX_ERRORS )
5561CXXFLAGS = $(BASE_CXXFLAGS ) $($(COMPILER ) _FLAGS)
@@ -222,7 +228,7 @@ tests/%.o: tests/%.cc .make/all-flags
222228
223229$(TEST_MODULE ) : gtest.a $(TEST_OBJECTS ) libpy/libpy.so
224230 $(CXX ) -shared -o $@ $(TEST_OBJECTS ) gtest.a $(TEST_INCLUDE ) \
225- -Wl,-rpath,`pwd` -lpthread -L. $(SONAME) $(LDFLAGS)
231+ -Wl,-rpath,` pwd` -lpthread -L. $(SONAME ) $(LDFLAGS )
226232
227233gtest.o : $(GTEST_SRCS ) .make/all-flags
228234 $(CXX ) $(filter-out $(WARNINGS ) ,$(CXXFLAGS ) ) -I $(GTEST_DIR ) \
0 commit comments