Skip to content

Commit a0b0a14

Browse files
yuminguwclaude
andcommitted
Add Linux-specific Makefile for C++ fiber backend extension
Provides a dedicated build configuration for building the pybind11 fiber_backend shared library on Linux, using sysconfig instead of python-config for portability and adding OpenMP support via CONDA_PREFIX. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e223132 commit a0b0a14

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/ctfire_py/CPP/Makefile.linux

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# --- Configuration ---
2+
TARGET = fiber_backend$(shell python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
3+
4+
# Compiler setup
5+
CXX = g++
6+
CXXFLAGS = -g -O0 -Wall -shared -std=c++14 -fPIC
7+
8+
# Python and Pybind11 Flags
9+
PY_INCLUDES = $(shell python -m pybind11 --includes) $(shell python -c "import sysconfig; print('-I' + sysconfig.get_path('include'))")
10+
# Replace python-config with sysconfig calls
11+
PY_LDFLAGS = $(shell python -c "import sysconfig; print('-L' + sysconfig.get_config_var('LIBDIR') + ' -lpython' + sysconfig.get_config_var('VERSION'))")
12+
13+
# OpenMP Configuration
14+
OMP_FLAGS = -fopenmp
15+
OMP_INCLUDES = -I$(CONDA_PREFIX)/include
16+
OMP_LIBS = -L$(CONDA_PREFIX)/lib -lgomp
17+
18+
# Source files
19+
SRCS = extend_xlink_native.cpp fiberproc_native.cpp findlocmax_native.cpp fire_utils.cpp
20+
21+
# --- Build Rules ---
22+
all: $(TARGET)
23+
24+
$(TARGET): $(SRCS) link_fibre.h
25+
$(CXX) $(CXXFLAGS) $(PY_INCLUDES) $(OMP_FLAGS) $(OMP_INCLUDES) $(SRCS) $(PY_LDFLAGS) $(OMP_LIBS) -o $(TARGET)
26+
27+
clean:
28+
rm -f *.so *.pyd

src/ctfire_py/fire_2d_angle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ def fire_2d_angle(
540540
"F": F,
541541
"R": R,
542542
"Xa": Xa,
543-
"Fa": Fa,
544543
"Xas": Xas,
544+
"Fa": Fa,
545545
"Fas": Fa,
546546
"Va": Va,
547547
"Ea": Ea,

0 commit comments

Comments
 (0)