forked from sofa-do-DA/occulum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (46 loc) · 1.11 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
# Compilador
CC = gcc
# Padrão da linguagem
STD = -std=c99 -Wall
# Flags para o compilador
CC_FLAGS = -c -Wpedantic -Wno-unused-result -O0 -g
# Flags para bibliotecas
LIBRARIES =
INCLUDES = ./includes
# Arquivos .c
C_SRC = $(wildcard ./src/*.c ./libs/*.c)
# Arquivos .h
H_SRC = $(wildcard $(INCLUDES)/*.h)
# Arquivos objeto
OBJ := $(patsubst %.c,./objs/%.o,$(notdir $(C_SRC)))
# Nome do binário
binary = main
all: show objdir bindir $(binary)
$(binary): $(OBJ) $(objdir)
@echo "Compilando o alvo principal: $@"
$(CC) $(STD) $^ -o ./bin/$@ $(LIBRARIES) -I. -I$(INCLUDES)
@echo
clean:
@echo "Limpando projeto..."
@-rm -rf ./objs
@-rm -rf ./bin
@echo "Projeto limpo"
@echo
show:
@echo "C source files: $(C_SRC)"
@echo "Header files: $(H_SRC)"
@echo "Object files: $(OBJ)"
@echo
objdir:
@mkdir -p ./objs
bindir:
@mkdir -p ./bin
./objs/main.o: ./src/main.c $(H_SRC)
@echo 'Compilando o alvo para: $<'
$(CC) $< $(STD) $(CC_FLAGS) -I. -I$(INCLUDES) -o $@
@echo
./objs/%.o: ./libs/%.c
@echo 'Compilando o alvo para: $<'
$(CC) $< -fPIC $(STD) $(CC_FLAGS) -I. -I$(INCLUDES) -o $@
@echo
.PHONY: all clean