# pcb/Makefile
#
# Builds only, into build/; publishing is ../ops/publish_pcb.sh.


BUILD_DIR		:= build
SRC_DIR			:= src/kicad

SCH_SRC			:= $(SRC_DIR)/keyboard.kicad_sch
SCHEMATIC_PDF	:= $(BUILD_DIR)/schematic.pdf

MKDIR			:= mkdir
MKDIR_FLAGS		:= -p
# The design is KiCad 10's; for the AppImage: make KICAD="kicad kicad-cli"
KICAD			?= kicad-cli


.PHONY: all clean schematic

all: schematic

$(BUILD_DIR):
	$(MKDIR) $(MKDIR_FLAGS) $@

# The schematic as PDF, from the design: never edited by hand, so it is the
# schematic as it is
schematic: $(SCHEMATIC_PDF)

$(SCHEMATIC_PDF): $(SCH_SRC) | $(BUILD_DIR)
	$(KICAD) sch export pdf --output $@ $<

clean:
	- $(RM) -r $(BUILD_DIR)
