File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed
Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change 1- bin /
1+ bin /
2+ obj /
Original file line number Diff line number Diff line change 1- # Generate an executable with this name
21TARGET = tourexec
32
4- # Define the compiler and flags to pass to that compiler
53CC = gfortran
64CFLAGS = -fno-automatic
75
8- # Define the directories for source code and output binary executable
6+ LINKER = gfortran
7+
98SRC_DIR = src
109BIN_DIR = bin
10+ OBJ_DIR = obj
11+
12+ SOURCES := $(wildcard $(SRC_DIR ) /* .f)
13+ OBJECTS := $(SOURCES:$(SRC_DIR ) /%.f=$(OBJ_DIR ) /%.o )
14+ rm = rm -rf
15+
16+ $(BIN_DIR ) /$(TARGET ) : $(OBJECTS )
17+ @mkdir -p $(@D )
18+ @$(LINKER ) $(OBJECTS ) -o $@
19+ @echo " Linking complete"
1120
12- $(BIN_DIR ) / $( TARGET ) : $(SRC_DIR ) /* .f
21+ $(OBJECTS ) : $( OBJ_DIR ) / % .o : $(SRC_DIR ) /% .f
1322 @mkdir -p $(@D )
14- $(CC ) $(CFLAGS ) -o $@ $<
23+ @$(CC ) $(CFLAGS ) -c $< -o $@
24+ @echo " Compiled " $< " successfully"
25+
26+ .PHONY : clean
27+ clean :
28+ @$(rm ) $(OBJ_DIR )
29+ @echo " Cleanup complete"
30+
31+ .PHONY : remove
32+ remove : clean
33+ @$(rm ) $(BIN_DIR )
34+ @echo " Executable removed"
You can’t perform that action at this time.
0 commit comments