Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make install.sh usable for distributions #66

Merged
merged 2 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ default: build ;

CLI_BIN := varnamcli
INSTALL_PREFIX := $(or ${PREFIX},${PREFIX},/usr/local)
LIBDIR := /lib

# Try to get the commit hash from git
LAST_COMMIT := $(or $(shell git rev-parse --short HEAD 2> /dev/null),"UNKNOWN")
Expand All @@ -14,39 +15,43 @@ BUILDSTR := ${VERSION} (\#${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z")
RELEASE_NAME := govarnam-${VERSION}-${shell uname -m}
UNAME := $(shell uname)

SED := sed -i
SED := sed
LIB_NAME := libgovarnam.so
SO_NAME := $(shell (echo $(VERSION) | cut -d. -f1))
CURDIR := $(shell pwd)

ifeq ($(UNAME), Darwin)
SED := sed -i ""
LIB_NAME = libgovarnam.dylib
else
EXT_LDFLAGS = -extldflags "-Wl,-soname,$(LIB_NAME).$(SO_NAME),--version-script,$(CURDIR)/govarnam.syms"
endif

VERSION_STAMP_LDFLAGS := -X 'github.com/varnamproject/govarnam/govarnam.BuildString=${BUILDSTR}' -X 'github.com/varnamproject/govarnam/govarnam.VersionString=${VERSION}' $(EXT_LDFLAGS)
pc:
cp govarnam.pc.in govarnam.pc
${SED} "s#@INSTALL_PREFIX@#${INSTALL_PREFIX}#g" govarnam.pc
${SED} "s#@VERSION@#${VERSION}#g" govarnam.pc
${SED} -e "s#@INSTALL_PREFIX@#${INSTALL_PREFIX}#g" \
-e "s#@VERSION@#${VERSION}#g" \
-e "s#@LIBDIR@#${LIBDIR}#g" \
govarnam.pc.in > govarnam.pc.tmp
mv govarnam.pc.tmp govarnam.pc

# Used only for building the CLI
temp-pc:
cp govarnam.pc.in govarnam.pc
${SED} "s#@INSTALL_PREFIX@#$(realpath .)#g" govarnam.pc
${SED} "s#@VERSION@#${VERSION}#g" govarnam.pc

${SED} "s#/include/libgovarnam##g" govarnam.pc
${SED} "s#/lib\$$##g" govarnam.pc
${SED} -e "s#@INSTALL_PREFIX@#$(realpath .)#g" \
-e "s#@VERSION@#${VERSION}#g" \
-e "s#@LIBDIR@#${LIBDIR}#g" \
-e "s#/include/libgovarnam##g" \
-e "s#/lib\$$##g" \
govarnam.pc.in > govarnam.pc.tmp
mv govarnam.pc.tmp govarnam.pc

install.sh: install.sh.in
cp install.sh.in install.sh
${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
${SED} -e "s#@INSTALL_PREFIX@#${INSTALL_PREFIX}#g" \
-e "s#@VERSION@#${VERSION}#g" \
-e "s#@LIBDIR@#${LIBDIR}#g" \
-e "s#@LIB_NAME@#${LIB_NAME}#g" \
-e "s#@SO_NAME@#${SO_NAME}#g" \
install.sh.in > install.sh.tmp
mv install.sh.tmp install.sh
chmod +x install.sh

.PHONY: install
Expand Down
2 changes: 1 addition & 1 deletion govarnam.pc.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prefix=@INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
libdir=${prefix}@LIBDIR@
includedir=${prefix}/include/libgovarnam

Name: GoVarnam
Expand Down
12 changes: 6 additions & 6 deletions install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ if [ "$ARG1" == "install" ]; then
"${SUDO}" mkdir -p "/usr/local/bin/"
"${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@@LIBDIR@/pkgconfig"
"${SUDO}" cp "$SCRIPT_DIR/@LIB_NAME@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@VERSION@"
"${SUDO}" ln -s "@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@"
"${SUDO}" ln -s "@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@SO_NAME@"
"${SUDO}" cp "$SCRIPT_DIR/govarnam.pc" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/pkgconfig/"

"${SUDO}" mkdir -p "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam"
"${SUDO}" cp "$SCRIPT_DIR/"*.h "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam/"
Expand All @@ -28,7 +28,7 @@ if [ "$ARG1" == "install" ]; then

notify-send "$msg" &> /dev/null || true
elif [ "$ARG1" == "uninstall" ]; then
"${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@/bin/varnamcli" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/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/"*
Expand Down
Loading