diff --git a/Makefile b/Makefile index 7b3cccc..28ea315 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,24 @@ +include config.mk + +CFLAGS+="-std=c99" +CFLAGS+=$(JSON_C_CFLAGS) +LDFLAGS+=$(JSON_C_LDFLAGS) + json-search: json-search.o - $(CC) -ljson-c -std=c99 -Wall -Wextra json-search.o -o json-search + $(CC) -ljson-c $(JSON_C_LDFLAGS) -std=c99 -Wall -Wextra json-search.o -o json-search + +appimagetool-x86_64.AppImage: + wget https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage + chmod +x appimagetool-x86_64.AppImage + +json-search-x86_64.AppImage: json-search appimagetool-x86_64.AppImage + mkdir -p json-search.AppDir/usr/ + mkdir -p json-search.AppDir/usr/bin/ + mkdir -p json-search.AppDir/usr/lib/ + cp json-search json-search.AppDir/usr/bin/ + ./cp_json-c.sh + ./appimagetool-x86_64.AppImage json-search.AppDir clean: rm json-search.o diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..9a10be4 --- /dev/null +++ b/config.mk @@ -0,0 +1,2 @@ + +JSON_C_CFLAGS=-I/usr/include/json-c diff --git a/configure b/configure new file mode 100755 index 0000000..fb915f6 --- /dev/null +++ b/configure @@ -0,0 +1,32 @@ +#!/bin/bash + +DIR=$PWD +NO_RECOMPILE=1 + +echo "" > config.mk +echo '#!/bin/bash' > ./cp_json-c.sh +chmod +x ./cp_json-c.sh + +for arg in $@; do + echo $( echo "$arg" | cut -d '=' -f 1) + if [ "--compile-json-c" = $arg ]; then + git clone https://github.com/json-c/json-c.git + mkdir json-c-build + cd json-c-build + cmake3 ../json-c/ + make + cd - + NO_RECOMPILE=0 + echo 'JSON_C_CFLAGS=-I./json-c -I./json-c-build' >> config.mk + echo 'JSON_C_LDFLAGS="-L./json-c-build"' >> config.mk + echo "cp json-c-build/libjson-c.so* json-search.AppDir/usr/lib/" >> ./cp_json-c.sh + fi + if [ "--help" = $arg ]; then + echo "--compile-json-c: clone and compile json-c" + fi +done + +if [ $NO_RECOMPILE -eq 1 ]; then + echo JSON_C_CFLAGS=$(pkg-config --cflags json-c) >> config.mk + echo "cp \$(ldd json-search | grep json | cut -d ' ' -f 3) json-search.AppDir/usr/lib/" >> ./cp_json-c.sh +fi diff --git a/json-search.AppDir/AppRun b/json-search.AppDir/AppRun new file mode 100755 index 0000000..7e766c6 --- /dev/null +++ b/json-search.AppDir/AppRun @@ -0,0 +1,3 @@ +#!/bin/bash + +LD_LIBRARY_PATH=${APPDIR}/usr/lib/ "${APPDIR}/usr/bin/json-search" "$@" diff --git a/json-search.AppDir/appimage-logo.png b/json-search.AppDir/appimage-logo.png new file mode 100644 index 0000000..8b50818 Binary files /dev/null and b/json-search.AppDir/appimage-logo.png differ diff --git a/json-search.AppDir/json-search.desktop b/json-search.AppDir/json-search.desktop new file mode 100644 index 0000000..50a103d --- /dev/null +++ b/json-search.AppDir/json-search.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=json-search +Exec=json-search +Comment=grep into like, and format print +Categories=Development; +Terminal=true +Icon=appimage-logo \ No newline at end of file diff --git a/json-search.c b/json-search.c index 25f1a59..da8ea79 100644 --- a/json-search.c +++ b/json-search.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include "json.h" #define panic(...) \ do { \