12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- DOWNLOADER ?= curl
- PLATFORM ?= linux
- BINOUT := bin
- STDLIB := stdlib
- QBE_SRC := https://c9x.me/compile
- HARE_SRC := https://git.sr.ht/~sircmpwn/hare
- HAREC_SRC := https://git.sr.ht/~sircmpwn/harec
- QBE_VERSION := 1.2
- HARE_VERSION := 0.24.2
- HAREC_VERSION := 0.24.2
- .PHONY: all
- all: ${BINOUT}/hare ${BINOUT}/harec ${BINOUT}/qbe
- # download function should downlad file ${1} from url ${2}
- ifeq (${DOWNLOADER},curl)
- download = curl -Lo '${1}' -- '${2}'
- else # if curl
- ifeq (${DOWNLOADER},wget)
- download = wget -O '${1}' -- '${2}'
- endif # if wget
- endif # if curl
- sh_pwd = "$${PWD:-$$(pwd)}/${1}"
- # $1 - archive
- # $2 - url
- # $3 - name
- # $4 - out bin
- # $5 - cmd
- define dl_install
- set -x \
- && tmp="$$(mktemp -d)" \
- && { bin="$$( : \
- && set -ue \
- && cd "$${tmp}" \
- && $(call download,${1},${2}) \
- && tar xf ${1} \
- && cd ${3}-*/ \
- && `# temporary fix:` \
- && ( [ ! -f scripts/version ] || sed 's/\(VERSION:\)\([^-]\)/\1-\2/' -i scripts/version; ) \
- && { ${5}; } 1>&2 \
- && echo $(call sh_pwd,${4}) \
- )" \
- && install -Dm755 "$${bin}" ${@} \
- ; } \
- && rm -rf "$${tmp}" # if failed tmdir will remain
- endef
- .MAKE_DIR := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
- .HARE_COMPILE := : \
- && dst='${.MAKE_DIR}' \
- && ln -s configs/${PLATFORM}.mk config.mk \
- && make LDFLAGS='-O3 -static -Wl,-s' \
- QBE='${.MAKE_DIR}/${BINOUT}/qbe' \
- HAREC='${.MAKE_DIR}/${BINOUT}/harec' \
- .bin/hare \
- && make DESTDIR="$${dst}/" STDLIB='${STDLIB}' install-mods
- ${BINOUT}/hare: ${BINOUT}/harec ${BINOUT}/qbe
- $(call dl_install,hare.tar.gz,${HARE_SRC}/archive/${HARE_VERSION}.tar.gz,\
- hare,.bin/hare,${.HARE_COMPILE})
- .QBE_COMPILE := make LDFLAGS='-O3 -static -Wl,-s'
- ${BINOUT}/qbe:
- $(call dl_install,qbe.tar.xz,${QBE_SRC}/release/qbe-${QBE_VERSION}.tar.xz,\
- qbe,qbe,${.QBE_COMPILE})
- .HAREC_COMPILE := : \
- && ln -s configs/${PLATFORM}.mk config.mk \
- && make LDFLAGS='-O3 -static -Wl,-s'
- ${BINOUT}/harec:
- $(call dl_install,harec.tar.gz,${HAREC_SRC}/archive/${HAREC_VERSION}.tar.gz,\
- harec,.bin/harec,${.HAREC_COMPILE})
|