forked from chipsalliance/UHDM
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
86 lines (65 loc) · 2.85 KB
/
Makefile
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# UHDM top Makefile (Wrapper to cmake)
# Use bash as the default shell
SHELL := /usr/bin/env bash
ifeq ($(CPU_CORES),)
CPU_CORES := $(shell nproc)
ifeq ($(CPU_CORES),)
CPU_CORES := $(shell sysctl -n hw.physicalcpu)
endif
ifeq ($(CPU_CORES),)
CPU_CORES := 2
endif
endif
PREFIX?=/usr/local
ADDITIONAL_CMAKE_OPTIONS ?=
export CTEST_PARALLEL_LEVEL = $(CPU_CORES)
release: build
cmake --build build --config Release -j $(CPU_CORES)
release-shared: build-shared
cmake --build build --config Release -j $(CPU_CORES)
debug:
mkdir -p dbuild
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(PREFIX) $(ADDITIONAL_CMAKE_OPTIONS) -S . -B dbuild
cmake --build dbuild --config Debug -j $(CPU_CORES)
debug-shared:
mkdir -p dbuild
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DBUILD_SHARED_LIBS=ON $(ADDITIONAL_CMAKE_OPTIONS) -S . -B dbuild
cmake --build dbuild --config Debug -j $(CPU_CORES)
test: build
cmake --build build --target UnitTests --config Release -j $(CPU_CORES)
cd build && ctest -C Release --output-on-failure
test-shared: build-shared
cmake --build build --target UnitTests --config Release -j $(CPU_CORES)
cd build && ctest -C Release --output-on-failure
test-junit: release
cd build && ctest --no-compress-output -T Test -C RelWithDebInfo --output-on-failure
xsltproc .github/kokoro/ctest2junit.xsl build/Testing/*/Test.xml > build/test_results.xml
clean:
rm -rf build dbuild
install: release
cmake --install build --config Release
install-shared: release-shared
cmake --install build --config Release
uninstall:
$(RM) $(PREFIX)/bin/uhdm-*
$(RM) -r $(PREFIX)/lib/libuhdm*
$(RM) -r $(PREFIX)/include/uhdm
build:
mkdir -p build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DBUILD_SHARED_LIBS=OFF $(ADDITIONAL_CMAKE_OPTIONS) -S . -B build
build-shared:
mkdir -p build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DBUILD_SHARED_LIBS=ON -DUHDM_WITH_PYTHON=$(UHDM_WITH_PYTHON) $(ADDITIONAL_CMAKE_OPTIONS) -S . -B build
test_install:
cmake --build build --target test_inst --config Release -j $(CPU_CORES)
find build/bin -name test_inst* -exec {} \;
# Smoke-test if installation results in usable pkg-config
# Depending on system, PKG_CONFIG_PATH env var has different name. Set both.
test_install_pkgconfig: install
PKG_CONFIG_PATH="$(PREFIX)/lib/pkgconfig:${PKG_CONFIG_PATH}" \
PKG_CONFIG_PATH_FOR_TARGET="$(PREFIX)/lib/pkgconfig:${PKG_CONFIG_PATH_FOR_TARGET}" \
PKG_CONFIG_CXXFLAGS=`pkg-config --cflags UHDM` && \
PKG_CONFIG_LDFLAGS=`pkg-config --libs UHDM` && \
echo -e "pkg-config:\n\tCXXFLAGS=$$PKG_CONFIG_CXXFLAGS\n\tLDFLAGS=$$PKG_CONFIG_LDFLAGS" && \
$(CXX) --std=c++17 $$PKG_CONFIG_CXXFLAGS util/uhdm-dump.cpp -obuild/uhdm-dump_pkg-config_test-compile $$PKG_CONFIG_LDFLAGS
.PHONY: build build-shared build-static release debug test test-junit clean install uninstall test_install