forked from syswonder/ruxos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaxbuild.mk
50 lines (43 loc) · 2 KB
/
axbuild.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
CMAKE = cmake
ARCH ?= x86_64
C_COMPILER := $(shell which $(CC))
CXX_COMPILER := $(shell which $(CC))
AR := $(shell which $(AR))
RANLIB := $(shell which $(RANLIB))
CROSS_COMPILE_PATH := $(shell dirname $(C_COMPILER))/..
CXX_STD ?= 20
app-objs := std_benchmark.o
std_benchmark_dir := $(APP)/std-benchmark
std_benchmark_build = $(std_benchmark_dir)/build
bench ?= all
benches_available := accessors algorithm mutators size_metric string stringstream
$(std_benchmark_dir):
@echo "Download std-benchmark source code"
cd $(APP)/ && git clone --recursive https://github.com/hiraditya/std-benchmark
patch -p1 -N -d $(std_benchmark_dir) --no-backup-if-mismatch -r - < $(APP)/std_benchmark.patch
$(APP)/$(app-objs): build_std-benchmark
build_std-benchmark: $(std_benchmark_dir) $(APP)/axbuild.mk
cd $(std_benchmark_dir) && mkdir -p build && cd build && \
$(CMAKE) .. -DCMAKE_CXX_STANDARD=$(CXX_STD) -DCMAKE_C_COMPILER=$(C_COMPILER) -DCMAKE_CXX_COMPILER=$(CXX_COMPILER) -DCMAKE_AR=$(AR) -DCMAKE_RANLIB=$(RANLIB) \
-DENABLE_C_BENCHMARKS=OFF -DENABLE_C_VS_CXX_BENCHMARKS=OFF -DENABLE_COMPILER_VS_PROGRAMMER=OFF -DBENCHMARK_ENABLE_TESTING=OFF && \
$(MAKE) -j
mkdir -p $(std_benchmark_build)/libgcc && cd $(std_benchmark_build)/libgcc && \
ln -s -f $(CROSS_COMPILE_PATH)/lib/gcc/*-linux-musl/*/libgcc.a ./ && \
$(AR) x libgcc.a _clrsbsi2.o
ifeq ($(bench), all)
$(error "Running all benches automatically is not supported currently, please add 'bench=' arg. \
Available benches: $(benches_available)")
endif
ifneq ($(filter $(bench),$(benches_available)),)
$(LD) -o $(app-objs) -nostdlib -static -no-pie -r -e main \
$(std_benchmark_build)/cxx/lib$(bench).bench.cpp.out.a \
$(std_benchmark_build)/benchmark/src/libbenchmark.a \
$(CROSS_COMPILE_PATH)/*-linux-musl/lib/libstdc++.a \
$(CROSS_COMPILE_PATH)/lib/gcc/*-linux-musl/*/libgcc_eh.a \
$(std_benchmark_build)/libgcc/_clrsbsi2.o
else
$(error "Available benches: $(benches_available)")
endif
clean_c::
rm -rf $(std_benchmark_build)/
.PHONY: build_std-benchmark clean_c