sophuwu.site > crls
simplified compiling
sophuwu sophie@skisiel.com
Sat, 24 Feb 2024 13:16:51 +0100
commit

2f444ed1f852d4628e41aef3888be5b077996e22

parent

635d06d2f5ecaf034c8d6c7a9f4f4604356a99f9

3 files changed, 9 insertions(+), 50 deletions(-)

jump to
M CMakeLists.txtCMakeLists.txt

@@ -1,6 +1,5 @@

cmake_minimum_required(VERSION 3.16) project(rls) - set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os") set(CMAKE_EXE_LINKER_FLAGS "-static")
M MakefileMakefile

@@ -1,60 +1,27 @@

+BUILDDIR?=./build ifeq ($(shell command -v cmake), ) -COMPCMD = g++ --std=c++17 -o build/rls rls.cpp -COMPMSG = g++ +COMPCMD = g++ --std=c++17 -o $(BUILDDIR)/rls rls.cpp else ifeq ($(shell command -v ninja), ) -COMPCMD = cmake -S . -B build && cmake --build build -COMPMSG = cmake +COMPCMD = cmake -S . -B $(BUILDDIR) && cmake --build $(BUILDDIR) else -COMPCMD = cmake -GNinja -S . -B build && cmake --build build -COMPMSG = cmake and ninja +COMPCMD = cmake -GNinja -S . -B $(BUILDDIR) && cmake --build $(BUILDDIR) endif CMAKELISTS = CMakeLists.txt endif -ifeq ($(shell command -v strip), ) -STRIPCMD = echo Strip not found. Binary size may be larger than expected. -else -STRIPCMD = strip --strip-all build/rls -endif -ifeq ($(shell command -v upx), ) -UPXCMD = echo UPX not found. Binary size may be larger than expected. -else -UPXCMD = upx --best build/rls > /dev/null -endif - build: rls.cpp $(CMAKELISTS) - @echo Building with $(COMPMSG). - @mkdir -p build + @mkdir -p $(BUILDDIR) @$(COMPCMD) @echo Compiled successfully. - @echo Program is located at build/rls. - @echo "make small" to reduce binary size. Requires strip and/or upx. - @echo "sudo make install" to install the program into /usr/local/bin. - @echo And "make clean" to remove the build directory. -clean: build/ +clean: $(BUILDDIR)/ @echo Cleaning up. - @rm -rf build + @rm -rf $(BUILDDIR) @echo Cleaned up successfully. -small: build/rls - @cp build/rls build/rls.bak - @echo Stripping binary. - @$(STRIPCMD) - @$(UPXCMD) - @echo Old Size: && du -sh build/rls.bak - @echo New size: && du -sh build/rls - - -install: build/rls +install: $(BUILDDIR)/rls @echo Installing to /usr/local/bin. - @sudo cp build/rls /usr/local/bin/rls + @sudo cp $(BUILDDIR)/rls /usr/local/bin/rls @echo Installed successfully. @echo Run "rls" to use the program. - -arm: rls.cpp CMakeLists.txt arm64_toolchain.cmake - @echo building arm - @mkdir -p build/arm - @cmake -DCMAKE_TOOLCHAIN_FILE=arm64_toolchain.cmake -B build/arm - @cmake --build build/arm
D arm64_toolchain.cmake

@@ -1,7 +0,0 @@

-set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_PROCESSOR aarch64) - -set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) -set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) - -# Here you can set any necessary compiler flags, like sysroot or include directories.