@@ -4,7 +4,7 @@ all: sdist bdist_wheel docs
44
55NAME := pytidyhtml5
66
7- .PHONY : all sdist bdist_wheel clean docs prepare clean-generated clean-artifacts
7+ .PHONY : all sdist bdist_wheel clean docs prepare clean-generated clean-artifacts export-environ
88
99FILES := Makefile MANIFEST.in _${NAME}.pyx README.rst setup.py \
1010 lib/native.hpp lib/VERSION.txt lib/DESCRIPTION.txt \
@@ -17,25 +17,43 @@ TIDY_CFLAGS += -fstack-protector-strong --param=ssp-buffer-size=8
1717TIDY_CFLAGS += -fvisibility=internal -fmerge-all-constants
1818TIDY_CFLAGS += -std=c11 -D_ISOC11_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
1919
20- export CC = $(shell which gcc clang g++ clang++ | head -n1)
21- export CXX = $(shell which g++ clang++ gcc clang | head -n1)
22- export AR = $(shell which gcc-ar llvm-ar ar | head -n1)
23- export RANLIB = $(shell which gcc-ranlib llvm-ranlib ranlib | head -n1)
2420
25- $(info CC=${CC})
26- $(info CXX=${CXX})
27- $(info AR=${AR})
28- $(info RANLIB=${RANLIB})
21+ CC: =$(shell which gcc clang g++ clang++ | head -n1 2> /dev/null)
22+ CXX: =$(shell which g++ clang++ gcc clang | head -n1 2> /dev/null)
23+ AR: =$(shell which gcc-ar llvm-ar ar | head -n1 2> /dev/null)
24+ RANLIB: =$(shell which gcc-ranlib llvm-ranlib ranlib | head -n1 2> /dev/null)
25+
26+ ifeq ($(findstring * /c/,* ${CC}) ,*/c/)
27+ CC: =$(patsubst /c/% ,c:/% ,${CC}) .exe
28+ endif
29+
30+ ifeq ($(findstring * /c/,* ${CXX}) ,*/c/)
31+ CXX: =$(patsubst /c/% ,c:/% ,${CXX}) .exe
32+ endif
33+
34+ ifeq ($(findstring * /c/,* ${AR}) ,*/c/)
35+ AR: =$(patsubst /c/% ,c:/% ,${AR}) .exe
36+ endif
37+
38+ ifeq ($(findstring * /c/,* ${RANLIB}) ,*/c/)
39+ RANLIB: =$(patsubst /c/% ,c:/% ,${RANLIB}) .exe
40+ endif
41+
42+ export CC
43+ export CXX
44+ export AR
45+ export ARFLAGS
46+ export RANLIB
47+
2948
3049tidy-html5/.git :
3150 git submodule init
3251 git submodule update
3352
3453tidy-html5/build/cmake/libtidy.a : | tidy-html5/.git
35- mkdir -p tidy-html5/build/
36-
3754 cd tidy-html5/build/cmake && \
3855 cmake ../.. \
56+ " -GUnix Makefiles" \
3957 -DCMAKE_BUILD_TYPE=Release \
4058 -DBUILD_SHARED_LIBS=OFF \
4159 -DCMAKE_C_FLAGS=" ${TIDY_CFLAGS} " \
@@ -45,35 +63,44 @@ tidy-html5/build/cmake/libtidy.a: | tidy-html5/.git
4563 -DCMAKE_RANLIB=" ${RANLIB} "
4664
4765 cd tidy-html5/build/cmake/ && \
48- $(MAKE) VERBOSE=1 -B
66+ $(MAKE) VERBOSE=1 -B tidy-static
4967
68+ -mv tidy-html5/build/cmake/libtidy_static.a tidy-html5/build/cmake/libtidy.a
5069 $(RANLIB) $@
5170
52- -rm tidy-html5/build/cmake/libtidy.so
71+ -rm tidy-html5/build/cmake/libtidy.so*
5372
5473lib/_import_tidy_enum.pyx :
5574 ./generate_imports.py
5675
5776_${NAME}.cpp : _${NAME}.pyx $(wildcard lib/* .pyx) | lib/_import_tidy_enum.pyx
5877 -rm -- dist/* .so
5978 -rm ./_${NAME} .cpp
60- python -m Cython.Build.Cythonize -f $<
79+
80+ python3 -m Cython.Build.Cythonize -f $<
81+
82+ sed -i -e '1s;^;# ifdef _WIN64\
83+ static void hypot() {}\
84+ namespace std { static void _hypot() {} }\
85+ #include <cmath>\
86+ #endif\
87+ ;' -e 's/%z/%" PY_FORMAT_SIZE_T "/g' $@
6188
6289prepare : _${NAME}.cpp ${FILES}
6390
6491sdist : _${NAME}.cpp ${FILES}
6592 -rm -- dist/${NAME} -* .tar.gz
66- python setup.py sdist --format=gztar
67- python setup.py sdist --format=xztar
93+ python3 setup.py sdist --format=gztar
94+ python3 setup.py sdist --format=xztar
6895
6996bdist_wheel : _${NAME}.cpp ${FILES} | sdist
7097 -rm -- dist/${NAME} -* .whl
71- python setup.py bdist_wheel
98+ python3 setup.py bdist_wheel
7299
73100docs : bdist_wheel $(wildcard docs/* docs/* /* )
74101 -rm -r -- dist/html/
75102 pip install --force dist/${NAME} -* .whl
76- python -m sphinx -M html docs/ dist/
103+ python3 -m sphinx -M html docs/ dist/
77104
78105clean : clean-generated clean-artifacts
79106
@@ -88,3 +115,10 @@ clean-artifacts:
88115 -rm -r -- ./dist/
89116 -rm -r -- ./" ${NAME} .egg-info/"
90117 -pip uninstall pytidyhtml5 -y
118+
119+ export-environ :
120+ @echo CC=${CC}
121+ @echo CXX=${CXX}
122+ @echo AR=${AR}
123+ @echo ARFLAGS=${ARFLAGS}
124+ @echo RANLIB=${RANLIB}
0 commit comments