From fc4b12725cf5b52e337a102daae2bb9fed8d2ade Mon Sep 17 00:00:00 2001 From: feelfree69 Date: Tue, 10 Mar 2026 21:57:16 +0100 Subject: [PATCH 1/5] Cleanup Makefile --- Makefile | 27 +++++++++++---------------- httpd/Makefile | 26 -------------------------- uip/Makefile | 26 -------------------------- 3 files changed, 11 insertions(+), 68 deletions(-) delete mode 100644 httpd/Makefile delete mode 100644 uip/Makefile diff --git a/Makefile b/Makefile index e403d34..e903b92 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ CC_FLAGS = -mmcs51 -I. -Ihttpd -Iuip ASM = sdas8051 AFLAGS= -plosgff -SUBDIRS := tools uip httpd +SUBDIRS := tools SUBDIRSCLEAN=$(addsuffix clean,$(SUBDIRS)) BUILDDIR = output/ @@ -24,11 +24,14 @@ all: create_build_dir $(VERSION_HEADER) $(SUBDIRS) $(BUILDDIR)rtlplayground.bin create_build_dir: mkdir -p $(BUILDDIR) + mkdir -p $(BUILDDIR)/uip + mkdir -p $(BUILDDIR)/httpd -SRCS = rtlplayground.c rtl837x_flash.c rtl837x_leds.c rtl837x_phy.c rtl837x_port.c cmd_parser.c html_data.c rtl837x_igmp.c \ - rtl837x_stp.c rtl837x_pins.c dhcp.c machine.c cmd_editor.c rtl837x_bandwidth.c +SRCS = rtlplayground.c rtl837x_flash.c rtl837x_leds.c rtl837x_phy.c rtl837x_port.c cmd_parser.c html_data.c rtl837x_igmp.c +SRCS += rtl837x_stp.c rtl837x_pins.c dhcp.c machine.c cmd_editor.c rtl837x_bandwidth.c +SRCS += uip/timer.c uip/uip.c uip/uip_arp.c uip/uiplib.c uip/uip-fw.c uip/uip-neighbor.c uip/uip-split.c +SRCS += httpd/httpd.c httpd/page_impl.c OBJS = ${SRCS:%.c=$(BUILDDIR)%.rel} -OBJS += uip/$(BUILDDIR)/timer.rel uip/$(BUILDDIR)/uip-fw.rel uip/$(BUILDDIR)/uip-neighbor.rel uip/$(BUILDDIR)/uip-split.rel uip/$(BUILDDIR)/uip.rel uip/$(BUILDDIR)/uip_arp.rel uip/$(BUILDDIR)/uiplib.rel httpd/$(BUILDDIR)/httpd.rel httpd/$(BUILDDIR)/page_impl.rel html_data.c html_data.h: html tools tools/$(BUILDDIR)fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -b BANK1 -d html -p html_data @@ -46,21 +49,13 @@ $(SUBDIRS): $(MAKE) -C $@ clean: - -make -C uip clean - -make -C httpd clean - -rm html_data.c html_data.h $(VERSION_HEADER) - -rm -r $(BUILDDIR) - -$(BUILDDIR)crtstart.rel: crtstart.asm - $(ASM) $(AFLAGS) -o $@ $< - -$(BUILDDIR)crc16.rel: crc16.asm - $(ASM) $(AFLAGS) -o $@ $< + -rm -f html_data.c html_data.h $(VERSION_HEADER) + -rm -rf $(BUILDDIR) $(BUILDDIR)%.rel: %.c $(CC) $(CC_FLAGS) -o $@ -c $< -$(BUILDDIR)%.rel: $(BUILDDIR)%.asm +$(BUILDDIR)%.rel: %.asm ${ASM} ${AFLAGS} -o $@ $< # mv -f $(addprefix $(basename $^), .lst .rel .sym) . @@ -79,4 +74,4 @@ $(BUILDDIR)rtlplayground.bin: $(BUILDDIR)rtlplayground.img tools/$(BUILDDIR)crc_calculator -u $@ -.PHONY: clean all $(SUBDIRS) +.PHONY: clean all $(SUBDIRS) $(VERSION_HEADER) diff --git a/httpd/Makefile b/httpd/Makefile deleted file mode 100644 index 242c8b7..0000000 --- a/httpd/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -CC = sdcc -CC_FLAGS = -mmcs51 -I. -I.. -I../uip -ASM = sdas8051 -AFLAGS= -plosgff - -BUILDDIR = output/ - -SRCS = httpd.c page_impl.c -OBJS = ${SRCS:%.c=$(BUILDDIR)%.rel} - -all: create_build_dir $(OBJS) - -create_build_dir: - mkdir -p $(BUILDDIR) - -$(BUILDDIR)%.asm: %.c - $(CC) $(CC_FLAGS) -o $@ -c -S $< - -$(BUILDDIR)%.rel: $(BUILDDIR)%.asm - ${ASM} ${AFLAGS} -o $@ $^ - -clean: - rm -r $(BUILDDIR) - -.PHONY: all clean - diff --git a/uip/Makefile b/uip/Makefile deleted file mode 100644 index d275a58..0000000 --- a/uip/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -CC = sdcc -CC_FLAGS = -mmcs51 -I. -I.. -I../httpd -ASM = sdas8051 -AFLAGS= -plosgff - -BUILDDIR = output/ - -SRCS = timer.c uip_arp.c uip.c uip-fw.c uiplib.c uip-neighbor.c uip-split.c -OBJS = ${SRCS:%.c=$(BUILDDIR)%.rel} - -all: create_build_dir $(OBJS) - -create_build_dir: - mkdir -p $(BUILDDIR) - -$(BUILDDIR)%.rel: %.c - $(CC) $(CC_FLAGS) -o $@ -c $< - -$(BUILDDIR)%.rel: $(BUILDDIR)%.asm - ${ASM} ${AFLAGS} $^ - -clean: - rm -r $(BUILDDIR) - -.PHONY: all clean - From 13fe354da75b8d20b6338b98af4daebb5a5136aa Mon Sep 17 00:00:00 2001 From: feelfree69 Date: Wed, 11 Mar 2026 07:26:15 +0100 Subject: [PATCH 2/5] add dependency file generation --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e903b92..34ba2e6 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ SRCS += rtl837x_stp.c rtl837x_pins.c dhcp.c machine.c cmd_editor.c rtl837x_bandw SRCS += uip/timer.c uip/uip.c uip/uip_arp.c uip/uiplib.c uip/uip-fw.c uip/uip-neighbor.c uip/uip-split.c SRCS += httpd/httpd.c httpd/page_impl.c OBJS = ${SRCS:%.c=$(BUILDDIR)%.rel} +DEPS := ${SRCS:%.c=$(BUILDDIR)%.d} html_data.c html_data.h: html tools tools/$(BUILDDIR)fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -b BANK1 -d html -p html_data @@ -53,7 +54,7 @@ clean: -rm -rf $(BUILDDIR) $(BUILDDIR)%.rel: %.c - $(CC) $(CC_FLAGS) -o $@ -c $< + $(CC) -MMD $(CC_FLAGS) -o $@ -c $< $(BUILDDIR)%.rel: %.asm ${ASM} ${AFLAGS} -o $@ $< @@ -75,3 +76,5 @@ $(BUILDDIR)rtlplayground.bin: $(BUILDDIR)rtlplayground.img .PHONY: clean all $(SUBDIRS) $(VERSION_HEADER) + +-include $(DEPS) \ No newline at end of file From b559c3b868d468eb1f337633ffa62af245b8d656 Mon Sep 17 00:00:00 2001 From: feelfree69 Date: Wed, 11 Mar 2026 07:34:18 +0100 Subject: [PATCH 3/5] avoid doubled generation of html_data.* --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 34ba2e6..6387436 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ SRCS += httpd/httpd.c httpd/page_impl.c OBJS = ${SRCS:%.c=$(BUILDDIR)%.rel} DEPS := ${SRCS:%.c=$(BUILDDIR)%.d} -html_data.c html_data.h: html tools +html_data.c: html tools tools/$(BUILDDIR)fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -b BANK1 -d html -p html_data $(VERSION_HEADER): From dc9b211924b45c4e4c474a66d21b13f0dde1d10e Mon Sep 17 00:00:00 2001 From: feelfree69 Date: Wed, 11 Mar 2026 19:01:21 +0100 Subject: [PATCH 4/5] BUILDDIR without slash --- Makefile | 30 +++++++++++++++--------------- tools/Makefile | 18 +++++++++--------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 6387436..94b5ead 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ AFLAGS= -plosgff SUBDIRS := tools SUBDIRSCLEAN=$(addsuffix clean,$(SUBDIRS)) -BUILDDIR = output/ +BUILDDIR = output VERSION_HEADER := version.h ifeq ($(MACHINE),) @@ -20,7 +20,7 @@ else CC_FLAGS += -DMACHINE_$(MACHINE) endif -all: create_build_dir $(VERSION_HEADER) $(SUBDIRS) $(BUILDDIR)rtlplayground.bin +all: create_build_dir $(VERSION_HEADER) $(SUBDIRS) $(BUILDDIR)/rtlplayground.bin create_build_dir: mkdir -p $(BUILDDIR) @@ -31,11 +31,11 @@ SRCS = rtlplayground.c rtl837x_flash.c rtl837x_leds.c rtl837x_phy.c rtl837x_port SRCS += rtl837x_stp.c rtl837x_pins.c dhcp.c machine.c cmd_editor.c rtl837x_bandwidth.c SRCS += uip/timer.c uip/uip.c uip/uip_arp.c uip/uiplib.c uip/uip-fw.c uip/uip-neighbor.c uip/uip-split.c SRCS += httpd/httpd.c httpd/page_impl.c -OBJS = ${SRCS:%.c=$(BUILDDIR)%.rel} -DEPS := ${SRCS:%.c=$(BUILDDIR)%.d} +OBJS = ${SRCS:%.c=$(BUILDDIR)/%.rel} +DEPS := ${SRCS:%.c=$(BUILDDIR)/%.d} html_data.c: html tools - tools/$(BUILDDIR)fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -b BANK1 -d html -p html_data + tools/$(BUILDDIR)/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -b BANK1 -d html -p html_data $(VERSION_HEADER): @echo "#ifndef VERSION_H" > $(VERSION_HEADER) @@ -53,26 +53,26 @@ clean: -rm -f html_data.c html_data.h $(VERSION_HEADER) -rm -rf $(BUILDDIR) -$(BUILDDIR)%.rel: %.c +$(BUILDDIR)/%.rel: %.c $(CC) -MMD $(CC_FLAGS) -o $@ -c $< -$(BUILDDIR)%.rel: %.asm +$(BUILDDIR)/%.rel: %.asm ${ASM} ${AFLAGS} -o $@ $< # mv -f $(addprefix $(basename $^), .lst .rel .sym) . -$(BUILDDIR)rtlplayground.ihx: $(OBJS) $(BUILDDIR)crtstart.rel $(BUILDDIR)crc16.rel +$(BUILDDIR)/rtlplayground.ihx: $(OBJS) $(BUILDDIR)/crtstart.rel $(BUILDDIR)/crc16.rel $(CC) $(CC_FLAGS) -Wl-bHOME=0x00000 -Wl-bBANK1=0x14000 -Wl-bBANK2=0x24000 -Wl-r -o $@ $^ -$(BUILDDIR)rtlplayground.img: $(BUILDDIR)rtlplayground.ihx +$(BUILDDIR)/rtlplayground.img: $(BUILDDIR)/rtlplayground.ihx objcopy --input-target=ihex -O binary $< $@ -$(BUILDDIR)rtlplayground.bin: $(BUILDDIR)rtlplayground.img +$(BUILDDIR)/rtlplayground.bin: $(BUILDDIR)/rtlplayground.img if [ -e $@ ]; then rm $@; fi - tools/$(BUILDDIR)imagebuilder -i $^ $@ - tools/$(BUILDDIR)fileadder -a $(DEFAULT_CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@ - tools/$(BUILDDIR)fileadder -a $(CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@ - tools/$(BUILDDIR)fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -d html -p html_data $@ - tools/$(BUILDDIR)crc_calculator -u $@ + tools/$(BUILDDIR)/imagebuilder -i $^ $@ + tools/$(BUILDDIR)/fileadder -a $(DEFAULT_CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@ + tools/$(BUILDDIR)/fileadder -a $(CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@ + tools/$(BUILDDIR)/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -d html -p html_data $@ + tools/$(BUILDDIR)/crc_calculator -u $@ .PHONY: clean all $(SUBDIRS) $(VERSION_HEADER) diff --git a/tools/Makefile b/tools/Makefile index 3533faa..c7143c5 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,27 +1,27 @@ CC = gcc CCFLAGS = -Wall -o -BUILDDIR = output/ +BUILDDIR = output -all: create_build_dir $(BUILDDIR)injector $(BUILDDIR)fileadder $(BUILDDIR)httpd_sim\ - $(BUILDDIR)crc_calculator $(BUILDDIR)imagebuilder +all: create_build_dir $(BUILDDIR)/injector $(BUILDDIR)/fileadder $(BUILDDIR)/httpd_sim\ + $(BUILDDIR)/crc_calculator $(BUILDDIR)/imagebuilder create_build_dir: mkdir -p $(BUILDDIR) clean: - rm -r $(BUILDDIR) + rm -rf $(BUILDDIR) -$(BUILDDIR)injector: injector.c +$(BUILDDIR)/injector: injector.c gcc $^ $(CCFLAGS) $@ -$(BUILDDIR)fileadder: fileadder.c +$(BUILDDIR)/fileadder: fileadder.c gcc $^ $(CCFLAGS) $@ -$(BUILDDIR)crc_calculator: crc_calculator.c +$(BUILDDIR)/crc_calculator: crc_calculator.c gcc $^ $(CCFLAGS) $@ -$(BUILDDIR)httpd_sim: httpd_sim.c httpd_sim.h +$(BUILDDIR)/httpd_sim: httpd_sim.c httpd_sim.h gcc $< $(CCFLAGS) $@ -I/usr/include/json-c -ljson-c -$(BUILDDIR)imagebuilder: imagebuilder.c +$(BUILDDIR)/imagebuilder: imagebuilder.c gcc $^ $(CCFLAGS) $@ From 765000ce4fe5afde983afdaf276b54b2dd4edbcc Mon Sep 17 00:00:00 2001 From: feelfree69 Date: Wed, 11 Mar 2026 19:08:32 +0100 Subject: [PATCH 5/5] fixed html dependencies --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 94b5ead..54a5a4f 100644 --- a/Makefile +++ b/Makefile @@ -33,8 +33,9 @@ SRCS += uip/timer.c uip/uip.c uip/uip_arp.c uip/uiplib.c uip/uip-fw.c uip/uip-ne SRCS += httpd/httpd.c httpd/page_impl.c OBJS = ${SRCS:%.c=$(BUILDDIR)/%.rel} DEPS := ${SRCS:%.c=$(BUILDDIR)/%.d} +HTML := $(shell find $(html) -name '*.js' -or -name '*.html' -or -name '*.svg') -html_data.c: html tools +html_data.c html_data.h: $(HTML) tools/$(BUILDDIR)/fileadder tools/$(BUILDDIR)/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -b BANK1 -d html -p html_data $(VERSION_HEADER):