diff --git a/Makefile b/Makefile index ef565d9..051dbb6 100644 --- a/Makefile +++ b/Makefile @@ -46,11 +46,18 @@ install-script: ${SED} "s#@INSTALL_PREFIX@#${INSTALL_PREFIX}#g" install.sh ${SED} "s#@VERSION@#${VERSION}#g" install.sh ${SED} "s#@LIB_NAME@#${LIB_NAME}#g" install.sh + ${SED} "s#@SO_NAME@#${SO_NAME}#g" install.sh chmod +x install.sh install: ./install.sh install +.PHONY: uninstall +uninstall: install-script + ./install.sh uninstall + + + .PHONY: cli cli: go build -o ${CLI_BIN} -ldflags "-s -w" ./cli @@ -60,6 +67,7 @@ library-nosqlite: library: CGO_ENABLED=1 go build -tags "fts5" -buildmode=c-shared -ldflags "-s -w ${VERSION_STAMP_LDFLAGS}" -o ${LIB_NAME} . + ln -sf "$(realpath ./)/libgovarnam.so" "$(realpath ./)/libgovarnam.so.${SO_NAME}" library-mac-universal: GOOS=darwin GOARCH=arm64 $(MAKE) library @@ -105,4 +113,4 @@ test: .PHONY: clean clean: - rm -f varnamcli libgovarnam.so libgovarnam.h govarnam.pc + rm -f varnamcli libgovarnam.* govarnam.pc install.sh diff --git a/install.sh.in b/install.sh.in index 93d49e1..d5381ba 100755 --- a/install.sh.in +++ b/install.sh.in @@ -9,29 +9,30 @@ SUDO=${SUDO:-sudo} if [ "$ARG1" == "install" ]; then "${SUDO}" mkdir -p "/usr/local/bin/" - "${SUDO}" cp "$SCRIPT_DIR/varnamcli" "@INSTALL_PREFIX@/bin/varnamcli" - - "${SUDO}" mkdir -p "@INSTALL_PREFIX@/lib/pkgconfig" - "${SUDO}" cp "$SCRIPT_DIR/@LIB_NAME@" "@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" - "${SUDO}" ln -s "@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" "@INSTALL_PREFIX@/lib/@LIB_NAME@" - "${SUDO}" cp "$SCRIPT_DIR/govarnam.pc" "@INSTALL_PREFIX@/lib/pkgconfig/" - - "${SUDO}" mkdir -p "@INSTALL_PREFIX@/include/libgovarnam" - "${SUDO}" cp "$SCRIPT_DIR/"*.h "@INSTALL_PREFIX@/include/libgovarnam/" + "${SUDO}" cp "$SCRIPT_DIR/varnamcli" "${DESTDIR}@INSTALL_PREFIX@/bin/varnamcli" + + "${SUDO}" mkdir -p "${DESTDIR}@INSTALL_PREFIX@/lib/pkgconfig" + "${SUDO}" cp "$SCRIPT_DIR/@LIB_NAME@" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" + "${SUDO}" ln -sf "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@" + "${SUDO}" ln -sf "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@SO_NAME@" + "${SUDO}" cp "$SCRIPT_DIR/govarnam.pc" "${DESTDIR}@INSTALL_PREFIX@/lib/pkgconfig/" + + "${SUDO}" mkdir -p "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam" + "${SUDO}" cp "$SCRIPT_DIR/"*.h "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam/" "${SUDO}" ldconfig || true - "${SUDO}" mkdir -p "@INSTALL_PREFIX@/share/varnam/schemes" + "${SUDO}" mkdir -p "${DESTDIR}@INSTALL_PREFIX@/share/varnam/schemes" msg="Installation finished" echo "$msg" notify-send "$msg" &> /dev/null || true elif [ "$ARG1" == "uninstall" ]; then - "${SUDO}" rm "@INSTALL_PREFIX@/bin/varnamcli" "@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" "@INSTALL_PREFIX@/lib/@LIB_NAME@" "@INSTALL_PREFIX@/lib/pkgconfig/govarnam.pc" - "${SUDO}" rm "@INSTALL_PREFIX@/include/libgovarnam/"* - "${SUDO}" rmdir "@INSTALL_PREFIX@/include/libgovarnam" - "${SUDO}" rm "@INSTALL_PREFIX@/share/varnam/schemes/"* - "${SUDO}" rmdir "@INSTALL_PREFIX@/share/varnam/schemes/" + "${SUDO}" rm -f "${DESTDIR}@INSTALL_PREFIX@/bin/varnamcli" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@/lib/@LIB_NAME@" "${DESTDIR}@INSTALL_PREFIX@/lib/pkgconfig/govarnam.pc" + "${SUDO}" rm -f "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam/"* + "${SUDO}" rmdir "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam" || true + "${SUDO}" rm -f "${DESTDIR}@INSTALL_PREFIX@/share/varnam/schemes/"* + "${SUDO}" rmdir "${DESTDIR}@INSTALL_PREFIX@/share/varnam/schemes/" || true msg="Uninstallation finished" echo $msg