aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorAdam <adamdharrison@gmail.com>2022-09-09 17:47:28 -0400
committerAdam <adamdharrison@gmail.com>2022-09-09 17:47:28 -0400
commitf3b23174bfed7203d53040b6ba028b6049f556ad (patch)
treee5dde639a22fd40666b3e15fa2fc659fd97d3f2a /build.sh
downloadlite-xl-plugin-manager-f3b23174bfed7203d53040b6ba028b6049f556ad.tar.gz
lite-xl-plugin-manager-f3b23174bfed7203d53040b6ba028b6049f556ad.zip
Initial commit.
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..497767d
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+: ${CC=gcc}
+: ${MAKE=make}
+: ${BIN=lpm}
+: ${JOBS=4}
+
+SRCS="*.c"
+LDFLAGS="$LDFLAGS -lm -pthread -static-libgcc"
+
+[[ "$@" == "clean" ]] && rm -rf lib/libgit2/build lib/zlib/build lib/openssl/build $BIN && exit 0
+
+# Build supporting libraries, libgit2, libz, libssl (with libcrypto), libpcre
+if [[ "$@" != *"-libgit2"* ]]; then
+ [ ! -e "lib/libgit2/include" ] && echo "Make sure you've cloned submodules. (git submodule update --init --depth=1)" && exit -1
+ [ ! -e "lib/libgit2/build" ] && cd lib/libgit2 && mkdir build && cmake .. -DBUILD_SHARED_LIBS=OFF -DUSE_SSH=OFF && $MAKE -j $JOBS && cd ../../
+ LDFLAGS="$LDFLAGS -Llib/libgit2/build -l:libgit2.a" && CFLAGS="$CFLAGS -Ilib/libgit2/build/include/git2 -Ilib/libgit2/build/include -Ilib/libgit2/include"
+fi
+if [[ "$@" != *"-lz"* ]]; then
+ [ ! -e "lib/zlib/build" ] && cd lib/zlib && mkdir build && ../configure && $MAKE -j $JOBS && cd ../../
+ LDFLAGS="$LDFLAGS -Llib/libz/build -l:libz.a" && CFLAGS="$CFLAGS -Ilib/libz"
+fi
+if [[ "$@" != *"-lssl"* ]]; then
+ [ ! -e "lib/openssl/build" ] && cd lib/openssl && mkdir build && ../Configure && $MAKE -j $JOBS && cd ../../
+ LDFLAGS="$LDFLAGS -Llib/libz/build -l:libssl.a -l:libcrypto.a" && CFLAGS="$CFLAGS -Ilib/libz"
+fi
+[[ "$@" != *"-llua"* ]] && CFLAGS="$CFLAGS -Ilib/lua -DMAKE_LIB=1" && SRCS="$SRCS lib/lua/onelua.c"
+
+# Build the pre-packaged lua file into the executbale.
+echo "const char* luafile = " > lpm.lua.c && cat lpm.lua | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed 's/^/"/' | sed 's/$/\\n"/' >> lpm.lua.c && echo ";" >> lpm.lua.c
+
+[[ "$@" != *" -g "* || "$@" != *" -O"* ]] && CFLAGS="$CFLAGS -O3" && LDFLAGS="$LDFLAGS -s"
+$CC $CFLAGS $SRCS $@ -o lpm $LDFLAGS -ldl -l:libpcre.a