mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
Merge pull request #709 from L4ky/add-config-path-to-makefile
Add CONFIG parameter to make
This commit is contained in:
2 files changed
+32
-7
No files matched your search
@@ -4,6 +4,10 @@ DEFAULT_CONFIG_LOCATION = 454656
|
|||||||
CONFIG_LOCATION = 458752
|
CONFIG_LOCATION = 458752
|
||||||
HTML_LOCATION = 262144
|
HTML_LOCATION = 262144
|
||||||
|
|
||||||
|
# Startup configuration embedded in the image. Override it to build a specific
|
||||||
|
# machine with its own configuration: make MACHINE=<name> CONFIG=<file>
|
||||||
|
CONFIG ?= config.txt
|
||||||
|
|
||||||
SDCC_TOOLCHAIN = sdcc-$(shell cat sdcc/* | cksum | cut -d' ' -f1)
|
SDCC_TOOLCHAIN = sdcc-$(shell cat sdcc/* | cksum | cut -d' ' -f1)
|
||||||
SDCC_PREFIX = toolchain/$(SDCC_TOOLCHAIN)
|
SDCC_PREFIX = toolchain/$(SDCC_TOOLCHAIN)
|
||||||
ifeq ($(origin CC),default)
|
ifeq ($(origin CC),default)
|
||||||
@@ -56,6 +60,7 @@ ifndef BUILDDIR
|
|||||||
BUILDDIR = output/$(MACHINE)
|
BUILDDIR = output/$(MACHINE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
CONFIG_STAMP := $(BUILDDIR)/.config
|
||||||
VERSION_HEADER := version.h
|
VERSION_HEADER := version.h
|
||||||
|
|
||||||
GIT_VERSION := $(shell git rev-parse --short HEAD)
|
GIT_VERSION := $(shell git rev-parse --short HEAD)
|
||||||
@@ -78,9 +83,10 @@ BUILD_DATE := $(shell date -u -d @$(SOURCE_DATE_EPOCH) +"%Y-%m-%d %H:%M:%S" 2>/d
|
|||||||
|| date -u -r $(SOURCE_DATE_EPOCH) +"%Y-%m-%d %H:%M:%S")
|
|| date -u -r $(SOURCE_DATE_EPOCH) +"%Y-%m-%d %H:%M:%S")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# $(MACHINE_SRC) is listed here so an unknown $MACHINE fails before anything else
|
# $(MACHINE_SRC) and $(CONFIG) are listed here so an unknown $MACHINE or a
|
||||||
# is built, including the tools/ subdirectory.
|
# missing config file fails before anything else is built, including the tools/
|
||||||
all: create_build_dir $(VERSION_HEADER) $(MACHINE_SRC) $(SUBDIRS) $(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin
|
# subdirectory.
|
||||||
|
all: create_build_dir $(VERSION_HEADER) $(MACHINE_SRC) $(CONFIG) $(SUBDIRS) $(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin
|
||||||
|
|
||||||
bank_size:
|
bank_size:
|
||||||
tools/bank_occupancy.sh "$(MACHINE)"
|
tools/bank_occupancy.sh "$(MACHINE)"
|
||||||
@@ -101,6 +107,12 @@ $(MACHINE_SRC):
|
|||||||
@echo " Example: make MACHINE=KP_9000_6XHML_X2" >&2
|
@echo " Example: make MACHINE=KP_9000_6XHML_X2" >&2
|
||||||
@false
|
@false
|
||||||
|
|
||||||
|
# Fail with a clear message when CONFIG names a file that does not exist.
|
||||||
|
$(CONFIG):
|
||||||
|
@echo "ERROR: CONFIG='$(CONFIG)' does not exist." >&2
|
||||||
|
@echo " Point CONFIG at a configuration file, or omit it to use config.txt." >&2
|
||||||
|
@false
|
||||||
|
|
||||||
# Keep the per-machine definition in first position to fail immediately on an
|
# Keep the per-machine definition in first position to fail immediately on an
|
||||||
# invalid $MACHINE value
|
# invalid $MACHINE value
|
||||||
SRCS = \
|
SRCS = \
|
||||||
@@ -220,6 +232,12 @@ FORCE:
|
|||||||
$(CCFLAGS_STAMP): FORCE | create_build_dir
|
$(CCFLAGS_STAMP): FORCE | create_build_dir
|
||||||
@echo '$(CC_FLAGS)' | cmp -s - $@ 2>/dev/null || echo '$(CC_FLAGS)' > $@
|
@echo '$(CC_FLAGS)' | cmp -s - $@ 2>/dev/null || echo '$(CC_FLAGS)' > $@
|
||||||
|
|
||||||
|
# The same for $(CONFIG): its path is stamped so switching to a config file
|
||||||
|
# older than the image still rebuilds it, while $(CONFIG) itself as a normal
|
||||||
|
# prerequisite covers edits to the selected file.
|
||||||
|
$(CONFIG_STAMP): FORCE | create_build_dir
|
||||||
|
@echo '$(CONFIG)' | cmp -s - $@ 2>/dev/null || echo '$(CONFIG)' > $@
|
||||||
|
|
||||||
$(BUILDDIR)/%.rel: %.c $(CCFLAGS_STAMP) | create_build_dir html_data.h
|
$(BUILDDIR)/%.rel: %.c $(CCFLAGS_STAMP) | create_build_dir html_data.h
|
||||||
$(CC) -MMD $(CC_FLAGS) -o $@ -c $<
|
$(CC) -MMD $(CC_FLAGS) -o $@ -c $<
|
||||||
|
|
||||||
@@ -233,11 +251,11 @@ $(BUILDDIR)/rtlplayground.ihx: $(OBJS) $(BUILDDIR)/crtbank.rel $(BUILDDIR)/crc16
|
|||||||
$(BUILDDIR)/rtlplayground.img: $(BUILDDIR)/rtlplayground.ihx
|
$(BUILDDIR)/rtlplayground.img: $(BUILDDIR)/rtlplayground.ihx
|
||||||
objcopy --input-target=ihex -O binary $< $@
|
objcopy --input-target=ihex -O binary $< $@
|
||||||
|
|
||||||
$(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin: $(BUILDDIR)/rtlplayground.img | tools
|
$(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin: $(BUILDDIR)/rtlplayground.img $(CONFIG) $(CONFIG_STAMP) | tools
|
||||||
if [ -e $@ ]; then rm $@; fi
|
if [ -e $@ ]; then rm $@; fi
|
||||||
tools/$(BUILDDIR)/imagebuilder -i $^ $@
|
tools/$(BUILDDIR)/imagebuilder -i $(BUILDDIR)/rtlplayground.img $@
|
||||||
tools/$(BUILDDIR)/fileadder -a $(DEFAULT_CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@
|
tools/$(BUILDDIR)/fileadder -a $(DEFAULT_CONFIG_LOCATION) -s $(IMAGESIZE) -d "$(CONFIG)" $@
|
||||||
tools/$(BUILDDIR)/fileadder -a $(CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@
|
tools/$(BUILDDIR)/fileadder -a $(CONFIG_LOCATION) -s $(IMAGESIZE) -d "$(CONFIG)" $@
|
||||||
tools/$(BUILDDIR)/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -z -d $(HTML_MIN) -b BANK1 $@
|
tools/$(BUILDDIR)/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -z -d $(HTML_MIN) -b BANK1 $@
|
||||||
tools/$(BUILDDIR)/crc_calculator -u $@
|
tools/$(BUILDDIR)/crc_calculator -u $@
|
||||||
ln -sf $(MACHINE)/rtlplayground-$(FILENAME_EXTENSION).bin $(BUILDDIR)/../rtlplayground.bin
|
ln -sf $(MACHINE)/rtlplayground-$(FILENAME_EXTENSION).bin $(BUILDDIR)/../rtlplayground.bin
|
||||||
|
|||||||
@@ -127,6 +127,13 @@ The name selects the board definition `machine/<name>.c`; `make` without a
|
|||||||
`MACHINE` value stops with an error listing what is expected. If your board is
|
`MACHINE` value stops with an error listing what is expected. If your board is
|
||||||
not in the list yet, see [Adding a new device](doc/adding-a-device.md).
|
not in the list yet, see [Adding a new device](doc/adding-a-device.md).
|
||||||
|
|
||||||
|
To embed a machine-specific startup configuration, pass `CONFIG`:
|
||||||
|
```
|
||||||
|
make MACHINE=DEFAULT_8C_1SFP CONFIG=configs/DEFAULT_8C_1SFP.txt
|
||||||
|
```
|
||||||
|
`CONFIG` defaults to `config.txt`; the selected file is embedded in the image
|
||||||
|
and changing it triggers a rebuild.
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> You can write configuration parameters in config.txt (see below) in order your switch to get
|
> You can write configuration parameters in config.txt (see below) in order your switch to get
|
||||||
> straight at the first boot, a correct IP configuration.
|
> straight at the first boot, a correct IP configuration.
|
||||||
|
|||||||
Reference in new issue
Block a user