|
1 | 1 | # Convenience top-level Makefile for siamize. Wraps the CMake build and adds |
2 | | -# code-formatting / cleanup targets. CMake is still the primary build system |
3 | | -# (this Makefile just shells out to it). |
| 2 | +# code-formatting / cleanup / packaging targets. CMake is still the primary |
| 3 | +# build system (this Makefile just shells out to it). |
4 | 4 | # |
5 | 5 | # Targets: |
6 | | -# make — configure + build (Release) under build/ |
7 | | -# make clean — remove build/ |
8 | | -# make pretty — format all source (astyle on C++, black on Python) |
9 | | -# make pretty-cpp — astyle on src/*.{cpp,h} |
10 | | -# make pretty-py — black on py/ and tools/ |
11 | | -# make test — run tests/run_regression.sh (needs models/ populated) |
12 | | - |
13 | | -BUILD_DIR ?= build |
| 6 | +# |
| 7 | +# make configure + build CPU CLI (Release) under build/ |
| 8 | +# make cuda configure + build CUDA CLI (re-fetches GPU ORT if needed) |
| 9 | +# make tensorrt configure + build TensorRT CLI (re-fetches GPU ORT if needed) |
| 10 | +# |
| 11 | +# make mex-octave build the Octave MEX (siamex.mex) |
| 12 | +# make mex-matlab build the MATLAB MEX (siamex.mex{a64,maca64,w64}) |
| 13 | +# make mex-test run matlab/tests/run_tests.m in Octave (30 unit tests) |
| 14 | +# |
| 15 | +# make package stage + zip the CPU CLI bundle |
| 16 | +# make package-cuda stage + zip the CUDA CLI bundle (needs `make cuda` first) |
| 17 | +# make package-tensorrt stage + zip the TRT CLI bundle (needs `make tensorrt`) |
| 18 | +# make package-mex stage + zip the MEX bundle (needs `make mex-*`) |
| 19 | +# |
| 20 | +# make test run tests/run_regression.sh (needs models/ populated) |
| 21 | +# |
| 22 | +# make pretty astyle on C++, black on Python |
| 23 | +# make pretty-cpp / pretty-py |
| 24 | +# |
| 25 | +# make clean rm -rf build/ (keeps third_party/) |
| 26 | +# make distclean rm -rf build/ third_party/onnxruntime/ |
| 27 | +# |
| 28 | +# Notes: |
| 29 | +# * The CPU and GPU ORT prebuilts share `third_party/onnxruntime/`, so |
| 30 | +# switching between `make` and `make cuda` re-fetches ORT only if the |
| 31 | +# current install doesn't have the right provider plugins. |
| 32 | +# * `make package*` runs `scripts/package.sh` which uses 7z; on macOS |
| 33 | +# you may need `brew install p7zip` if 7z isn't already present. |
| 34 | + |
| 35 | +BUILD_DIR ?= build |
14 | 36 | BUILD_TYPE ?= Release |
| 37 | +ORT_DIR := third_party/onnxruntime |
| 38 | + |
| 39 | +# Filenames used to detect which ORT prebuilt (CPU vs GPU) is currently |
| 40 | +# installed under third_party/onnxruntime/. |
| 41 | +ORT_GPU_MARKER := $(ORT_DIR)/lib/libonnxruntime_providers_cuda.so |
| 42 | +ORT_GPU_MARKER_DLL := $(ORT_DIR)/lib/onnxruntime_providers_cuda.dll |
| 43 | + |
| 44 | +.PHONY: all build cuda tensorrt mex-octave mex-matlab mex-test \ |
| 45 | + package package-cuda package-tensorrt package-mex \ |
| 46 | + ort-cpu ort-gpu clean distclean pretty pretty-cpp pretty-py test |
15 | 47 |
|
16 | | -.PHONY: all build clean pretty pretty-cpp pretty-py test |
| 48 | +# ---- CLI builds ------------------------------------------------------------- |
17 | 49 |
|
18 | 50 | all: build |
19 | 51 |
|
20 | | -build: |
| 52 | +build: ort-cpu |
21 | 53 | cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) |
22 | 54 | cmake --build $(BUILD_DIR) --config $(BUILD_TYPE) --parallel |
23 | 55 |
|
| 56 | +cuda: ort-gpu |
| 57 | + cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DSIAMIZE_GPU=cuda |
| 58 | + cmake --build $(BUILD_DIR) --config $(BUILD_TYPE) --parallel |
| 59 | + @echo |
| 60 | + @echo "[make cuda] built $(BUILD_DIR)/siamize with CUDA EP." |
| 61 | + @echo "Runtime: see README.md > 'Optional: NVIDIA GPU build' for the" |
| 62 | + @echo "LD_LIBRARY_PATH one-liner that exposes CUDA/cuDNN libs to ORT." |
| 63 | + |
| 64 | +tensorrt: ort-gpu |
| 65 | + cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DSIAMIZE_GPU=tensorrt |
| 66 | + cmake --build $(BUILD_DIR) --config $(BUILD_TYPE) --parallel |
| 67 | + @echo |
| 68 | + @echo "[make tensorrt] built $(BUILD_DIR)/siamize with TensorRT + CUDA EPs." |
| 69 | + |
| 70 | +# ---- ORT prebuilt management ------------------------------------------------ |
| 71 | + |
| 72 | +# CPU ORT: fetch only if no CPU-only install is present. If a GPU build is |
| 73 | +# currently installed, wipe build/ + ORT and refetch. |
| 74 | +ort-cpu: |
| 75 | + @if [ -d $(ORT_DIR) ] && [ ! -e $(ORT_GPU_MARKER) ] && [ ! -e $(ORT_GPU_MARKER_DLL) ]; then \ |
| 76 | + echo "[ort] CPU ORT already installed under $(ORT_DIR)"; \ |
| 77 | + else \ |
| 78 | + echo "[ort] (re)installing CPU ORT prebuilt"; \ |
| 79 | + rm -rf $(ORT_DIR) $(BUILD_DIR); \ |
| 80 | + scripts/fetch_deps.sh; \ |
| 81 | + fi |
| 82 | + |
| 83 | +# GPU ORT: fetch only if the CUDA provider plugin isn't already present. |
| 84 | +ort-gpu: |
| 85 | + @if [ -e $(ORT_GPU_MARKER) ] || [ -e $(ORT_GPU_MARKER_DLL) ]; then \ |
| 86 | + echo "[ort] GPU ORT already installed under $(ORT_DIR)"; \ |
| 87 | + else \ |
| 88 | + echo "[ort] (re)installing GPU ORT prebuilt"; \ |
| 89 | + rm -rf $(ORT_DIR) $(BUILD_DIR); \ |
| 90 | + ORT_BUILD=gpu scripts/fetch_deps.sh; \ |
| 91 | + fi |
| 92 | + |
| 93 | +# ---- MEX builds ------------------------------------------------------------- |
| 94 | + |
| 95 | +mex-octave: ort-cpu |
| 96 | + cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DSIAMIZE_BUILD_OCTAVE_MEX=ON |
| 97 | + cmake --build $(BUILD_DIR) --config $(BUILD_TYPE) --parallel |
| 98 | + @echo "[make mex-octave] built $(BUILD_DIR)/siamex.mex" |
| 99 | + |
| 100 | +mex-matlab: ort-cpu |
| 101 | + cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DSIAMIZE_BUILD_MATLAB_MEX=ON |
| 102 | + cmake --build $(BUILD_DIR) --config $(BUILD_TYPE) --parallel |
| 103 | + @echo "[make mex-matlab] built $(BUILD_DIR)/siamex.mex<a64|maca64|w64>" |
| 104 | + |
| 105 | +mex-test: |
| 106 | + octave-cli --no-gui --eval "cd matlab/tests; run_tests('--exit')" |
| 107 | + |
| 108 | +# ---- Packaging -------------------------------------------------------------- |
| 109 | + |
| 110 | +# Each package-* target stages files under dist/<name>/ and zips to |
| 111 | +# <name>.zip in the repo root via scripts/package.sh. |
| 112 | + |
| 113 | +package: |
| 114 | + scripts/package.sh cpu siamize-cpu |
| 115 | + |
| 116 | +package-cuda: |
| 117 | + scripts/package.sh cuda siamize-cuda |
| 118 | + |
| 119 | +package-tensorrt: |
| 120 | + scripts/package.sh tensorrt siamize-tensorrt |
| 121 | + |
| 122 | +package-mex: |
| 123 | + scripts/package.sh mex siamex |
| 124 | + |
| 125 | +# ---- Misc ------------------------------------------------------------------- |
| 126 | + |
| 127 | +test: |
| 128 | + tests/run_regression.sh |
| 129 | + |
24 | 130 | clean: |
25 | | - rm -rf $(BUILD_DIR) |
| 131 | + rm -rf $(BUILD_DIR) dist/ siamize-cpu.zip siamize-cuda.zip siamize-tensorrt.zip siamex.zip |
| 132 | + |
| 133 | +distclean: clean |
| 134 | + rm -rf $(ORT_DIR) |
26 | 135 |
|
27 | 136 | pretty: pretty-cpp pretty-py |
28 | 137 |
|
@@ -54,6 +163,3 @@ pretty-cpp: |
54 | 163 | # Python formatting via black (PEP 8 conformant, default 88-col line length). |
55 | 164 | pretty-py: |
56 | 165 | black py/ tools/ |
57 | | - |
58 | | -test: |
59 | | - tests/run_regression.sh |
|
0 commit comments