mirror of
https://github.com/antos-rde/antos.git
synced 2025-08-31 00:02:08 +02:00
feat: Support CI and cross compile for amd64, arm64, arm
All checks were successful
gitea-sync/antos/pipeline/head This commit looks good
All checks were successful
gitea-sync/antos/pipeline/head This commit looks good
This commit is contained in:
144
Makefile
144
Makefile
@@ -1,125 +1,167 @@
|
||||
|
||||
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
TAG:=$(subst master,stable,$(subst refs/heads/,,$(shell git symbolic-ref -q HEAD)))
|
||||
|
||||
PLATFORM?=x86_64
|
||||
ARCH?=amd64
|
||||
VERSION?=2.0.0-b
|
||||
|
||||
RUSTUP_HOME?=/opt/rust
|
||||
CARGO_HOME?=/opt/rust/cargo
|
||||
RUST_TARGET?=x86_64-unknown-linux-gnu
|
||||
|
||||
DESTDIR?=$(ROOT_DIR)/build/
|
||||
BUILD_PREFIX:=$(DESTDIR)/opt/www
|
||||
|
||||
VERSION?=2.0.0
|
||||
BRANCH?=b
|
||||
BUILDID=$(shell git rev-parse --short HEAD)
|
||||
ifeq ('$(ARCH)','amd64')
|
||||
RUST_TARGET?=x86_64-unknown-linux-gnu
|
||||
CC_PREFIX?=
|
||||
HOST?=
|
||||
endif
|
||||
|
||||
VERSION_STR=$(VERSION)-$(BRANCH)-$(BUILDID)
|
||||
PKG_NAME="AntOS_${VERSION_STR}_${PLATFORM}"
|
||||
ifeq ('$(ARCH)','arm64')
|
||||
RUST_TARGET?=aarch64-unknown-linux-gnu
|
||||
CC_PREFIX?=aarch64-linux-gnu-
|
||||
HOST?=--host=aarch64-linux-gnu
|
||||
endif
|
||||
|
||||
all: antos deb tar.gz appimg
|
||||
ifeq ('$(ARCH)','arm')
|
||||
RUST_TARGET?=armv7-unknown-linux-gnueabihf
|
||||
CC_PREFIX?=arm-linux-gnueabihf-
|
||||
HOST?=--host=arm-linux-gnueabihf
|
||||
endif
|
||||
|
||||
CC:=$(CC_PREFIX)gcc
|
||||
CXX:=$(CC_PREFIX)g++
|
||||
BUILD_PREFIX:=/opt/www
|
||||
INSTALL_DIR:=$(DESTDIR)/$(ARCH)/$(BUILD_PREFIX)
|
||||
|
||||
BUILDID:=$(shell git rev-parse --short HEAD)
|
||||
|
||||
VERSION_STR=$(VERSION)-$(BUILDID)
|
||||
PKG_NAME="AntOS_${VERSION_STR}_${ARCH}"
|
||||
|
||||
all: antos tar.gz
|
||||
|
||||
antos: antd backend frontend
|
||||
cp $(ROOT_DIR)/README.md $(INSTALL_DIR)/htdocs/os
|
||||
|
||||
antd: httpd plugins luasec luasocket silk luafcgi
|
||||
rm $(BUILD_PREFIX)/runner.ini
|
||||
cp $(ROOT_DIR)/config/*.ini $(BUILD_PREFIX)/etc
|
||||
rm $(INSTALL_DIR)/runner.ini
|
||||
cp $(ROOT_DIR)/config/*.ini $(INSTALL_DIR)/etc
|
||||
rm $(INSTALL_DIR)/bin/ant-d $(INSTALL_DIR)/bin/runnerd
|
||||
@echo "Finish building Antd server"
|
||||
|
||||
httpd:
|
||||
httpd: clean_c
|
||||
cd $(ROOT_DIR)/antd/ant-http && libtoolize && aclocal && autoconf && automake --add-missing
|
||||
cd $(ROOT_DIR)/antd/ant-http && ./configure --prefix=$(BUILD_PREFIX)
|
||||
make -C $(ROOT_DIR)/antd/ant-http install
|
||||
cd $(ROOT_DIR)/antd/ant-http && ./configure $(HOST) --prefix=$(BUILD_PREFIX)
|
||||
DESTDIR=$(DESTDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/ant-http install
|
||||
|
||||
plugins: antd-fcgi-plugin antd-tunnel-plugin antd-wvnc-plugin antd-tunnel-publishers
|
||||
@echo "Finish making plugins"
|
||||
|
||||
luasec:
|
||||
luasec: clean_c
|
||||
@echo "Building $@"
|
||||
lua5.3 $(ROOT_DIR)/antd/luasec/src/options.lua -g \
|
||||
/usr/include/openssl/ssl.h \
|
||||
> $(ROOT_DIR)/antd/luasec/src/options.c
|
||||
CC=$(CC) \
|
||||
INC_PATH=-I$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
|
||||
make -C $(ROOT_DIR)/antd/luasec linux
|
||||
CC=$(CC) \
|
||||
INC_PATH=-I$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
|
||||
DESTDIR=$(DESTDIR) \
|
||||
DESTDIR=$(DESTDIR)/$(ARCH) \
|
||||
LUAPATH=/opt/www/lib/lua \
|
||||
LUACPATH=/opt/www/lib/lua \
|
||||
make -C $(ROOT_DIR)/antd/luasec install
|
||||
|
||||
luasocket:
|
||||
luasocket: clean_c
|
||||
@echo "Building $@"
|
||||
sed -i 's/^CC_linux=/CC_linux?=/g' $(ROOT_DIR)/antd/luasocket/src/makefile
|
||||
sed -i 's/^LD_linux=/LD_linux?=/g' $(ROOT_DIR)/antd/luasocket/src/makefile
|
||||
CC_linux=$(CC) \
|
||||
LD_linux=$(CC) \
|
||||
LUAV=5.4 \
|
||||
LUAINC_linux=$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
|
||||
LUAPREFIX_linux=$(DESTDIR) \
|
||||
LUAPREFIX_linux=$(BUILD_PREFIX) \
|
||||
PLAT=linux \
|
||||
make -C $(ROOT_DIR)/antd/luasocket linux
|
||||
CC_linux=$(CC) \
|
||||
LD_linux=$(CC) \
|
||||
LUAV=5.4 \
|
||||
LUAINC_linux=$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
|
||||
LUAPREFIX_linux=$(DESTDIR) \
|
||||
LUAPREFIX_linux=$(BUILD_PREFIX) \
|
||||
PLAT=linux \
|
||||
make -C $(ROOT_DIR)/antd/luasocket install-unix
|
||||
-mkdir -p $(DESTDIR)/lib/lua
|
||||
cp -rf $(DESTDIR)/lib/lua/5.4/* $(DESTDIR)/opt/www/lib/lua/
|
||||
cp -rf $(DESTDIR)/share/lua/5.4/* $(DESTDIR)/opt/www/lib/lua/
|
||||
rm -rf $(DESTDIR)/lib $(DESTDIR)/share
|
||||
DESTDIR=$(DESTDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/luasocket install-unix
|
||||
-mkdir -p $(INSTALL_DIR)/lib/lua
|
||||
cp -rf $(INSTALL_DIR)/lib/lua/5.4/* $(INSTALL_DIR)/lib/lua/
|
||||
cp -rf $(INSTALL_DIR)/share/lua/5.4/* $(INSTALL_DIR)/lib/lua/
|
||||
rm -rf $(INSTALL_DIR)/lib/lua/5.4 $(INSTALL_DIR)/share
|
||||
|
||||
antd-% sil%: httpd
|
||||
antd-% sil%: clean_c
|
||||
@echo "Building $@"
|
||||
cd $(ROOT_DIR)/antd/$@ && libtoolize && aclocal && autoconf && automake --add-missing
|
||||
cd $(ROOT_DIR)/antd/$@ && CFLAGS="-I$(BUILD_PREFIX)/include" LDFLAGS="-L$(BUILD_PREFIX)/lib" ./configure --prefix=$(BUILD_PREFIX)
|
||||
make -C $(ROOT_DIR)/antd/$@ install
|
||||
cd $(ROOT_DIR)/antd/$@ && CFLAGS="-I$(INSTALL_DIR)/include" LDFLAGS="-L$(INSTALL_DIR)/lib" \
|
||||
./configure $(HOST) --prefix=$(BUILD_PREFIX)
|
||||
DESTDIR=$(DESTDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/$@ install
|
||||
|
||||
luafcgi:
|
||||
ifeq ($(LUAFCGI_IGNORE),)
|
||||
@echo "Building $@"
|
||||
mkdir -p $(INSTALL_DIR)/bin
|
||||
RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) \
|
||||
. $(CARGO_HOME)/env && \
|
||||
rustup default stable && \
|
||||
rustup target add $(RUST_TARGET) && \
|
||||
cargo build --target=$(RUST_TARGET) --release \
|
||||
--manifest-path=$(ROOT_DIR)/antd/luafcgi/Cargo.toml
|
||||
install -m 0755 $(ROOT_DIR)/antd/luafcgi/target/$(RUST_TARGET)/release/luad $(BUILD_PREFIX)/bin
|
||||
--manifest-path=$(ROOT_DIR)/antd/luafcgi/Cargo.toml \
|
||||
--config=$(ROOT_DIR)/antd/luafcgi/.cargo/config.toml
|
||||
install -m 0755 $(ROOT_DIR)/antd/luafcgi/target/$(RUST_TARGET)/release/luad $(INSTALL_DIR)/bin
|
||||
else
|
||||
@echo "Ignore building $@"
|
||||
endif
|
||||
|
||||
clean:
|
||||
@echo "Clean all target"
|
||||
make -C antd/ant-http clean
|
||||
make -C antd/antd-fcgi-plugin clean
|
||||
make -C antd/antd-tunnel-plugin clean
|
||||
make -C antd/antd-wvnc-plugin clean
|
||||
make -C antd/antd-tunnel-publishers clean
|
||||
make -C antd/luasec clean
|
||||
make -C antd/luasocket clean
|
||||
make -C antd/silk clean
|
||||
clean_c:
|
||||
@echo "Clean all C based modules"
|
||||
-make -C antd/ant-http clean
|
||||
-make -C antd/antd-fcgi-plugin clean
|
||||
-make -C antd/antd-tunnel-plugin clean
|
||||
-make -C antd/antd-wvnc-plugin clean
|
||||
-make -C antd/antd-tunnel-publishers clean
|
||||
-make -C antd/luasec clean
|
||||
-make -C antd/luasocket clean
|
||||
-make -C antd/silk clean
|
||||
|
||||
clean: clean_c
|
||||
@echo "Clean Rust project and output DIR"
|
||||
RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) \
|
||||
. $(CARGO_HOME)/env && cargo clean --manifest-path=$(ROOT_DIR)/antd/luafcgi/Cargo.toml
|
||||
. $(CARGO_HOME)/env && \
|
||||
rustup default stable && \
|
||||
cargo clean \
|
||||
--manifest-path=$(ROOT_DIR)/antd/luafcgi/Cargo.toml \
|
||||
--config=$(ROOT_DIR)/antd/luafcgi/.cargo/config.toml
|
||||
-rm -rf $(DESTDIR)/*
|
||||
|
||||
backend:
|
||||
@echo "Building $@"
|
||||
DESTDIR=$(BUILD_PREFIX)/htdocs/os make -C antos-backend
|
||||
mkdir -p $(INSTALL_DIR)/htdocs/os
|
||||
DESTDIR=$(INSTALL_DIR)/htdocs/os make -C antos-backend
|
||||
|
||||
frontend:
|
||||
ifeq ($(FRONTEND_IGNORE),)
|
||||
@echo "Building $@"
|
||||
BUILDDIR=$(BUILD_PREFIX)/htdocs/os make -C antos-frontend install_dev release
|
||||
mkdir -p $(INSTALL_DIR)/htdocs/os
|
||||
BUILDDIR=$(INSTALL_DIR)/htdocs/os make -C antos-frontend install_dev release
|
||||
else
|
||||
@echo "Ignore building $@"
|
||||
endif
|
||||
|
||||
deb: antos
|
||||
-rm $(DESTDIR)/*.deb
|
||||
scripts/mkdeb.sh $(VERSION_STR) $(PLATFORM) $(DESTDIR)
|
||||
deb:
|
||||
-rm $(DESTDIR)/$(ARCH)/*.deb
|
||||
scripts/mkdeb.sh $(VERSION_STR) $(ARCH) $(DESTDIR)/$(ARCH)
|
||||
|
||||
tar.gz: antos
|
||||
-rm $(DESTDIR)/$(PKG_NAME).tar.gz
|
||||
cd $(DESTDIR)/ && tar cvzf $(PKG_NAME).tar.gz opt
|
||||
-rm $(DESTDIR)/$(ARCH)/$(PKG_NAME).tar.gz
|
||||
cd $(DESTDIR)/$(ARCH)/ && tar cvzf $(PKG_NAME).tar.gz opt
|
||||
|
||||
appimg: antos
|
||||
-rm $(DESTDIR)/*.AppImage
|
||||
scripts/mkappimg.sh $(PLATFORM) $(VERSION_STR) $(DESTDIR) $(ROOT_DIR)/antos-64.png
|
||||
appimg:
|
||||
-rm $(DESTDIR)/$(ARCH)/*.AppImage
|
||||
scripts/mkappimg.sh $(ARCH) $(VERSION_STR) $(DESTDIR)/$(ARCH) $(ROOT_DIR)/antos-64.png
|
||||
|
||||
.PHONY: antd antos
|
Reference in New Issue
Block a user