2024-03-09 21:38:11 +01:00
|
|
|
|
|
|
|
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
2024-03-10 00:17:53 +01:00
|
|
|
TAG:=$(subst master,stable,$(subst refs/heads/,,$(shell git symbolic-ref -q HEAD)))
|
2024-03-09 21:38:11 +01:00
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
ARCH?=amd64
|
|
|
|
VERSION?=2.0.0-b
|
2024-03-09 21:38:11 +01:00
|
|
|
|
|
|
|
RUSTUP_HOME?=/opt/rust
|
|
|
|
CARGO_HOME?=/opt/rust/cargo
|
2024-03-10 00:17:53 +01:00
|
|
|
DESTDIR?=$(ROOT_DIR)/build/
|
|
|
|
|
|
|
|
ifeq ('$(ARCH)','amd64')
|
2024-03-09 21:38:11 +01:00
|
|
|
RUST_TARGET?=x86_64-unknown-linux-gnu
|
2024-03-10 00:17:53 +01:00
|
|
|
CC_PREFIX?=
|
|
|
|
HOST?=
|
|
|
|
endif
|
2024-03-09 21:38:11 +01:00
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
ifeq ('$(ARCH)','arm64')
|
|
|
|
RUST_TARGET?=aarch64-unknown-linux-gnu
|
|
|
|
CC_PREFIX?=aarch64-linux-gnu-
|
|
|
|
HOST?=--host=aarch64-linux-gnu
|
|
|
|
endif
|
2024-03-09 21:38:11 +01:00
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
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)
|
2024-03-09 21:38:11 +01:00
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
VERSION_STR=$(VERSION)-$(BUILDID)
|
|
|
|
PKG_NAME="AntOS_${VERSION_STR}_${ARCH}"
|
2024-03-09 21:38:11 +01:00
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
all: antos tar.gz
|
2024-03-09 21:38:11 +01:00
|
|
|
|
|
|
|
antos: antd backend frontend
|
2024-03-10 00:17:53 +01:00
|
|
|
cp $(ROOT_DIR)/README.md $(INSTALL_DIR)/htdocs/os
|
2024-03-09 21:38:11 +01:00
|
|
|
|
|
|
|
antd: httpd plugins luasec luasocket silk luafcgi
|
2024-03-10 00:17:53 +01:00
|
|
|
rm $(INSTALL_DIR)/runner.ini
|
|
|
|
cp $(ROOT_DIR)/config/*.ini $(INSTALL_DIR)/etc
|
|
|
|
rm $(INSTALL_DIR)/bin/ant-d $(INSTALL_DIR)/bin/runnerd
|
2024-03-09 21:38:11 +01:00
|
|
|
@echo "Finish building Antd server"
|
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
httpd: clean_c
|
2024-03-09 21:38:11 +01:00
|
|
|
cd $(ROOT_DIR)/antd/ant-http && libtoolize && aclocal && autoconf && automake --add-missing
|
2024-03-10 00:17:53 +01:00
|
|
|
cd $(ROOT_DIR)/antd/ant-http && ./configure $(HOST) --prefix=$(BUILD_PREFIX)
|
|
|
|
DESTDIR=$(DESTDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/ant-http install
|
2024-03-09 21:38:11 +01:00
|
|
|
|
|
|
|
plugins: antd-fcgi-plugin antd-tunnel-plugin antd-wvnc-plugin antd-tunnel-publishers
|
|
|
|
@echo "Finish making plugins"
|
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
luasec: clean_c
|
2024-03-09 21:38:11 +01:00
|
|
|
@echo "Building $@"
|
|
|
|
lua5.3 $(ROOT_DIR)/antd/luasec/src/options.lua -g \
|
|
|
|
/usr/include/openssl/ssl.h \
|
|
|
|
> $(ROOT_DIR)/antd/luasec/src/options.c
|
2024-03-10 00:17:53 +01:00
|
|
|
CC=$(CC) \
|
2024-03-09 21:38:11 +01:00
|
|
|
INC_PATH=-I$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
|
|
|
|
make -C $(ROOT_DIR)/antd/luasec linux
|
2024-03-10 00:17:53 +01:00
|
|
|
CC=$(CC) \
|
2024-03-09 21:38:11 +01:00
|
|
|
INC_PATH=-I$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
|
2024-03-10 00:17:53 +01:00
|
|
|
DESTDIR=$(DESTDIR)/$(ARCH) \
|
2024-03-09 21:38:11 +01:00
|
|
|
LUAPATH=/opt/www/lib/lua \
|
|
|
|
LUACPATH=/opt/www/lib/lua \
|
|
|
|
make -C $(ROOT_DIR)/antd/luasec install
|
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
luasocket: clean_c
|
2024-03-09 21:38:11 +01:00
|
|
|
@echo "Building $@"
|
2024-03-10 00:17:53 +01:00
|
|
|
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) \
|
2024-03-09 21:38:11 +01:00
|
|
|
LUAV=5.4 \
|
|
|
|
LUAINC_linux=$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
|
2024-03-10 00:17:53 +01:00
|
|
|
LUAPREFIX_linux=$(BUILD_PREFIX) \
|
2024-03-09 21:38:11 +01:00
|
|
|
PLAT=linux \
|
|
|
|
make -C $(ROOT_DIR)/antd/luasocket linux
|
2024-03-10 00:17:53 +01:00
|
|
|
CC_linux=$(CC) \
|
|
|
|
LD_linux=$(CC) \
|
2024-03-09 21:38:11 +01:00
|
|
|
LUAV=5.4 \
|
|
|
|
LUAINC_linux=$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
|
2024-03-10 00:17:53 +01:00
|
|
|
LUAPREFIX_linux=$(BUILD_PREFIX) \
|
2024-03-09 21:38:11 +01:00
|
|
|
PLAT=linux \
|
2024-03-10 00:17:53 +01:00
|
|
|
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
|
2024-03-09 21:38:11 +01:00
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
antd-% sil%: clean_c
|
2024-03-09 21:38:11 +01:00
|
|
|
@echo "Building $@"
|
|
|
|
cd $(ROOT_DIR)/antd/$@ && libtoolize && aclocal && autoconf && automake --add-missing
|
2024-03-10 00:17:53 +01:00
|
|
|
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
|
2024-03-09 21:38:11 +01:00
|
|
|
|
|
|
|
luafcgi:
|
|
|
|
ifeq ($(LUAFCGI_IGNORE),)
|
|
|
|
@echo "Building $@"
|
2024-03-10 00:17:53 +01:00
|
|
|
mkdir -p $(INSTALL_DIR)/bin
|
2024-03-09 21:38:11 +01:00
|
|
|
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 \
|
2024-03-10 00:17:53 +01:00
|
|
|
--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
|
2024-03-09 21:38:11 +01:00
|
|
|
else
|
|
|
|
@echo "Ignore building $@"
|
|
|
|
endif
|
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
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"
|
2024-03-09 21:38:11 +01:00
|
|
|
RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) \
|
2024-03-10 00:17:53 +01:00
|
|
|
. $(CARGO_HOME)/env && \
|
|
|
|
rustup default stable && \
|
|
|
|
cargo clean \
|
|
|
|
--manifest-path=$(ROOT_DIR)/antd/luafcgi/Cargo.toml \
|
|
|
|
--config=$(ROOT_DIR)/antd/luafcgi/.cargo/config.toml
|
2024-03-09 21:38:11 +01:00
|
|
|
-rm -rf $(DESTDIR)/*
|
|
|
|
|
|
|
|
backend:
|
|
|
|
@echo "Building $@"
|
2024-03-10 00:17:53 +01:00
|
|
|
mkdir -p $(INSTALL_DIR)/htdocs/os
|
|
|
|
DESTDIR=$(INSTALL_DIR)/htdocs/os make -C antos-backend
|
2024-03-09 21:38:11 +01:00
|
|
|
|
|
|
|
frontend:
|
|
|
|
ifeq ($(FRONTEND_IGNORE),)
|
|
|
|
@echo "Building $@"
|
2024-03-10 00:17:53 +01:00
|
|
|
mkdir -p $(INSTALL_DIR)/htdocs/os
|
|
|
|
BUILDDIR=$(INSTALL_DIR)/htdocs/os make -C antos-frontend install_dev release
|
2024-03-09 21:38:11 +01:00
|
|
|
else
|
|
|
|
@echo "Ignore building $@"
|
|
|
|
endif
|
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
deb:
|
|
|
|
-rm $(DESTDIR)/$(ARCH)/*.deb
|
|
|
|
scripts/mkdeb.sh $(VERSION_STR) $(ARCH) $(DESTDIR)/$(ARCH)
|
2024-03-09 21:38:11 +01:00
|
|
|
|
|
|
|
tar.gz: antos
|
2024-03-10 00:17:53 +01:00
|
|
|
-rm $(DESTDIR)/$(ARCH)/$(PKG_NAME).tar.gz
|
|
|
|
cd $(DESTDIR)/$(ARCH)/ && tar cvzf $(PKG_NAME).tar.gz opt
|
2024-03-09 21:38:11 +01:00
|
|
|
|
2024-03-10 00:17:53 +01:00
|
|
|
appimg:
|
|
|
|
-rm $(DESTDIR)/$(ARCH)/*.AppImage
|
|
|
|
scripts/mkappimg.sh $(ARCH) $(VERSION_STR) $(DESTDIR)/$(ARCH) $(ROOT_DIR)/antos-64.png
|
2024-03-09 21:38:11 +01:00
|
|
|
|
|
|
|
.PHONY: antd antos
|