This repository has been archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
91 lines (67 loc) · 2.26 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
# Easily adaptable makefile
# Note: remove comments (#) to activate some features
#
# author Vitor Carreira
# date 2010-09-26 / updated: 2016-03-15 (Patricio)
# Libraries to include (if any)
LIBS=#-lm -pthread
# Compiler flags
CFLAGS=-Wall -Wextra -ggdb -std=c11 -pedantic -D_POSIX_C_SOURCE=200809L #-pg
# Linker flags
LDFLAGS=#-pg
# Indentation flags
# IFLAGS=-br -brs -brf -npsl -ce -cli4 -bli4 -nut
IFLAGS=-linux -brs -brf -br
# Name of the executable
PROGRAM=checkFile
# Prefix for the gengetopt file (if gengetopt is used)
PROGRAM_OPT=args
# Object files required to build the executable
PROGRAM_OBJS=main.o debug.o memory.o $(PROGRAM_OPT).o type.o
# Clean and all are not files
.PHONY: clean all docs indent debugon
all: $(PROGRAM)
# activate DEBUG, defining the SHOW_DEBUG macro
debugon: CFLAGS += -D SHOW_DEBUG -g
debugon: $(PROGRAM)
# activate optimization (-O...)
OPTIMIZE_FLAGS=-O2 # possible values (for gcc): -O2 -O3 -Os -Ofast
optimize: CFLAGS += $(OPTIMIZE_FLAGS)
optimize: LDFLAGS += $(OPTIMIZE_FLAGS)
optimize: $(PROGRAM)
$(PROGRAM): $(PROGRAM_OBJS)
$(CC) -o $@ $(PROGRAM_OBJS) $(LIBS) $(LDFLAGS)
# Dependencies
main.o: main.c debug.h memory.h $(PROGRAM_OPT).h
$(PROGRAM_OPT).o: $(PROGRAM_OPT).c $(PROGRAM_OPT).h
type.o: type.c type.h
debug.o: debug.c debug.h
memory.o: memory.c memory.h
# disable warnings from gengetopt generated files
$(PROGRAM_OPT).o: $(PROGRAM_OPT).c $(PROGRAM_OPT).h
$(CC) -ggdb -std=c11 -pedantic -c $<
#how to create an object file (.o) from C file (.c)
.c.o:
$(CC) $(CFLAGS) -c $<
# Generates command line arguments code from gengetopt configuration file
$(PROGRAM_OPT).c $(PROGRAM_OPT).h: $(PROGRAM_OPT).ggo
gengetopt < $(PROGRAM_OPT).ggo --file-name=$(PROGRAM_OPT)
clean:
rm -f *.o core.* *~ $(PROGRAM) *.bak $(PROGRAM_OPT).h $(PROGRAM_OPT).c
docs: Doxyfile
doxygen Doxyfile
Doxyfile:
doxygen -g Doxyfile
# entry to create the list of dependencies
depend:
$(CC) -MM *.c
# entry 'indent' requires the application indent (sudo apt-get install indent)
indent:
indent $(IFLAGS) *.c *.h
# entry to run the pmccabe utility (computes the "complexity" of the code)
# Requires the application pmccabe (sudo apt-get install pmccabe)
pmccabe:
pmccabe -v *.c
# entry to run the cppcheck tool
cppcheck:
cppcheck --enable=all --verbose *.c *.h