-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.mk
executable file
·89 lines (69 loc) · 2.58 KB
/
main.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
OBJS := $(SRCS:.$(EXT)=.o)
PATH_OBJS_RLS := $(addprefix $(DIR_OBJ_RLS), $(OBJS))
PATH_OBJS_DBG := $(addprefix $(DIR_OBJ_DBG), $(OBJS))
RFLAGS += $(CFLAGS) $(addprefix -I, $(DIRS_INC_RLS))
DFLAGS += $(CFLAGS) $(addprefix -I, $(DIRS_INC_DBG))
DIR_LIB_RLS := $(DIR_PROJS)$(DIR_PROJ)lib/Release/
DIR_LIB_DBG := $(DIR_PROJS)$(DIR_PROJ)lib/Debug/
.PHONY : default
default: release
.PHONY : lib
lib: lib_release lib_debug
.PHONY : lib_release
lib_release: release $(PATH_OBJS_RLS)
$(AR) $(AARGS) $(DIR_LIB_RLS)lib$(DIR_PROJ:/=.a) $(filter-out $(DIR_OBJ_RLS)main.o $(DIR_OBJ_RLS)cli_%, $(PATH_OBJS_RLS)) && \
$(CP) $(wildcard $(DIR_OBJ_RLS)*mod) $(DIR_LIB_RLS) && \
$(AR) t $(DIR_LIB_RLS)lib$(DIR_PROJ:/=.a)
.PHONY : lib_debug
lib_debug: debug $(PATH_OBJS_DBG)
$(AR) $(AARGS) $(DIR_LIB_DBG)lib$(DIR_PROJ:/=.a) $(filter-out $(DIR_OBJ_DBG)main.o $(DIR_OBJ_DBG)cli_%, $(PATH_OBJS_DBG)) && \
$(CP) $(wildcard $(DIR_OBJ_DBG)*mod) $(DIR_LIB_DBG) && \
$(AR) t $(DIR_LIB_DBG)lib$(DIR_PROJ:/=.a)
.PHONY : release
release: prep_release $(PATH_OBJS_RLS)
$(FC) $(RFLAGS) -s -o $(PATH_BIN_RLS) $(PATH_OBJS_RLS) $(LIBS_RLS)
$(DIR_OBJ_RLS)%.o: %.$(EXT)
$(FC) $(RFLAGS) $(OP_DIR_OBJ) $(DIR_OBJ_RLS) -o $@ -c $<
.PHONY : debug
debug: prep_debug $(PATH_OBJS_DBG)
$(FC) $(DFLAGS) -o $(PATH_BIN_DBG) $(PATH_OBJS_DBG) $(LIBS_DBG) && \
ln -sf $(PATH_BIN_DBG) ~/gdb/fortran_debug
$(DIR_OBJ_DBG)%.o: %.$(EXT)
$(FC) $(DFLAGS) $(OP_DIR_OBJ) $(DIR_OBJ_DBG) -o $@ -c $<
.PHONY : debugrun
debugrun: prep_debug debug
$(DIR_PROJS)$(DIR_PROJ)bin/Debug/$(NAME) | tee $(NAME).log
.PHONY : prep
prep: prep_release prep_debug
.PHONY : prep_release
prep_release:
$(MKDIR) $(DIR_OBJ_RLS) $(DIR_BIN_RLS) $(DIR_LIB_RLS)
.PHONY : prep_debug
prep_debug:
$(MKDIR) $(DIR_OBJ_DBG) $(DIR_BIN_DBG) $(DIR_LIB_DBG) ~/gdb/
.PHONY : clean
clean: clean_release clean_debug
.PHONY : clean_release
clean_release:
$(RM) $(PATH_BIN_RLS)
$(RM) $(DIR_OBJ_RLS)*.*
.PHONY : clean_debug
clean_debug:
$(RM) $(PATH_BIN_DBG)
$(RM) $(DIR_OBJ_DBG)*.*
.PHONY : extra_clean
extra_clean:
$(RM)r $(PATH_BIN_RLS) $(PATH_BIN_DBG) $(DIR_OBJ_RLS) $(DIR_OBJ_DBG) $(DIR_LIB_RLS) $(DIR_LIB_DBG)
.PHONY : install
install:
$(MKDIR) $(DIR_BIN_INS)$(DIR_PROJ)
$(CP) $(DIR_BIN_RLS)$(NAME) $(DIR_BIN_INS)$(DIR_PROJ)$(NAME)
$(RM) /usr/bin/$(ID_PROG)_$(NAME)
$(LN) $(DIR_BIN_INS)$(DIR_PROJ)$(NAME) /usr/bin/$(ID_PROG)_$(NAME)
chown $(USR):$(USR) $(DIR_BIN_INS)$(DIR_PROJ)$(NAME)
chown $(USR):$(USR) /usr/bin/$(ID_PROG)_$(NAME)
.PHONY : uninstall
uninstall:
$(RM) $(DIR_BIN_INS)$(DIR_PROJ)$(NAME)
find $(DIR_BIN_INS) -type d -empty -delete
$(RM) /usr/bin/$(ID_PROG)_$(NAME)