-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
126 lines (101 loc) · 2.39 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#/// @file
#/// @brief Generic Makefile for the System 2 project.
#
#/// @detail If you just add some library files used by the project.c program, you have nothing to change to compile them if sources are in the ./src directory. To add a new binary, just add the name of the main file in the TARGETS variable.
#Nom du project
TARGETS = project
##############
# Constantes #
##############
# Repertoires
SOURCE = ./src
BIN = ./bin
DOCPATH = ${SOURCE}/dox
DOCTARGET = ./doc
DIRLIST = ${SOURCE} ${BIN}
#DEP = ${SOURCE}/depend
#DIRLIST = ${SOURCE} ${BIN} ${OPT} ${DEP}
# Cibles
BINTGTS = ${TARGETS:%=${BIN}/%}
# Commandes
CC = gcc
# Options
CFLAGS = -O0 -g -W -Wall -Wextra -Wconversion -Werror -mtune=native -march=native -std=c99
LDFLAGS = -lm -W -Wall -pedantic -L. -lm
# Fichiers
DOX = ${wildcard ${DOCPATH}/*.dox} # Sources
SRC = ${wildcard ${SOURCE}/*.c} # Sources
INT = ${wildcard ${SOURCE}/*.h} # Interfaces
OBJ = ${SRC:%.c=%.o} # Objets
##########
# Regles #
##########
# ALL
all : ${BINTGTS}
# CLEAN
clean :
@echo
@echo Cleaning : object files
@echo --------
@echo
rm -f ${OBJ}
clean-doc :
@echo
@echo Cleaning : object files
@echo --------
@echo
rm -fr ${DOCTARGET}
clean-emacs :
@echo
@echo Cleaning : emacs back-ups
@echo --------
@echo
rm -f ${SOURCE}/*~
rm -f ${SOURCE}/\#*\#
rm -f *~
rm -f \#*\#
clean-bin :
@echo
@echo Cleaning : binaries
@echo --------
@echo
rm -f ${BINTGTS}
distclean : clean clean-emacs clean-bin
dirs :
@for dir in ${DIRLIST} ;\
do \
echo Creating directory : $${dir} ;\
echo ------------------ ;\
if test -d $${dir} ;\
then \
echo Directory already exists ;\
else mkdir -p $${dir} ;\
fi ;\
echo Done ;\
echo ;\
done
# Binaires
${BIN}/${TARGETS} : ${${TARGETS}:%=${SOURCE}/%}
${BIN}/% : $(OBJ)
@echo
@echo Linking bytecode : $@
@echo ----------------
@echo
${CC} -o $@ $^ ${LDFLAGS}
@echo
@echo Done
@echo
# Regles generiques
%.o : %.c %.h
@echo
@echo Compiling $@
@echo --------
@echo
$(CC) $(CFLAGS) -c $< -o $@
# Documentation
doc : ${SRC} ${INT} ${DOX}
doxygen; doxygen
#############################
# Inclusion et spécificités #
#############################
.PHONY : all clean clean-doc clean-emacs clean-bin distclean doc