-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
56 lines (42 loc) · 1.06 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
BIN_DIR := bin
OBJ_DIR := build
DUMP_DIR := dump
INC_DIR := inc
SRC_DIR := src
TARGET := $(BIN_DIR)/perceptron
PPM := model.ppm
INCLUDES := $(shell find $(INC_DIR)/* -type f \( -iname "*.inc" \) )
SOURCES := $(shell find $(SRC_DIR)/* -type f \( -iname "*.asm" \) )
OBJECTS := $(foreach OBJECT, $(patsubst %.asm, %.o, $(SOURCES)), $(OBJ_DIR)/$(OBJECT))
AS := nasm
AS_FLAGS = -f elf64 -g
LD := ld
LD_FLAGS :=
GDB := gdb
GDB_FLAGS := -ex 'set confirm off' \
-ex 'file $(TARGET)' \
-ex 'break _start' \
-ex 'layout asm' \
-ex 'layout regs' \
-ex 'run $(TARGET)'
.PHONY: .FORCE
.FORCE:
all: build
build: clean $(TARGET)
$(TARGET): $(OBJECTS)
@mkdir -p $(DUMP_DIR)
@mkdir -p $(@D)
$(LD) $(LD_FLAGS) $+ -o $@
$(OBJ_DIR)/%.o: %.asm
@mkdir -p $(@D)
$(AS) $(AS_FLAGS) $< -o $@
clean:
@rm -rf $(BIN_DIR)/* $(OBJ_DIR)/* $(DUMP_DIR)/*
@rm -f $(PPM)
debug: build
$(GDB) $(GDB_FLAGS)
run: build
@$(TARGET)
assets:
@ffmpeg -y -i $(DUMP_DIR)/weights-%d.ppm -vf scale=320:-1 -filter:v "setpts=PTS/15,fps=30" docs/training.mp4
@convert model.ppm docs/model.png