Skip to content

Commit

Permalink
Define differently
Browse files Browse the repository at this point in the history
  • Loading branch information
minhqdao committed Feb 26, 2024
1 parent e5b4177 commit 3a22b8f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,30 @@ MOD-DIR = $(BUILD-DIR)/mod
OBJ-DIR = $(BUILD-DIR)/obj
TEST-DIR = $(BUILD-DIR)/test

ifeq ($(FC),nvfortran)
MOD-OUT-OPTION = -module $(MOD-DIR)
else
MOD-OUT-OPTION = -J$(MOD-DIR)
endif

ifeq ($(FC),nvfortran)
MOD-IN-OPTION = -module $(MOD-DIR)
else
MOD-IN-OPTION = -I$(MOD-DIR)
endif

.PHONY: all test clean

all: $(STATIC)

$(STATIC): $(SRC)
mkdir -p $(MOD-DIR) $(OBJ-DIR)
ifeq ($(FC),nvfortran)
$(FC) $(FFLAGS) -c $(SRC) -module $(MOD-DIR) -o $(OBJ-DIR)/$(FILENAME).o
else
$(FC) $(FFLAGS) -c $(SRC) -J$(MOD-DIR) -o $(OBJ-DIR)/$(FILENAME).o
endif
$(FC) $(FFLAGS) -c $(SRC) $(MOD-OUT-OPTION) -o $(OBJ-DIR)/$(FILENAME).o
$(AR) $(ARFLAGS) $(STATIC) $(OBJ-DIR)/$(FILENAME).o

test: $(TEST-SRC) $(STATIC)
mkdir -p $(TEST-DIR)
$(FC) $(FFLAGS) $(TEST-SRC) -I$(MOD-DIR) -o $(TEST-DIR)/test.out $(STATIC)
$(FC) $(FFLAGS) $(TEST-SRC) $(MOD-IN-OPTION) -o $(TEST-DIR)/test.out $(STATIC)
$(TEST-DIR)/test.out

clean:
Expand Down

0 comments on commit 3a22b8f

Please sign in to comment.