aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2024-04-05 14:36:53 -0400
committerAdam Harrison <adamdharrison@gmail.com>2024-04-05 14:36:53 -0400
commitc2815d0fa63ac1ace4b0837be5ad8926656a6d62 (patch)
treee0cddaa3f34b8248fb4f7528020b8625affc610d
parentbe66aaf58f0b3987bf32aef5524ee00a84f8b8ba (diff)
downloadlite-xl-plugin-manager-c2815d0fa63ac1ace4b0837be5ad8926656a6d62.tar.gz
lite-xl-plugin-manager-c2815d0fa63ac1ace4b0837be5ad8926656a6d62.zip
Changed CFLAGS and LDFLAGS vars in build script to handle Guldo's exotic build configuration.
-rwxr-xr-xbuild.sh30
1 files changed, 15 insertions, 15 deletions
diff --git a/build.sh b/build.sh
index cd8c67a..8c6669a 100755
--- a/build.sh
+++ b/build.sh
@@ -7,8 +7,8 @@
: ${JOBS=4}
SRCS="src/*.c"
-CFLAGS="$CFLAGS -Ilib/prefix/include"
-LDFLAGS="$LDFLAGS -lm -Llib/prefix/lib"
+COMPILE_FLAGS="$CFLAGS -Ilib/prefix/include" # We specifically rename this and LDFLAGS, because exotic build environments export these to subprcoesses.
+LINK_FLAGS="$LDFLAGS -lm -Llib/prefix/lib" # And ideally we don't want to mess with the underlying build processes, unless we're explicit about it.
[[ "$@" == "clean" ]] && rm -rf lib/libgit2/build lib/zlib/build lib/libzip/build lib/mbedtls/build lib/prefix lua $BIN *.exe src/lpm.luac src/lpm.lua.c && exit 0
cmake --version >/dev/null 2>/dev/null || { echo "Please ensure that you have cmake installed." && exit -1; }
@@ -19,23 +19,23 @@ CMAKE_DEFAULT_FLAGS=" $CMAKE_DEFAULT_FLAGS -DCMAKE_PREFIX_PATH=`pwd`/lib/prefix
mkdir -p lib/prefix/include lib/prefix/lib
if [[ "$@" != *"-lz"* ]]; then
[ ! -e "lib/zlib" ] && echo "Make sure you've cloned submodules. (git submodule update --init --depth=1)" && exit -1
- [[ ! -e "lib/zlib/build" ]] && { cd lib/zlib && mkdir build && cd build && $CC $CFLAGS -O3 -D_LARGEFILE64_SOURCE -I.. ../*.c -c && $AR rc libz.a *.o && cp libz.a ../../prefix/lib && cp ../*.h ../../prefix/include && cd ../../../ || exit -1; }
- LDFLAGS="$LDFLAGS -lz"
+ [[ ! -e "lib/zlib/build" ]] && { cd lib/zlib && mkdir build && cd build && $CC $COMPILE_FLAGS -O3 -D_LARGEFILE64_SOURCE -I.. ../*.c -c && $AR rc libz.a *.o && cp libz.a ../../prefix/lib && cp ../*.h ../../prefix/include && cd ../../../ || exit -1; }
+ LINK_FLAGS="$LINK_FLAGS -lz"
fi
if [[ "$@" != *"-lmbedtls"* && "$@" != *"-lmbedcrypto"* && "$@" != *"-lmbedx509"* ]]; then
- [ ! -e "lib/mbedtls/build" ] && { cd lib/mbedtls && mkdir build && cd build && CFLAGS="$CFLAGS $CFLAGS_MBEDTLS -DMBEDTLS_MD4_C=1 -DMBEDTLS_DEBUG_C -w" cmake .. $CMAKE_DEFAULT_FLAGS -G "Unix Makefiles" -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF $SSL_CONFIGURE && CFLAGS="$CFLAGS $CFLAGS_MBEDTLS -DMBEDTLS_MD4_C=1 -w" $MAKE -j $JOBS && $MAKE install && cd ../../../ || exit -1; }
- LDFLAGS="$LDFLAGS -lmbedtls -lmbedx509 -lmbedcrypto"
+ [ ! -e "lib/mbedtls/build" ] && { cd lib/mbedtls && mkdir build && cd build && CFLAGS="$COMPILE_FLAGS $CFLAGS_MBEDTLS -DMBEDTLS_MD4_C=1 -DMBEDTLS_DEBUG_C -w" cmake .. $CMAKE_DEFAULT_FLAGS -G "Unix Makefiles" -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF $SSL_CONFIGURE && CFLAGS="$COMPILE_FLAGS $CFLAGS_MBEDTLS -DMBEDTLS_MD4_C=1 -w" $MAKE -j $JOBS && $MAKE install && cd ../../../ || exit -1; }
+ LINK_FLAGS="$LINK_FLAGS -lmbedtls -lmbedx509 -lmbedcrypto"
fi
if [[ "$@" != *"-lgit2"* ]]; then
[ ! -e "lib/libgit2/build" ] && { cd lib/libgit2 && mkdir build && cd build && cmake .. -G "Unix Makefiles" $GIT2_CONFIGURE $CMAKE_DEFAULT_FLAGS -DBUILD_TESTS=OFF -DBUILD_CLI=OFF -DREGEX_BACKEND=builtin -DUSE_SSH=OFF -DUSE_HTTPS=mbedTLS && $MAKE -j $JOBS && $MAKE install && cd ../../../ || exit -1; }
- LDFLAGS="-lgit2 $LDFLAGS"
+ LINK_FLAGS="-lgit2 $LINK_FLAGS"
fi
if [[ "$@" != *"-lzip"* ]]; then
[ ! -e "lib/libzip/build" ] && { cd lib/libzip && mkdir build && cd build && cmake .. -G "Unix Makefiles" $CMAKE_DEFAULT_FLAGS -DBUILD_TOOLS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOC=OFF -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_OPENSSL=OFF -DENABLE_BZIP2=OFF -DENABLE_LZMA=OFF -DENABLE_ZSTD=OFF && $MAKE -j $JOBS && $MAKE install && cd ../../../ || exit -1; }
- LDFLAGS="$LDFLAGS -lzip"
+ LINK_FLAGS="$LINK_FLAGS -lzip"
fi
-[[ "$@" != *"-lmicrotar"* ]] && CFLAGS="$CFLAGS -Ilib/microtar/src" && SRCS="$SRCS lib/microtar/src/microtar.c"
-[[ "$@" != *"-llua"* ]] && CFLAGS="$CFLAGS -Ilib/lua -DMAKE_LIB=1" && SRCS="$SRCS lib/lua/onelua.c"
+[[ "$@" != *"-lmicrotar"* ]] && COMPILE_FLAGS="$COMPILE_FLAGS -Ilib/microtar/src" && SRCS="$SRCS lib/microtar/src/microtar.c"
+[[ "$@" != *"-llua"* ]] && COMPILE_FLAGS="$COMPILE_FLAGS -Ilib/lua -DMAKE_LIB=1" && SRCS="$SRCS lib/lua/onelua.c"
# Build the pre-packaged lua file into the executbale.
if [[ "$@" == *"-DLPM_STATIC"* ]]; then
@@ -43,9 +43,9 @@ if [[ "$@" == *"-DLPM_STATIC"* ]]; then
./lua.exe -e 'io.open("src/lpm.lua.c", "wb"):write("unsigned char lpm_luac[] = \""..string.dump(loadfile("src/lpm.lua")):gsub(".",function(c) return string.format("\\x%02X",string.byte(c)) end).."\";unsigned int lpm_luac_len = sizeof(lpm_luac)-1;")'
fi
-[[ $OSTYPE != 'msys'* && $CC != *'mingw'* && $CC != "emcc" ]] && CFLAGS="$CFLAGS -DLUA_USE_LINUX" && LDFLAGS="$LDFLAGS -ldl"
-[[ $OSTYPE == 'msys'* || $CC == *'mingw'* ]] && LDFLAGS="$LDFLAGS -lbcrypt -lws2_32 -lz -lwinhttp -lole32 -lcrypt32 -lrpcrt4 -lsecur32"
-[[ $OSTYPE == *'darwin'* ]] && LDFLAGS="$LDFLAGS -liconv -framework Security -framework Foundation"
+[[ $OSTYPE != 'msys'* && $CC != *'mingw'* && $CC != "emcc" ]] && COMPILE_FLAGS="$COMPILE_FLAGS -DLUA_USE_LINUX" && LINK_FLAGS="$LINK_FLAGS -ldl"
+[[ $OSTYPE == 'msys'* || $CC == *'mingw'* ]] && LINK_FLAGS="$LINK_FLAGS -lbcrypt -lws2_32 -lz -lwinhttp -lole32 -lcrypt32 -lrpcrt4 -lsecur32"
+[[ $OSTYPE == *'darwin'* ]] && LINK_FLAGS="$LINK_FLAGS -liconv -framework Security -framework Foundation"
-[[ " $@" != *" -g"* && " $@" != *" -O"* ]] && CFLAGS="$CFLAGS -O3" && LDFLAGS="$LDFLAGS -s -flto"
-$CC $CFLAGS $SRCS $@ -o $BIN $LDFLAGS
+[[ " $@" != *" -g"* && " $@" != *" -O"* ]] && COMPILE_FLAGS="$COMPILE_FLAGS -O3" && LINK_FLAGS="$LINK_FLAGS -s -flto"
+$CC $COMPILE_FLAGS $SRCS $@ -o $BIN $LINK_FLAGS