Skip to content

Commit

Permalink
Merge branch 'agx-destdir'
Browse files Browse the repository at this point in the history
  • Loading branch information
subins2000 committed Nov 5, 2023
2 parents c98f431 + 3630613 commit f95b043
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
31 changes: 16 additions & 15 deletions install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f95b043

Please sign in to comment.