-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
100 lines (79 loc) · 2.24 KB
/
Makefile
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
90
91
92
93
94
95
96
97
98
99
100
#
# MAIN CONFIGURATION
#
EXEC = main stats benchmark test
OBJECTS = utils.o
PROJECT_NAME = SUDOKU_SOLVER
SRC_DIR = src
OBJECTS_DIR = obj
INCLUDE_DIR = includes
BIN_DIR = bin
#
# SUFFIXES (must not change it)
#
.SUFFIXES: .c .o
#
# OBJECTS (must not change it)
#
EXEC_O = $(EXEC:=.o)
OBJECTS_O = $(OBJECTS) $(EXEC_O)
#
# ARGUMENTS AND COMPILER (to configure)
#
CC = gcc
CCFLAGS_STD = -Wall -O3 -fopenmp
CCFLAGS_DEBUG = -D _DEBUG_
CCFLAGS_CUSTOM = _SHOW_
CCFLAGS = $(CCFLAGS_STD)
CCLIBS = -fopenmp -lm -lncurses
#
# RULES (must not change it)
#
all: msg $(addprefix $(OBJECTS_DIR)/,$(OBJECTS)) $(addprefix $(OBJECTS_DIR)/,$(EXEC_O))
@echo "Create executables..."
@for i in $(EXEC); do \
$(CC) -o $(addprefix $(BIN_DIR)/,$$i) $(addprefix $(OBJECTS_DIR)/,$$i.o) $(addprefix $(OBJECTS_DIR)/,$(OBJECTS)) $(CCLIBS) -I../$(INCLUDE_DIR)/; \
done
@echo "Done."
msg:
@echo "Create objects..."
debug: CCFLAGS = $(CCFLAGS_STD) $(CCFLAGS_DEBUG)
debug: all
show: CCFLAGS = $(CCFLAGS_STD) $(CCFLAGS_CUSTOM)
show: all
#
# DEFAULT RULES (must not change it)
#
$(addprefix obj/,%.o) : $(addprefix src/,%.c)
@${CC} ${CCFLAGS} -c $< -o $@ -I$(INCLUDE_DIR)/
#
# MAIN RULES (must not change it)
#
# You can add your own commands
clean:
@echo "Delete objects, temporary files..."
@rm -f $(addprefix $(OBJECTS_DIR)/,$(OBJECTS_O))
@rm -f $(addprefix $(OBJECTS_DIR)/,$(EXEC_O))
@rm -f $(addprefix $(OBJECTS_DIR)/,*~) $(addprefix $(OBJECTS_DIR)/,*#)
@rm -f $(addprefix $(INCLUDE_DIR)/,*~) $(addprefix $(INCLUDE_DIR)/,*#)
@rm -f $(addprefix $(BIN_DIR)/,$(EXEC))
@rm -f dependancies
@echo "Done."
depend:
@echo "Create dependancies..."
@sed -e "/^# DEPENDANCIES/,$$ d" makefile > dependancies
@echo "# DEPENDANCIES" >> dependancies
@for i in $(OBJECTS_O); do \
$(CC) -MM -MT $(addprefix $(OBJECTS_DIR)/,$$i) $(CCFLAGS) $(SRC_DIR)/`echo $$i | sed "s/\(.*\)\\.o$$/\1.c/"` -I$(INCLUDE_DIR) >> dependancies; \
done
@cat dependancies > makefile
@rm dependancies
@echo "Done."
#
# CREATE ARCHIVE (must not modify)
#
ARCHIVE_FILES = *
archive: clean
@echo "Create archive $(PROJECT_NAME)_$(shell date '+%y%m%d.tar.gz')..."
@REP=`basename "$$PWD"`; cd .. && tar zcf $(PROJECT_NAME)_$(shell date '+%y%m%d.tar.gz') $(addprefix "$$REP"/,$(ARCHIVE_FILES))
@echo "Done."# DEPENDANCIES