-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (34 loc) · 970 Bytes
/
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
# Compilador
CC = gcc
# CFLAGS = -g -Wall -O0
CFLAGS = -g -O3 # Flag -Wall removida para funcionar no runcodes
INCLUDE = $(wildcard src/*.h)
SOURCES = $(wildcard src/*.c)
OBJ = $(SOURCES:$(SRC_DIR)/%.c = $(SRC_DIR)/%.o)
# Diretórios
SRC_DIR = src
BIN_DIR = bin
# Target
NOME_EXECUTAVEL = brain
TARGET = $(BIN_DIR)/$(NOME_EXECUTAVEL)
# Criar diretórios bin e build
$(BIN_DIR):
mkdir -p $(BIN_DIR)
# Compilar arquivos .c em arquivos .o
$(SRC_DIR)/%.o: $(SRC_DIR)/%.c $(INC_DIR)/%.h
$(CC) $(CFLAGS) -c $< -o $@
# Set the default goal to 'all'
.DEFAULT_GOAL := all
all: $(OBJ) $(BIN_DIR)
$(CC) $(CFLAGS) $(OBJ) -o $(TARGET) -lm
debug: $(OBJ) $(BIN_DIR)
$(CC) $(CFLAGS) $(OBJ) -o $(TARGET) -DDEBUG
run:
$(TARGET)
clean:
@rm -f $(BUILD_DIR)/*.o ./*.zip $(BIN_DIR)/* core
# Só funciona no linux (ow WSL)
zip:
@rm -f *.zip
zip -r $(NOME_EXECUTAVEL).zip $(SRC_DIR)/* ./Makefile
.PHONY: all debug run clean zip