2018-03-23 01:39:07 -06:00
|
|
|
include config.mk
|
|
|
|
include openwrt.mk
|
|
|
|
|
|
|
|
# get main- and subtarget name from TARGET
|
|
|
|
MAINTARGET=$(word 1, $(subst -, ,$(TARGET)))
|
|
|
|
SUBTARGET=$(word 2, $(subst -, ,$(TARGET)))
|
2022-12-22 13:22:49 -07:00
|
|
|
ALTTARGET=$(word 3, $(subst -, ,$(TARGET)))
|
2018-03-23 01:39:07 -06:00
|
|
|
|
|
|
|
GIT_BRANCH=$(shell git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
|
|
|
|
GIT_COMMIT=$(shell git rev-parse --short HEAD)
|
|
|
|
|
|
|
|
# set dir and file names
|
|
|
|
TOP_DIR=$(shell pwd)
|
|
|
|
OPENWRT_DIR=$(TOP_DIR)/openwrt
|
2022-12-22 13:22:49 -07:00
|
|
|
TARGET_CONFIG=$(TOP_DIR)/configs/common.config $(TOP_DIR)/configs/$(MAINTARGET)-$(SUBTARGET)$(patsubst %,-%,$(ALTTARGET)).config
|
2018-03-23 01:39:07 -06:00
|
|
|
UMASK=umask 022
|
|
|
|
|
2018-07-11 21:30:46 -06:00
|
|
|
# set variables based on private or CircleCI build
|
|
|
|
ifeq ($(CIRCLECI),true)
|
|
|
|
$(info CircleCI build ...)
|
2023-04-16 17:36:39 -06:00
|
|
|
FW_VERSION=$(PRIVATE_BUILD_VERSION)-$(GIT_COMMIT)
|
2018-03-23 01:39:07 -06:00
|
|
|
else
|
2020-03-28 16:27:58 -06:00
|
|
|
FW_VERSION=$(PRIVATE_BUILD_VERSION)-$(GIT_BRANCH)-$(GIT_COMMIT)
|
2018-03-23 01:39:07 -06:00
|
|
|
endif
|
|
|
|
|
|
|
|
# test for existing $TARGET-config or abort
|
|
|
|
ifeq ($(wildcard $(TOP_DIR)/configs/$(TARGET).config),)
|
|
|
|
$(error config for $(TARGET) not defined)
|
|
|
|
endif
|
|
|
|
|
|
|
|
default: compile
|
|
|
|
|
|
|
|
# clone openwrt
|
|
|
|
$(OPENWRT_DIR): .stamp-openwrt-removed
|
|
|
|
git clone $(OPENWRT_SRC) $(OPENWRT_DIR)
|
|
|
|
cd $(OPENWRT_DIR); git checkout $(OPENWRT_COMMIT)
|
|
|
|
ln -sf $(TOP_DIR)/patches $(OPENWRT_DIR)/
|
|
|
|
ln -sf $(TOP_DIR)/files $(OPENWRT_DIR)/
|
|
|
|
touch .stamp-openwrt-cleaned
|
|
|
|
rm -f .stamp-unpatched
|
|
|
|
|
|
|
|
# when updating openwrt.mk to point to another repo
|
|
|
|
.stamp-openwrt-removed: openwrt.mk
|
|
|
|
rm -rf $(OPENWRT_DIR)
|
|
|
|
rm -f .stamp*
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
# clean up openwrt working copy
|
|
|
|
openwrt-clean: stamp-clean-openwrt-cleaned .stamp-openwrt-cleaned
|
2021-07-18 20:20:23 -06:00
|
|
|
.stamp-openwrt-cleaned: | $(OPENWRT_DIR)
|
2018-03-23 01:39:07 -06:00
|
|
|
cd $(OPENWRT_DIR); \
|
|
|
|
./scripts/feeds clean && \
|
|
|
|
git clean -dff && git fetch && git reset --hard HEAD && \
|
|
|
|
rm -rf .config feeds.conf build_dir/target-* logs/
|
|
|
|
rm -rf $(TOP_DIR)/results
|
2018-11-17 11:22:28 -07:00
|
|
|
rm -rf $(TOP_DIR)/.pc
|
2018-03-23 01:39:07 -06:00
|
|
|
rm -f .stamp-unpatched
|
|
|
|
ln -sf $(TOP_DIR)/patches $(OPENWRT_DIR)/
|
|
|
|
ln -sf $(TOP_DIR)/files $(OPENWRT_DIR)/
|
2021-02-25 06:21:49 -07:00
|
|
|
sed -i "s/^.*freifunk.*$$//" $(OPENWRT_DIR)/feeds.conf.default
|
2022-12-22 13:22:49 -07:00
|
|
|
sed -i "s/luci.git$$/luci.git;openwrt-22.03/" $(OPENWRT_DIR)/feeds.conf.default
|
2018-03-23 01:39:07 -06:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
# update openwrt and checkout specified commit
|
|
|
|
openwrt-update: .stamp-openwrt-updated .stamp-unpatched
|
|
|
|
.stamp-openwrt-updated: stamp-clean-openwrt-updated .stamp-openwrt-cleaned
|
|
|
|
cd $(OPENWRT_DIR); git checkout --detach $(OPENWRT_COMMIT)
|
|
|
|
rm -f .stamp-unpatched
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
# feeds
|
|
|
|
$(OPENWRT_DIR)/feeds.conf: feeds.conf
|
|
|
|
cp $(TOP_DIR)/feeds.conf $@
|
|
|
|
cat $(OPENWRT_DIR)/feeds.conf.default >> $@
|
|
|
|
|
|
|
|
# update feeds
|
|
|
|
feeds-update: stamp-clean-feeds-updated .stamp-feeds-updated
|
|
|
|
.stamp-feeds-updated: $(OPENWRT_DIR)/feeds.conf
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds uninstall -a
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds update -a
|
2022-12-22 13:22:49 -07:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install libpam
|
2020-01-22 18:37:27 -07:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install libcap
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install jansson
|
2018-08-08 10:45:45 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install libidn2
|
2018-03-31 09:13:16 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install liblzma
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install libssh2
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install libidn
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install libopenldap
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install libgnutls
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install libnetsnmp
|
2018-03-23 01:39:07 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install -p arednpackages olsrd
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install -p arednpackages vtun
|
2022-12-22 13:22:49 -07:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install -p arednpackages dd-wrt-ath10k-firmware
|
2023-04-20 19:34:52 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install -p arednpackages prometheus-exporter
|
2018-03-23 01:39:07 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install snmpd
|
2022-12-22 13:22:49 -07:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install curl
|
2018-03-23 01:39:07 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install ntpclient
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install socat
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install luci-base
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install luci-lib-nixio
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install luci-lib-ip
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install luci-lib-jsonc
|
2019-03-26 21:49:33 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install luasocket
|
2022-12-22 13:22:49 -07:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install iperf3
|
2023-09-15 22:54:55 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install micrond
|
2022-12-22 13:22:49 -07:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install mii-tool
|
2021-07-18 20:20:23 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install mmc-utils
|
2018-03-23 01:39:07 -06:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
# prepare patch
|
|
|
|
pre-patch: stamp-clean-pre-patch .stamp-pre-patch
|
|
|
|
.stamp-pre-patch: $(wildcard $(TOP_DIR)/patches/*) | $(OPENWRT_DIR)
|
|
|
|
rm -f .stamp-unpatched
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
# patch openwrt working copy
|
|
|
|
patch: stamp-clean-patched .stamp-patched
|
2018-08-08 10:45:45 -06:00
|
|
|
.stamp-patched: .stamp-pre-patch .stamp-unpatched .stamp-feeds-updated
|
2018-03-23 01:39:07 -06:00
|
|
|
cd $(OPENWRT_DIR); quilt push -a || [ $$? = 2 ] && true
|
|
|
|
rm -rf $(OPENWRT_DIR)/tmp
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
.stamp-build_rev: .FORCE
|
|
|
|
ifneq (,$(wildcard .stamp-build_rev))
|
|
|
|
ifneq ($(shell cat .stamp-build_rev),$(FW_VERSION))
|
|
|
|
echo $(FW_VERSION) | diff >/dev/null -q $@ - || echo -n $(FW_VERSION) >$@
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
echo -n $(FW_VERSION) >$@
|
|
|
|
endif
|
|
|
|
|
|
|
|
# openwrt config
|
2018-05-19 23:39:51 -06:00
|
|
|
$(OPENWRT_DIR)/.config: .stamp-feeds-updated $(TARGET_CONFIG) .stamp-build_rev always
|
2018-03-23 01:39:07 -06:00
|
|
|
cat $(TARGET_CONFIG) >$(OPENWRT_DIR)/.config
|
|
|
|
echo "CONFIG_VERSION_NUMBER=\"$(FW_VERSION)\"" >>$(OPENWRT_DIR)/.config
|
|
|
|
echo "$(FW_VERSION)" >$(TOP_DIR)/files/etc/mesh-release
|
2018-07-11 21:30:46 -06:00
|
|
|
echo "CONFIG_VERSION_REPO=\"$(PRIVATE_BUILD_PACKAGES)\"" >>$(OPENWRT_DIR)/.config
|
2018-03-23 01:39:07 -06:00
|
|
|
$(UMASK); \
|
|
|
|
$(MAKE) -C $(OPENWRT_DIR) defconfig
|
|
|
|
|
|
|
|
# prepare openwrt .config
|
|
|
|
prepare: stamp-clean-prepared .stamp-prepared
|
|
|
|
.stamp-prepared: .stamp-patched .stamp-feeds-updated $(OPENWRT_DIR)/.config
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
# compile
|
|
|
|
compile: stamp-clean-compiled .stamp-compiled
|
2018-07-11 21:30:46 -06:00
|
|
|
.stamp-compiled: .stamp-prepared .stamp-feeds-updated | $(TOP_DIR)/firmware
|
2018-03-23 01:39:07 -06:00
|
|
|
$(TOP_DIR)/scripts/tests-prebuild.sh
|
|
|
|
$(UMASK); \
|
|
|
|
$(MAKE) -C $(OPENWRT_DIR) $(MAKE_ARGS)
|
2022-12-22 13:22:49 -07:00
|
|
|
for FILE in `find $(TOP_DIR)/firmware/targets/$(MAINTARGET)/$(SUBTARGET) -path "*packages" -prune -o \( -type f -a \
|
2023-04-28 12:01:58 -06:00
|
|
|
! \( -name "*factory.bin" -o -name "*sysupgrade.bin" -o -name "*x86*" -o -name "*initramfs*" -o -name sha256sums -o -name "*.buildinfo" -o -name "*.json" \) \
|
2018-07-11 21:30:46 -06:00
|
|
|
-print \)`; do rm $$FILE; \
|
|
|
|
done;
|
2018-03-23 01:39:07 -06:00
|
|
|
$(TOP_DIR)/scripts/tests-postbuild.sh
|
|
|
|
|
|
|
|
$(TOP_DIR)/firmware:
|
2018-03-31 09:13:16 -06:00
|
|
|
ln -sf $(OPENWRT_DIR)/bin/ $(TOP_DIR)/firmware
|
2018-03-23 01:39:07 -06:00
|
|
|
|
|
|
|
stamp-clean-%:
|
|
|
|
rm -f .stamp-$*
|
|
|
|
|
|
|
|
stamp-clean:
|
|
|
|
rm -f .stamp-*
|
|
|
|
|
|
|
|
# unpatch needs "patches/" in openwrt
|
2018-05-19 23:39:51 -06:00
|
|
|
.stamp-unpatched:
|
2018-03-23 01:39:07 -06:00
|
|
|
# RC = 2 of quilt --> nothing to be done
|
|
|
|
cd $(OPENWRT_DIR); quilt pop -a -f || [ $$? = 2 ] && true
|
|
|
|
rm -rf $(OPENWRT_DIR)/tmp
|
|
|
|
rm -f .stamp-patched
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
clean: stamp-clean .stamp-openwrt-cleaned
|
|
|
|
|
2018-07-11 21:30:46 -06:00
|
|
|
.PHONY: openwrt-clean openwrt-update patch feeds-update prepare compile stamp-clean clean always
|
2018-03-23 01:39:07 -06:00
|
|
|
.NOTPARALLEL:
|
|
|
|
.FORCE:
|