From 6ba13bbeda548fc82140812ae059901e31f3840b Mon Sep 17 00:00:00 2001 From: Patrick Lipka Date: Mon, 18 Aug 2025 17:41:27 +0200 Subject: [PATCH] Add makefile --- Makefile | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..61c2428 --- /dev/null +++ b/Makefile @@ -0,0 +1,62 @@ +CC = clang +FC = flang +AR = ar + +# Architecture settings for RISC-V (adjust as needed) +ARCH_FLAGS = + +DEBUG_FLAGS = -g + +# Library settings +LIB_NAME = librvprof +STATIC_LIB = $(LIB_NAME).a + +# Source directories +SRC_DIR = src +INCLUDE_DIR = include + +# Source files +C_SOURCES = \ + $(SRC_DIR)/rvprof_core.c \ + $(SRC_DIR)/rvprof_timing.c \ + $(SRC_DIR)/rvprof_symbols.c \ + $(SRC_DIR)/rvprof_memory.c \ + $(SRC_DIR)/rvprof_hooks.c \ + $(SRC_DIR)/rvprof_output.c \ + $(SRC_DIR)/rvprof_utils.c \ + $(SRC_DIR)/rvprof_stats.c \ + $(SRC_DIR)/rvprof_context.c \ + $(SRC_DIR)/rvprof_fortran.c + +F_SOURCES = rvprof_module.f90 +HEADERS = rvprof.h $(SRC_DIR)/rvprof_internal.h + +# Object files +C_OBJECTS = $(C_SOURCES:.c=.o) +F_OBJECTS = $(F_SOURCES:.f90=.o) +ALL_OBJECTS = $(C_OBJECTS) $(F_OBJECTS) + +# Module files (generated by Fortran compiler) +MOD_FILES = rvprof.mod + +# Default target +all: $(STATIC_LIB) + +# Static library +$(STATIC_LIB): $(ALL_OBJECTS) + @echo "Creating static library $@" + $(AR) rcs $@ $^ + +# C object files +$(SRC_DIR)/%.o: $(SRC_DIR)/%.c $(HEADERS) + @echo "Compiling C source $<" + $(CC) $(CFLAGS) $(DEBUG_FLAGS) -I. -c $< -o $@ + +# Fortran object files (depends on C objects for linking) +%.o: %.f90 $(C_OBJECTS) + @echo "Compiling Fortran module $<" + $(FC) $(FFLAGS) -c $< -o $@ + +clean: + rm -f $(ALL_OBJECTS) $(MOD_FILES) + rm -f $(STATIC_LIB) \ No newline at end of file