-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
55 lines (45 loc) · 1.39 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
# =========================================================================
#
# Cheap-8 Makefile
#
# TODO: (list of "maybes")
# - Maybe add separate targets to compile with or without debugger
# - Maybe add a separate target for cheap8 compiler after it's developed
# - Maybe add "make menuconfig" like shit after more functionalities are developed
#
# =========================================================================
# Program name
TARGET = cheap8
# Compiler
CC = gcc
CFLAGS = -I -Wall -Werror
# Linker
LINKER = gcc
LFLAGS = -lsdl2 -lm -lpanel -lform -lncurses
# Sources, objects and binaries directories
SRCDIR = src
OBJDIR = obj
BINDIR = bin
SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
# Compiling objects file into an executable (or a binary)
$(BINDIR)/$(TARGET): $(OBJECTS)
@mkdir -p $(BINDIR)
@$(LINKER) $(OBJECTS) $(LFLAGS) -o $@
@echo "Linking done"
# Making object files from all the source files
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@mkdir -p $(OBJDIR)
@$(CC) $(CFLAGS) -c $< -o $@
@echo "Compiled "$<
# Clean object files but leave a binary file in place
.PHONY: clean
clean:
@rm -f $(OBJECTS)
@echo "All object files successfully cleared"
# Delete both object files and a binary
.PHONY: remove
remove: clean
@rm -f $(BINDIR)/$(TARGET)
@echo "Executable successfully removed"