7474endif
7575
7676# Build profile configuration
77- # Usage: make build PROFILE=dev|release|native (default: dev)
78- # The PECOS_PROFILE env var is passed to build scripts so they can set appropriate
79- # compiler flags for both Rust and C++ code.
80- PROFILE ?= dev
77+ # Usage: make build PROFILE=debug|release|native (default: debug)
78+ # Build scripts detect the profile via Cargo's PROFILE env var.
79+ PROFILE ?= debug
8180
8281# Profile-specific Cargo/Maturin settings
83- # C++ flags are handled by build scripts reading PECOS_PROFILE
82+ # - debug: uses default cargo (debug) profile - fast compile, no optimization
83+ # - release: uses --release flag - full optimization
84+ # - native: uses --profile native (custom profile inheriting from release) + CPU-specific opts
85+ #
86+ # For native profile, we also pass -C target-cpu=native to Rust via RUSTFLAGS.
87+ # Build scripts detect PROFILE=native and add -march=native for C++ code.
8488ifeq ($(PROFILE ) ,native)
8589 MATURIN_RELEASE_FLAG := --release
86- CARGO_RELEASE_FLAG := --release
90+ CARGO_PROFILE_FLAG := --profile native
8791 RUSTFLAGS_EXTRA := -C target-cpu=native
8892 PROFILE_DESC := native (release + CPU optimizations)
8993else ifeq ($(PROFILE),release)
9094 MATURIN_RELEASE_FLAG := --release
91- CARGO_RELEASE_FLAG := --release
95+ CARGO_PROFILE_FLAG := --release
9296 RUSTFLAGS_EXTRA :=
9397 PROFILE_DESC := release (optimized)
9498else
95- # dev profile (default)
99+ # debug profile (default)
96100 MATURIN_RELEASE_FLAG :=
97- CARGO_RELEASE_FLAG :=
101+ CARGO_PROFILE_FLAG :=
98102 RUSTFLAGS_EXTRA :=
99- PROFILE_DESC := dev (fast compile, unoptimized)
103+ PROFILE_DESC := debug (fast compile, unoptimized)
100104endif
101105
102106# Helper to build FFI crates with the correct profile
103- # PECOS_PROFILE is read by build.rs scripts to set C++ compiler flags
107+ # Build scripts detect profile via Cargo's PROFILE env var
104108define BUILD_FFI_CRATES
105109 @if command -v julia >/dev/null 2>&1; then \
106110 echo "Julia detected, building Julia FFI library ($(PROFILE ) )..."; \
107111 cd julia/pecos-julia-ffi && \
108- PECOS_PROFILE=$(PROFILE ) \
109112 RUSTFLAGS="$$RUSTFLAGS $(RUSTFLAGS_EXTRA ) " \
110- cargo build $(CARGO_RELEASE_FLAG ) ; \
113+ cargo build $(CARGO_PROFILE_FLAG ) ; \
111114 echo "Julia FFI library built successfully"; \
112115 else \
113116 echo "Julia not detected, skipping Julia build"; \
114117 fi
115118 @if command -v go >/dev/null 2>&1; then \
116119 echo "Go detected, building Go FFI library ($(PROFILE ) )..."; \
117120 cd go/pecos-go-ffi && \
118- PECOS_PROFILE=$(PROFILE ) \
119121 RUSTFLAGS="$$RUSTFLAGS $(RUSTFLAGS_EXTRA ) " \
120- cargo build $(CARGO_RELEASE_FLAG ) ; \
122+ cargo build $(CARGO_PROFILE_FLAG ) ; \
121123 echo "Go FFI library built successfully"; \
122124 else \
123125 echo "Go not detected, skipping Go build"; \
124126 fi
125127endef
126128
127129.PHONY : build
128- build : installreqs # # Build PECOS (use PROFILE=dev |release|native, default: dev )
130+ build : installreqs # # Build PECOS (use PROFILE=debug |release|native, default: debug )
129131 @echo " Building with profile: $( PROFILE_DESC) "
130132 @$(SETUP_LLVM ) ; $(UNSET_CONDA ) cd python/pecos-rslib/ && \
131- PECOS_PROFILE=$(PROFILE ) \
132133 RUSTFLAGS=" $$ RUSTFLAGS $( RUSTFLAGS_EXTRA) " \
133134 uv run maturin develop --uv $(MATURIN_RELEASE_FLAG )
134135 @$(UNSET_CONDA ) uv pip install -e " ./python/quantum-pecos[all]"
135136 $(BUILD_FFI_CRATES )
136137
137138.PHONY : build-cuda
138- build-cuda : installreqs # # Build PECOS with CUDA support (use PROFILE=dev |release|native, default: dev )
139+ build-cuda : installreqs # # Build PECOS with CUDA support (use PROFILE=debug |release|native, default: debug )
139140 @echo " Building with CUDA support, profile: $( PROFILE_DESC) "
140141 @$(SETUP_LLVM ) ; $(UNSET_CONDA ) cd python/pecos-rslib/ && \
141- PECOS_PROFILE=$(PROFILE ) \
142142 RUSTFLAGS=" $$ RUSTFLAGS $( RUSTFLAGS_EXTRA) " \
143143 uv run maturin develop --uv $(MATURIN_RELEASE_FLAG )
144144 @$(UNSET_CONDA ) uv pip install -e " ./python/quantum-pecos[all,cuda]"
145145 $(BUILD_FFI_CRATES )
146146
147147# Convenience aliases for common build profiles
148- .PHONY : build-dev
149- build-dev : # # Alias for: make build PROFILE=dev
150- @$(MAKE ) build PROFILE=dev
148+ .PHONY : build-debug
149+ build-debug : # # Alias for: make build PROFILE=debug
150+ @$(MAKE ) build PROFILE=debug
151151
152152.PHONY : build-release
153153build-release : # # Alias for: make build PROFILE=release
@@ -157,9 +157,9 @@ build-release: ## Alias for: make build PROFILE=release
157157build-native : # # Alias for: make build PROFILE=native
158158 @$(MAKE ) build PROFILE=native
159159
160- .PHONY : build-cuda-dev
161- build-cuda-dev : # # Alias for: make build-cuda PROFILE=dev
162- @$(MAKE ) build-cuda PROFILE=dev
160+ .PHONY : build-cuda-debug
161+ build-cuda-debug : # # Alias for: make build-cuda PROFILE=debug
162+ @$(MAKE ) build-cuda PROFILE=debug
163163
164164.PHONY : build-cuda-release
165165build-cuda-release : # # Alias for: make build-cuda PROFILE=release
@@ -771,7 +771,7 @@ pip-install-uv: ## Install uv using pip and create a venv. (Recommended to inst
771771 uv sync
772772
773773.PHONY : dev
774- dev : clean build-dev test # # Run the typical sequence of commands to check everything is running correctly
774+ dev : clean build-debug test # # Run the typical sequence of commands to check everything is running correctly
775775
776776.PHONY : devl
777777devl : dev lint # # Run the commands to make sure everything runs + lint
@@ -792,7 +792,7 @@ help: ## Show the help menu
792792 @grep -E ' ^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}'
793793 @echo " "
794794 @echo " Note: Julia and Go support is automatically detected."
795- @echo " - 'make build-dev ' will also build Julia/Go FFI if they are installed"
795+ @echo " - 'make build-debug ' will also build Julia/Go FFI if they are installed"
796796 @echo " - 'make test' will also run Julia/Go tests if they are installed"
797797 @echo " - 'make lint' checks code quality; 'make lint-fix' fixes issues"
798798 @echo " - Use 'make julia-info' or 'make go-info' for more information"
0 commit comments