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)))
|
|
|
|
|
|
|
|
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
|
|
|
|
TARGET_CONFIG=$(TOP_DIR)/configs/common.config $(TOP_DIR)/configs/$(MAINTARGET)-$(SUBTARGET).config
|
|
|
|
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 ...)
|
2020-03-25 18:57:56 -06:00
|
|
|
FW_VERSION=$(PRIVATE_BUILD_VERSION)
|
2018-03-23 01:39:07 -06:00
|
|
|
else
|
2020-03-25 18:57:56 -06:00
|
|
|
FW_VERSION=$(PRIVATE_BUILD_VERSION)
|
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
|
2018-07-11 21:30:46 -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)/
|
|
|
|
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
|
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 libpam
|
|
|
|
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 perl
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install -p arednpackages vtun
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install -a -p arednpackages
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install snmpd
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install ntpclient
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install socat
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install xinetd
|
|
|
|
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
|
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install luaposix
|
2019-03-26 21:49:33 -06:00
|
|
|
cd $(OPENWRT_DIR); ./scripts/feeds install luasocket
|
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)
|
2018-07-11 21:30:46 -06:00
|
|
|
for FILE in `find $(TOP_DIR)/firmware/targets/ -path "*packages" -prune -o \( -type f -a \
|
2020-01-22 18:37:27 -07:00
|
|
|
! \( -name "*factory.bin" -o -name "*sysupgrade.bin" -o -name "*initramfs.elf" -o \
|
|
|
|
-name sha256sums -o -name "*.buildinfo" \) \
|
2018-07-11 21:30:46 -06:00
|
|
|
-print \)`; do rm $$FILE; \
|
|
|
|
done;
|
|
|
|
for FILE in `find $(TOP_DIR)/firmware/targets/ -type f -a \
|
2020-01-22 18:37:27 -07:00
|
|
|
\( -name "*ar71xx-generic-*" \
|
|
|
|
-o -name "*ath79-generic-*" \
|
|
|
|
-o -name "*ar71xx-mikrotik*squashfs*" \
|
2018-07-11 21:30:46 -06:00
|
|
|
\) -print`; do \
|
2020-01-22 18:37:27 -07:00
|
|
|
NEWNAME="$${FILE/generic-/}"; \
|
2018-03-23 01:39:07 -06:00
|
|
|
NEWNAME="$${NEWNAME/squashfs-/}"; \
|
|
|
|
mv "$$FILE" "$$NEWNAME"; \
|
|
|
|
done;
|
|
|
|
$(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:
|