From b99436543acc5389e1202bffa1400769492fad12 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Tue, 4 Aug 2026 13:17:53 +0300 Subject: [PATCH 1/4] makefile: Make CC and ASM overridable via command line This makes it easier to run make without docker within distros without editing Makefile. For example Fedora: `ASM=sdcc-sdas8051 CC=sdcc-sdcc make` --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3b8027b..5d018d1 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,9 @@ DEFAULT_CONFIG_LOCATION = 454656 CONFIG_LOCATION = 458752 HTML_LOCATION = 262144 -CC = sdcc +CC ?= sdcc CC_FLAGS = -mmcs51 -I. -Ihttpd -Iuip -ASM = sdas8051 +ASM ?= sdas8051 AFLAGS= -plosgff SUBDIRS := tools From adb0b54691021a01d96788bafc8e6ea75ae33e69 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Tue, 4 Aug 2026 17:57:53 +0300 Subject: [PATCH 2/4] makefile: Reorder sources to immediately fail on invalid MACHINE Also group and reorder source files and move each of these to separate line. --- Makefile | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5d018d1..868a273 100644 --- a/Makefile +++ b/Makefile @@ -37,10 +37,40 @@ create_build_dir: 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 -SRCS += rtl837x_stp.c rtl837x_pins.c dhcp.c machine.c cmd_editor.c rtl837x_bandwidth.c rtl837x_init.c syslog.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 udp_apps.c -SRCS += httpd/httpd.c httpd/page_impl.c +# Keep machine.c in first position to fail immediately on invalid $MACHINE value +SRCS = \ + machine.c \ + cmd_editor.c \ + cmd_parser.c \ + dhcp.c \ + html_data.c \ + rtlplayground.c \ + syslog.c \ + udp_apps.c + +# RTL837x +SRCS += \ + rtl837x_bandwidth.c \ + rtl837x_flash.c \ + rtl837x_igmp.c \ + rtl837x_init.c \ + rtl837x_leds.c \ + rtl837x_phy.c \ + rtl837x_pins.c\ + rtl837x_port.c \ + rtl837x_stp.c +SRCS += \ + httpd/httpd.c \ + httpd/page_impl.c +SRCS += \ + uip/timer.c \ + uip/uip.c \ + uip/uiplib.c \ + uip/uip_arp.c \ + uip/uip-fw.c \ + uip/uip-neighbor.c \ + uip/uip-split.c + OBJS = ${SRCS:%.c=$(BUILDDIR)/%.rel} DEPS := ${SRCS:%.c=$(BUILDDIR)/%.d} HTML := $(shell find $(html) -name '*.js' -or -name '*.html' -or -name '*.svg') From bebe79c4c9fb009ef52318276f1cf22364e8418a Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Tue, 4 Aug 2026 18:52:59 +0300 Subject: [PATCH 3/4] makefile: Fix possible shell injections in makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 868a273..2bcb077 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,9 @@ FILENAME_EXTENSION = $(VERSION_EXTENSION)-$(MACHINE) all: create_build_dir $(VERSION_HEADER) $(SUBDIRS) $(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin create_build_dir: - mkdir -p $(BUILDDIR) - mkdir -p $(BUILDDIR)/uip - mkdir -p $(BUILDDIR)/httpd + mkdir -p "$(BUILDDIR)" + mkdir -p "$(BUILDDIR)/uip" + mkdir -p "$(BUILDDIR)/httpd" # Keep machine.c in first position to fail immediately on invalid $MACHINE value SRCS = \ From 3c89b222070342f2fc9cd06b3915f8ab20a49be8 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Tue, 4 Aug 2026 21:55:28 +0300 Subject: [PATCH 4/4] makefile: Use origin check for CC variable Make defines defaults for commonly used variables, therefore we need to check first how the variable was defined. If `default` value was used, override it with our own default. --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2bcb077..0cbc04f 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,9 @@ DEFAULT_CONFIG_LOCATION = 454656 CONFIG_LOCATION = 458752 HTML_LOCATION = 262144 -CC ?= sdcc +ifeq ($(origin CC),default) +CC = sdcc +endif CC_FLAGS = -mmcs51 -I. -Ihttpd -Iuip ASM ?= sdas8051 AFLAGS= -plosgff