From 4b71a185fd67324375fea2ad39ce59d8608731e7 Mon Sep 17 00:00:00 2001 From: Kristofer Berggren Date: Sun, 5 Nov 2023 18:01:15 +0800 Subject: [PATCH] fixes #142 - update build documentation --- .github/workflows/linux.yml | 2 +- .github/workflows/macos.yml | 2 +- FLAGS.md | 17 ++++ LOWMEMORY.md | 82 ++++++++++++++++ README.md | 190 +++++++++--------------------------- lib/common/src/version.h | 2 +- make.sh | 14 ++- src/nchat.1 | 2 +- 8 files changed, 159 insertions(+), 152 deletions(-) create mode 100644 FLAGS.md create mode 100644 LOWMEMORY.md diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a95c9446..4928df5e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -15,4 +15,4 @@ jobs: - name: Checkout uses: actions/checkout@v1 - name: Build Linux - run: ./make.sh all + run: ./make.sh all -y diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index a4528a4c..5e103d74 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -15,4 +15,4 @@ jobs: - name: Checkout uses: actions/checkout@v1 - name: Build macOS - run: ./make.sh all + run: ./make.sh all -y diff --git a/FLAGS.md b/FLAGS.md new file mode 100644 index 00000000..769ef358 --- /dev/null +++ b/FLAGS.md @@ -0,0 +1,17 @@ +Feature Flags +============= + +Enabling / Disabling Protocol Support +------------------------------------- +The protocols supported by nchat is controlled by the following cmake flags: + + HAS_DUMMY=ON + HAS_TELEGRAM=ON + HAS_WHATSAPP=ON + +It is possible to enable / disable protocols by passing one or multiple flags +to cmake: + + mkdir -p build && cd build + cmake -DHAS_WHATSAPP=OFF .. && make -s + diff --git a/LOWMEMORY.md b/LOWMEMORY.md new file mode 100644 index 00000000..90860223 --- /dev/null +++ b/LOWMEMORY.md @@ -0,0 +1,82 @@ +Building on Low Memory / RAM Systems +==================================== +The Telegram client library subcomponent requires relatively large amount of +RAM to build by default (3.5GB using g++, and 1.5 GB for clang++). It is +possible to adjust the Telegram client library source code so that it requires +less RAM (but takes longer time). Doing so reduces the memory requirement to +around 1GB under g++ and 0.5GB for clang++. + +Steps to build nchat on a low memory system: + +**Extra Dependencies (Linux)** + + sudo apt install php-cli clang + +**Source** + + git clone https://github.com/d99kris/nchat && cd nchat + +**Setup** + + mkdir -p build && cd build + CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake .. + +**Split source (optional)** + + cmake --build . --target prepare_cross_compiling + cd ../lib/tgchat/ext/td ; php SplitSource.php ; cd - + +**Build** + + make -s + +**Install** + + sudo make install + +**Revert Source Code Split (Optional)** + + cd ../lib/tgchat/ext/td ; php SplitSource.php --undo ; cd - + +Arch Linux +---------- +**Source** + + git clone https://aur.archlinux.org/nchat-git.git && cd nchat-git + +**Prepare** + + Open PKGBUILD in your favourite editor. + Add `php` and `clang` on depends array. + Change the `_install_mode` to `slow`. + +**Build** + + makepkg -s + +**Install** + + makepkg -i + +Fedora +------ +**Extra Dependencies** + + sudo dnf install php-cli + +**Source** + + git clone https://github.com/d99kris/nchat && cd nchat + +**Build** + + mkdir -p build && cd build + CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake .. + cmake --build . --target prepare_cross_compiling + cd ../lib/tgchat/ext/td ; php SplitSource.php ; cd - + make -s + +**Install** + + sudo make install + diff --git a/README.md b/README.md index 9933bdda..1e6e2aff 100644 --- a/README.md +++ b/README.md @@ -117,193 +117,97 @@ Supported Platforms nchat is developed and tested on Linux and macOS. Current version has been tested on: -- macOS Big Sur 11.5 -- Ubuntu 20.04 LTS +- macOS Sonoma 14.0 +- Ubuntu 22.04 LTS - -Build / Install -=============== -Nchat consists of a large code-base (mainly the Telegram client library), so be -prepared for a relatively long first build time. - -Ubuntu ------- -**Dependencies** - - sudo apt install ccache cmake build-essential gperf help2man libreadline-dev libssl-dev libncurses-dev libncursesw5-dev ncurses-doc zlib1g-dev libsqlite3-dev libmagic-dev golang - -**Source** - - git clone https://github.com/d99kris/nchat && cd nchat - -**Build** - - mkdir -p build && cd build && cmake .. && make -s - -**Install** - - sudo make install +Install using Package Manager +============================= macOS ----- +**Build / Install Stable Release** -There are two methods to install nchat on macOS: through Homebrew or building from source. - -### Using Homebrew - -**Add tap** - - brew tap d99kris/nchat - -**Install** - - brew install nchat - -### Building from Source - -**Dependencies** - - brew install gperf cmake openssl ncurses ccache readline help2man sqlite libmagic go - -**Source** - - git clone https://github.com/d99kris/nchat && cd nchat - -**Build** - - mkdir -p build && cd build && cmake .. && make -s - -**Install** - - make install + brew install d99kris/d99kris/nchat Arch Linux ---------- -**Source** +**Build / Install Latest Git** git clone https://aur.archlinux.org/nchat-git.git && cd nchat-git + makepkg -s && makepkg -i -**Build** +**Build / Install Stable Release** - makepkg -s - -**Install** - - makepkg -i - -Fedora ------- -**Dependencies** + git clone https://aur.archlinux.org/nchat.git && cd nchat + makepkg -s && makepkg -i - sudo dnf install git cmake clang golang ccache file-devel file-libs gperf readline-devel openssl-devel ncurses-devel sqlite-devel zlib-devel +Build from Source +================= +nchat consists of a large code-base (mainly the Telegram library tdlib), so be +prepared for a relatively long first build time. -**Source** +**Get Source** git clone https://github.com/d99kris/nchat && cd nchat -**Build** +Using make.sh script +-------------------- +If using macOS, Arch, Fedora, Gentoo, Raspbian, Ubuntu or Void, one can use +the `make.sh` script provided. - mkdir -p build && cd build && cmake .. && make -s +**Dependencies** -**Install** + ./make.sh deps - sudo make install +**Build / Install** -Enabling / Disabling Protocol Support -------------------------------------- -The protocols supported by nchat is controlled by the following cmake flags: + ./make.sh build && ./make.sh install - HAS_DUMMY=ON - HAS_TELEGRAM=ON - HAS_WHATSAPP=ON +Manually +-------- +**Dependencies** -It is possible to enable / disable protocols by passing one or multiple flags -to cmake: +macOS - mkdir -p build && cd build - cmake -DHAS_WHATSAPP=OFF .. && make -s + brew install gperf cmake openssl ncurses ccache readline help2man sqlite libmagic go -Low Memory / RAM Systems ------------------------- -The Telegram client library subcomponent requires relatively large amount of -RAM to build by default (3.5GB using g++, and 1.5 GB for clang++). It is -possible to adjust the Telegram client library source code so that it requires -less RAM (but takes longer time). Doing so reduces the memory requirement to -around 1GB under g++ and 0.5GB for clang++. +Arch -Steps to build nchat on a low memory system: + sudo pacman -S ccache cmake file go gperf help2man ncurses openssl readline sqlite zlib base-devel -**Extra Dependencies (Linux)** +Debian-based (Ubuntu, Raspbian, etc) - sudo apt install php-cli clang + sudo apt install ccache cmake build-essential gperf help2man libreadline-dev libssl-dev libncurses-dev libncursesw5-dev ncurses-doc zlib1g-dev libsqlite3-dev libmagic-dev golang -**Source** +Fedora - git clone https://github.com/d99kris/nchat && cd nchat + sudo dnf install git cmake clang golang ccache file-devel file-libs gperf readline-devel openssl-devel ncurses-devel sqlite-devel zlib-devel -**Setup** +Gentoo - mkdir -p build && cd build - CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake .. + sudo emerge -n dev-util/cmake dev-util/gperf sys-apps/help2man sys-libs/readline dev-libs/openssl sys-libs/ncurses sys-libs/zlib dev-db/sqlite sys-apps/file dev-lang/go -**Split source (optional)** +Void - cmake --build . --target prepare_cross_compiling - cd ../lib/tgchat/ext/td ; php SplitSource.php ; cd - + sudo xbps-install base-devel go ccache cmake gperf help2man libmagick-devel readline-devel sqlite-devel file-devel openssl-devel **Build** - make -s + mkdir -p build && cd build && cmake .. && make -s **Install** sudo make install -**Revert Source Code Split (Optional)** - - cd ../lib/tgchat/ext/td ; php SplitSource.php --undo ; cd - - -Arch Linux ----------- -**Source** - - git clone https://aur.archlinux.org/nchat-git.git && cd nchat-git - -**Prepare** - - Open PKGBUILD in your favourite editor. - Add `php` and `clang` on depends array. - Change the `_install_mode` to `slow`. - -**Build** - - makepkg -s - -**Install** +Advanced Build Options +---------------------- +By default nchat requires ~3.5GB RAM to build using G++ and ~1.5GB RAM with +clang++, but it is possible to reduce the memory needed, +see [Building on Low Memory Systems](LOWMEMORY.md). - makepkg -i +All nchat features are enabled by default, but it's possible to control +inclusion of some features using cmake flags, see [Feature Flags](FLAGS.md). -Fedora ------- -**Extra Dependencies** - - sudo dnf install php-cli - -**Source** - - git clone https://github.com/d99kris/nchat && cd nchat - -**Build** - - mkdir -p build && cd build - CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake .. - cmake --build . --target prepare_cross_compiling - cd ../lib/tgchat/ext/td ; php SplitSource.php ; cd - - make -s - -**Install** - - sudo make install Getting Started =============== diff --git a/lib/common/src/version.h b/lib/common/src/version.h index fe91de96..b9151e5e 100644 --- a/lib/common/src/version.h +++ b/lib/common/src/version.h @@ -7,4 +7,4 @@ #pragma once -#define NCHAT_VERSION "3.95" +#define NCHAT_VERSION "3.96" diff --git a/make.sh b/make.sh index 3f545b75..f212aac2 100755 --- a/make.sh +++ b/make.sh @@ -63,7 +63,7 @@ case "${1%/}" in ;; *) - echo "usage: make.sh " + echo "usage: make.sh [-y]" echo " deps - install project dependencies" echo " build - perform build" echo " debug - perform debug build" @@ -72,9 +72,11 @@ case "${1%/}" in echo " install - perform build and install" echo " all - perform deps, build, tests, doc and install" echo " src - perform source code reformatting" + echo " -y - non-interactive mode, assume " exit 1 ;; esac +[[ "${2}" == "-y" ]] && YES="-y" || YES="" # helper functions function version_ge() { @@ -88,22 +90,24 @@ if [[ "${DEPS}" == "1" ]]; then unset NAME eval $(grep "^NAME=" /etc/os-release 2> /dev/null) if [[ "${NAME}" == "Ubuntu" ]]; then - sudo apt update && sudo apt -y install ccache cmake build-essential gperf help2man libreadline-dev libssl-dev libncurses-dev libncursesw5-dev ncurses-doc zlib1g-dev libsqlite3-dev libmagic-dev || exiterr "deps failed (ubuntu), exiting." + sudo apt update && sudo apt ${YES} install ccache cmake build-essential gperf help2man libreadline-dev libssl-dev libncurses-dev libncursesw5-dev ncurses-doc zlib1g-dev libsqlite3-dev libmagic-dev || exiterr "deps failed (ubuntu), exiting." unset VERSION_ID eval $(grep "^VERSION_ID=" /etc/os-release 2> /dev/null) if version_ge "${VERSION_ID}" "22.04"; then - sudo apt -y install golang || exiterr "deps failed (apt golang), exiting." + sudo apt ${YES} install golang || exiterr "deps failed (apt golang), exiting." else sudo snap install go --classic || exiterr "deps failed (snap go), exiting." fi elif [[ "${NAME}" == "Raspbian GNU/Linux" ]]; then - sudo apt update && sudo apt -y install ccache cmake build-essential gperf help2man libreadline-dev libssl-dev libncurses-dev libncursesw5-dev ncurses-doc zlib1g-dev libsqlite3-dev libmagic-dev golang || exiterr "deps failed (raspbian gnu/linux), exiting." + sudo apt update && sudo apt ${YES} install ccache cmake build-essential gperf help2man libreadline-dev libssl-dev libncurses-dev libncursesw5-dev ncurses-doc zlib1g-dev libsqlite3-dev libmagic-dev golang || exiterr "deps failed (raspbian gnu/linux), exiting." elif [[ "${NAME}" == "Gentoo" ]]; then sudo emerge -n dev-util/cmake dev-util/gperf sys-apps/help2man sys-libs/readline dev-libs/openssl sys-libs/ncurses sys-libs/zlib dev-db/sqlite sys-apps/file dev-lang/go || exiterr "deps failed (gentoo), exiting." elif [[ "${NAME}" == "Fedora Linux" ]]; then - sudo dnf -y install git cmake clang golang ccache file-devel file-libs gperf readline-devel openssl-devel ncurses-devel sqlite-devel zlib-devel + sudo dnf ${YES} install git cmake clang golang ccache file-devel file-libs gperf readline-devel openssl-devel ncurses-devel sqlite-devel zlib-devel elif [[ "${NAME}" == "Arch Linux" ]]; then sudo pacman -S ccache cmake file go gperf help2man ncurses openssl readline sqlite zlib base-devel + elif [[ "${NAME}" == "Void" ]]; then + sudo xbps-install ${YES} base-devel go ccache cmake gperf help2man libmagick-devel readline-devel sqlite-devel file-devel openssl-devel else exiterr "deps failed (unsupported linux distro ${NAME}), exiting." fi diff --git a/src/nchat.1 b/src/nchat.1 index 60c592cc..158bf51b 100644 --- a/src/nchat.1 +++ b/src/nchat.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH NCHAT "1" "October 2023" "nchat v3.95" "User Commands" +.TH NCHAT "1" "November 2023" "nchat v3.96" "User Commands" .SH NAME nchat \- ncurses chat .SH SYNOPSIS