Skip to content

Commit

Permalink
Solve p28 in fortran (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Oct 2, 2024
1 parent bacae2b commit d1d267f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions fortran/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ FC?=flang-new
COV?=false
BUILD_DIR=build
SRC_DIR=src
INCLUDE_DIR=$(SRC_DIR)/include
SRC_FILES=$(wildcard $(SRC_DIR)/*.f90) $(wildcard $(SRC_DIR)/include/*.f90)
OBJ_FILES=$(patsubst $(SRC_DIR)/%.f90, $(BUILD_DIR)/%.o, $(SRC_FILES))
INCLUDE_FILES=$(wildcard $(INCLUDE_DIR)/*.f90)
INCLUDE_OBJS=$(patsubst $(INCLUDE_DIR)/%.f90, $(BUILD_DIR)/include/%.o, $(notdir $(INCLUDE_FILES)))
OBJ_FILES=$(patsubst $(SRC_DIR)/%.f90, $(BUILD_DIR)/%.o, $(SRC_FILES)) $(INCLUDE_OBJS)

GCC_VERSION := $(shell gcc --version | grep ^gcc | sed 's/^.* //g')
GCC_MAJOR := $(shell echo $(GCC_VERSION) | cut -d. -f1)

Expand Down Expand Up @@ -39,16 +43,19 @@ help:
@echo " $(BLUE)test_auto$(NC) Run through all Fortran tests (parallel execution not implemented)."
@echo " $(BLUE)clean$(NC) Clean up any stray files."

$(BUILD_DIR)/include/constants.o: $(SRC_DIR)/include/constants.f90
$(BUILD_DIR)/include/constants.o: $(INCLUDE_DIR)/constants.f90
@mkdir -p $(BUILD_DIR)/include
$(FC) $(opt_args) $(cov_args) -c $(SRC_DIR)/include/constants.f90 -o $(BUILD_DIR)/include/constants.o
@$(FC) $(opt_args) $(cov_args) -c $(INCLUDE_DIR)/constants.f90 -o $@

$(BUILD_DIR)/include/%.o: $(INCLUDE_DIR)/%.f90 $(BUILD_DIR)/include/constants.o
@$(FC) $(opt_args) $(cov_args) -c $< -o $@

$(BUILD_DIR)/%.o: $(SRC_DIR)/%.f90 $(BUILD_DIR)/include/constants.o
$(FC) $(opt_args) $(cov_args) $(BUILD_DIR)/include/constants.o -c $< -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.f90 $(INCLUDE_OBJS)
@$(FC) $(opt_args) $(cov_args) -c $< -o $@

test_runner: ../LICENSE
@$(MAKE) $(OBJ_FILES) $(MFLAGS) -j --no-print-directory
$(FC) $(opt_args) $(cov_args) $(BUILD_DIR)/*.o $(BUILD_DIR)/include/*.o test.f90 -o test_runner
@$(MAKE) $(OBJ_FILES) $(INCLUDE_OBJS) $(MFLAGS) -j --no-print-directory
@$(FC) $(opt_args) $(cov_args) $(BUILD_DIR)/*.o $(BUILD_DIR)/include/*.o test.f90 -o test_runner

.PHONY: test
test: test_runner
Expand Down

0 comments on commit d1d267f

Please sign in to comment.