-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (32 loc) · 1.01 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
# constants
AS = nasm
ASFLAGS = -f bin
PYTHON = python3
QEMU = qemu-system-i386
QEMUFLAGS = -accel kvm
SRC_DIR = src
BUILD_DIR = build
SOURCES = $(sort $(wildcard $(SRC_DIR)/*.asm))
EXECUTABLE = bad_apple.img
VIDEO_PATH = video.flv
FPS = $(shell mediainfo --Output='Video;%FrameRate_Num%' $(VIDEO_PATH))
FRAME_COUNT = $(shell mediainfo --Output='Video;%FrameCount%' $(VIDEO_PATH))
RELOAD_VALUE = $$((1193182 / $(FPS)))
ASCII_GRADIENT = oxxo
# phony
.PHONY: all run clean
# targets
all: $(BUILD_DIR)/$(EXECUTABLE)
run: $(BUILD_DIR)/$(EXECUTABLE)
$(QEMU) $(QEMUFLAGS) -drive format=raw,file=$^
clean:
$(RM) -r build
# rules
$(BUILD_DIR)/$(EXECUTABLE): $(BUILD_DIR)/bootloader.bin $(BUILD_DIR)/data.bin
cat $^ > $@
$(BUILD_DIR)/bootloader.bin: $(SOURCES) | $(BUILD_DIR)
$(AS) $(ASFLAGS) -DPIT_RELOAD_VALUE=$(RELOAD_VALUE) -DFRAME_AMOUNT=$(FRAME_COUNT) $< -o $@
$(BUILD_DIR)/data.bin: $(VIDEO_PATH) | $(BUILD_DIR)
$(PYTHON) $(SRC_DIR)/converter/main.py --gradient $(ASCII_GRADIENT) $< -o $@
$(BUILD_DIR):
mkdir -p $@