-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
58 lines (46 loc) · 1.21 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
TARGET_EXEC := bbsh.exe
INC_DIRS := include
BUILD_DIR := build
OBJS_DIR := build/objs
SRC_DIR := src
CC=gcc
INC_FLAGS := -I$(INC_DIRS)
SRCS := $(shell find $(SRC_DIR) -name '*.c' -or -name '*.s')
OBJS := $(SRCS:$(SRC_DIR)/%.c=$(OBJS_DIR)/%.o)
bbsh: $(OBJS) # Won't delete the files, only makes
@$(CC) $(INC_FLAGS) -g $(OBJS) -lm -o $(TARGET_EXEC)
@chmod +x $(TARGET_EXEC)
@echo Compiled... Please check ./bbsh.exe
$(OBJS_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(BUILD_DIR) $(OBJS_DIR)
@$(CC) $(INC_FLAGS) -lm -c $< -o $@
clean:
@rm -rf ./build
@rm -f bbsh.exe
@echo Cleaned Files
# CUSTOM COMMANDS, NOT FOR NORMAL USE
full:
@rm -rf ./build
@rm -f bbsh.exe
@make bbsh
@echo Prefer using make bbsh directly, as some features may not work here
@./bbsh.exe
@rm -rf ./build
@rm -f bbsh.exe
@echo Cleaned Files
debug: $(OBJS)
@$(CC) $(INC_FLAGS) -g $(OBJS) -lm -o $(TARGET_EXEC)
@chmod +x $(TARGET_EXEC)
@echo Compiled... Running
@gdb ./$(TARGET_EXEC)
@rm -rf ./build
@rm -f bbsh.exe
@echo Cleaned Files
valgrind: $(OBJS)
@$(CC) $(INC_FLAGS) -g $(OBJS) -lm -o $(TARGET_EXEC)
@chmod +x $(TARGET_EXEC)
@echo Compiled... Running
@valgrind ./$(TARGET_EXEC)
@rm -rf ./build
@rm -f bbsh.exe
@echo Cleaned Files