-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (39 loc) · 1.16 KB
/
Makefile
File metadata and controls
51 lines (39 loc) · 1.16 KB
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
TARGET=cad
# Files
SOURCE_DIR:=src
SOURCE_FILES:=$(wildcard $(SOURCE_DIR)/*.c $(SOURCE_DIR)/*/*.c)
HEADER_FILES:=$(wildcard $(SOURCE_DIR)/*.h $(SOURCE_DIR)/*/*.h)
ASSEMB_FILES:=$(wildcard $(SOURCE_DIR)/*.S $(SOURCE_DIR)/*/*.S)
OBJ:=${SOURCE_FILES:.c=.o}
OBJ+=${ASSEMB_FILES:.S=.o}
# Compiler
CC:=gcc
ARCH:=arm64
FONT_INCLUDE:=-I/opt/homebrew/opt/freetype/include/freetype2 -I/opt/homebrew/opt/libpng/include/libpng16
GL_INCLUDE:=-framework Cocoa -framework OpenGL -framework IOKit
CFLAGS:=-arch $(ARCH) -I$(SOURCE_DIR) $(GL_INCLUDE) $(FONT_INCLUDE) -F /Library/Frameworks -g
LIBS:= -lglfw3 -framework UL -L/opt/homebrew/opt/freetype/lib -lfreetype
# Assembler
ASM:=gcc
ASMFLAGS:=-arch arm64
# Preprocessor
PP:=gcc
PPFLAGS:=-E
# Rules
%.o: %.S Makefile
$(PP) $< -o tmp.tmp $(PPFLAGS)
sed /^#/d tmp.tmp > preprocessed.tmp.s
$(RM) tmp.tmp
$(ASM) -c -o $@ preprocessed.tmp.s $(ASMFLAGS)
$(RM) preprocessed.tmp.s
%.o: %.c $(HEADER_FILES) Makefile
$(CC) -c -o $@ $< $(CFLAGS) $(LIBS)
$(TARGET): $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
run: $(TARGET)
./$(TARGET)
install: $(TARGET)
echo "export PATH=\"\$$PATH:$(PWD)\"" >> ~/.zshrc
clean:
$(RM) $(OBJ)
$(RM) $(TARGET)