-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (46 loc) · 1.5 KB
/
Copy pathMakefile
File metadata and controls
58 lines (46 loc) · 1.5 KB
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
# Makefile for libsparseir-fortran-test
# This uses manual compilation approach that works
# Compiler settings
FC = gfortran
FCFLAGS = -O2 -g
# Build directory
BUILD_DIR = build
# libsparseir directories (after CMake build)
LIBSPARSEIR_BUILD_DIR = $(BUILD_DIR)/_deps/libsparseir-build
FORTRAN_LIB_DIR = $(LIBSPARSEIR_BUILD_DIR)/fortran
C_LIB_DIR = $(LIBSPARSEIR_BUILD_DIR)
MODULE_DIR = $(FORTRAN_LIB_DIR)/fortran
# Library flags
LDFLAGS = -L$(FORTRAN_LIB_DIR) -L$(C_LIB_DIR) -lsparseir_fortran -lsparseir
FCFLAGS += -I$(MODULE_DIR)
# Source files
TEST_SRC = test/test_sparseir.f90
TEST_EXE = test_sparseir_manual
# Default target
all: setup $(TEST_EXE)
# Setup: build libsparseir using CMake
setup:
@echo "Building libsparseir using CMake..."
@mkdir -p $(BUILD_DIR)
@cd $(BUILD_DIR) && cmake .. -DSPARSEIR_BUILD_FORTRAN=ON -DSPARSEIR_BUILD_TESTING=OFF
@cd $(BUILD_DIR) && make sparseir sparseir_fortran
# Build test executable
$(TEST_EXE): $(TEST_SRC) setup
@echo "Compiling Fortran test..."
$(FC) $(FCFLAGS) $(LDFLAGS) $(TEST_SRC) -o $(TEST_EXE)
# Run test
test: $(TEST_EXE)
@echo "Running test..."
DYLD_LIBRARY_PATH=$(FORTRAN_LIB_DIR):$(C_LIB_DIR) ./$(TEST_EXE)
# Clean
clean:
rm -rf $(BUILD_DIR) $(TEST_EXE)
# Help
help:
@echo "Available targets:"
@echo " all - Build everything (default)"
@echo " setup - Build libsparseir libraries only"
@echo " test - Build and run the test"
@echo " clean - Clean all build artifacts"
@echo " help - Show this help"
.PHONY: all setup test clean help