-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
87 lines (67 loc) · 2.09 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
# Makefile for the Cataract Diagnosis Software
#
# Creators:
# - João Pedro de Amorim Paula
# - Felipe C. Ramos Filho
PROJ_NAME = catarata
# Makefile conventions
SHELL = /bin/sh
# Directories
incdir = ./include
srcdir = ./src
objdir = ./obj
bindir = ./bin
# Macros
CC = gcc
CFLAGS = -Wall -Wextra -g -ggdb -std=c11 -lm -I. -I$(incdir)
RM = -rm
OBJS = $(addprefix $(objdir)/,read.o process.o write.o util.o)
# Phony targets (for more information, visit https://www.gnu.org/software/make/manual/make.html#Phony-Targets)
.PHONY: clean cleanobj cleanbin cleanimg
.PHONY: all main build read process write
# Use "make" to execute everything
all: build main
# Use "make main" to compile the main
main: $(PROJ_NAME)
# Use "make build" to build all the modules
build: util read process write
# Use "make util" to build only the util module
util: $(objdir)/util.o
# Use "make read" to build only the read module
read: $(objdir)/read.o
# Use "make process" to build only the process module
process: $(objdir)/process.o
# Use "make write" to build only the write module
write: $(objdir)/write.o
# Compiles the main
catarata: $(srcdir)/main.c $(OBJS)
# mkdir -p $(bindir)
$(CC) $(CFLAGS) $^ -o $@ -lm
# Builds only the util module
$(objdir)/util.o: $(srcdir)/util.c $(incdir)/util.h
mkdir -p $(objdir)
$(CC) $(CFLAGS) -c $< -o $@ -lm
# Builds only the reading module (use "make read")
$(objdir)/read.o: $(srcdir)/read.c $(incdir)/read.h $(incdir)/util.h
mkdir -p $(objdir)
$(CC) $(CFLAGS) -c $< -o $@ -lm
# Builds only the processing module (use "make process")
$(objdir)/process.o: $(srcdir)/process.c $(incdir)/process.h $(incdir)/util.h
mkdir -p $(objdir)
$(CC) $(CFLAGS) -c $< -o $@ -lm
# Builds only the writing module (use "make write")
$(objdir)/write.o: $(srcdir)/write.c $(incdir)/write.h $(incdir)/util.h
mkdir -p $(objdir)
$(CC) $(CFLAGS) -c $< -o $@ -lm
# Removes all objects
cleanobj:
$(RM) -rf $(objdir)
# Removes all executables
cleanbin:
$(RM) -rf $(bindir)
$(RM) $(PROJ_NAME)
# Removes all images
cleanimg:
$(RM) ./test/*
# Removes all executables and all objects
clean: cleanobj cleanbin cleanimg