Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Allow to set libdir #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
35 changes: 20 additions & 15 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,38 +15,42 @@ 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-script:
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} -e "s#@INSTALL_PREFIX@#${INSTALL_PREFIX}#g" \
-e "s#@VERSION@#${VERSION}#g" \
-e "s#@LIBDIR@#${LIBDIR}#g" \
-e "s#@LIB_NAME@#${LIB_NAME}#g" \
install.sh.in > install.sh.tmp
mv install.sh.tmp install.sh
chmod +x install.sh

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
26 changes: 13 additions & 13 deletions install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ SUDO=${SUDO:-sudo}

if [ "$ARG1" == "install" ]; then
"${SUDO}" mkdir -p "/usr/local/bin/"
"${SUDO}" cp "$SCRIPT_DIR/varnamcli" "@INSTALL_PREFIX@/bin/varnamcli"
"${SUDO}" cp "$SCRIPT_DIR/varnamcli" "${DESTDIR}@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 "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/pkgconfig"
"${SUDO}" cp "$SCRIPT_DIR/@LIB_NAME@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@VERSION@"
"${SUDO}" ln -s "@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@.@VERSION@" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/@LIB_NAME@"
"${SUDO}" cp "$SCRIPT_DIR/govarnam.pc" "${DESTDIR}@INSTALL_PREFIX@@LIBDIR@/pkgconfig/"

"${SUDO}" mkdir -p "@INSTALL_PREFIX@/include/libgovarnam"
"${SUDO}" cp "$SCRIPT_DIR/"*.h "@INSTALL_PREFIX@/include/libgovarnam/"
"${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 "${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 "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam/"*
"${SUDO}" rmdir "${DESTDIR}@INSTALL_PREFIX@/include/libgovarnam"
"${SUDO}" rm "${DESTDIR}@INSTALL_PREFIX@/share/varnam/schemes/"*
"${SUDO}" rmdir "${DESTDIR}@INSTALL_PREFIX@/share/varnam/schemes/"

msg="Uninstallation finished"
echo $msg
Expand Down
Loading