From 65ba8e4c07b25f218b905819b989b5d23d92f723 Mon Sep 17 00:00:00 2001 From: uvok Date: Thu, 25 Dec 2025 10:51:48 +0100 Subject: makefile: Try fix dep rule --- Makefile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4dbe558..5f3d026 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,10 @@ CST ?= tangnano9k.cst FLASH_OPTS ?= YOSYS_OPTS ?= -Q -q -l $(PROGRAM).yosys.log DEPS := $(wildcard *.dep) +# this is "bad", as it runs the deps target every time +# probably because of the include below +# SOURCES := $(wildcard *.v) +# DEPS := $(SOURCES:.v=.dep) # yosys deps-file doesn't work, it writes ": infile depfiles" #-E $(PROGRAM).deps @@ -30,19 +34,22 @@ flash: $(PROGRAM).fs openFPGALoader -b tangnano9k $(FLASH_OPTS) $(PROGRAM).fs clean: - rm -rf *.json *.fs *.svg *.log *.deps + rm -rf *.json *.fs *.svg *.log *.dep synth: $(PROGRAM).json -deps: $(PROGRAM).deps +deps: $(DEPS) ## Patterns # synthesize -%.json: %.v +# re-synth if deps change (and create in the first place) +%.json: %.v %.dep yosys -p "read_verilog $<; synth_gowin -top $* -json $@" $(YOSYS_OPTS) -%.deps: %.v +# because yosys -E is buggy, or behaves differently than expected, +# use gawk to force-create deps. +%.dep: %.v gawk 'match($$0, /`include "(.*)"/, ary) {print FILENAME, ":", ary[1]}' $< > $@ # place and route? -- cgit v1.2.3