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
2
1
TARGET = tourexec
3
2
4
- # Define the compiler and flags to pass to that compiler
5
3
CC = gfortran
6
4
CFLAGS = -fno-automatic
7
5
8
- # Define the directories for source code and output binary executable
6
+ LINKER = gfortran
7
+
9
8
SRC_DIR = src
10
9
BIN_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"
11
20
12
- $(BIN_DIR ) / $( TARGET ) : $(SRC_DIR ) /* .f
21
+ $(OBJECTS ) : $( OBJ_DIR ) / % .o : $(SRC_DIR ) /% .f
13
22
@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