# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Neil H. Gray
#
# =====================================================================
# Zenith Serial Disk Server Makefile
# =====================================================================

CC = gcc
CFLAGS = -g -Wall
NASM = nasm
NASMFLAGS = -f bin

# Target binaries
all: serial_server bootser.bin bootstub.bin

config.inc: config.h gen_config.py
	python3 gen_config.py

bootser.bin: serial_port_boot_sector.asm config.inc
	$(NASM) $(NASMFLAGS) serial_port_boot_sector.asm -o bootser.bin -l bootser.lst

bootstub.bin : micro_stub.asm config.inc
	$(NASM) $(NASMFLAGS) micro_stub.asm -o bootstub.bin -l bootstub.lst

serial_server: serial_server.c config.h
	$(CC) $(CFLAGS) serial_server.c -o serial_server

# Clean up generated build artifacts
clean:
	rm -f serial_server bootser.bin bootser.lst bootstub.bin bootstub.lst config.inc
