Skip to content

Commit

Permalink
Mac OS X support (#61)
Browse files Browse the repository at this point in the history
  * Add Homebrew gnubin directories to PATH
  * Configure bash-completion
  * Configure gpg-agent to use pinentry-mac
  * Handle platform-specific GVim font specification
  * Fixes #60

Signed-off-by: Mike Detwiler <[email protected]>
  • Loading branch information
detwiler authored Jul 17, 2018
1 parent 02b95ed commit cbaaba3
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 33 deletions.
46 changes: 40 additions & 6 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ gnulib_tool = gnulib-tool
vc_list_files = vc-list-files
gnulib_scripts = $(gnulib_tool) \
$(vc_list_files)
gnupgdir = $(homedir)/.gnupg
gpg_agent_conf = $(gnupgdir)/gpg-agent.conf
install_data_targets =
uninstall_targets =

pkgconf_DATA = $(pkg_release)

Expand All @@ -21,8 +25,7 @@ DISTCLEANFILES = $(gvg_version) \
EXTRA_DIST = $(gvg_version) \
m4/gnulib-cache.m4

DISTCHECK_CONFIGURE_FLAGS = HOME=$(top_distdir) \
--enable-local-bash-completion=$enable_local_bash_comp
DISTCHECK_CONFIGURE_FLAGS = HOME=$(top_distdir)

$(gvg_version): Makefile
$(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
Expand All @@ -38,8 +41,10 @@ gen-ChangeLog:
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
fi

.PHONY: mk-bindir
mk-bindir:
$(AM_V_GEN)test -e $(DESTDIR)$(bindir) || mkdir -p $(DESTDIR)$(bindir)
$(AM_V_GEN)test -e $(DESTDIR)$(bindir) \
|| $(MKDIR_P) $(DESTDIR)$(bindir)

$(gnulib_tool): mk-bindir
$(AM_V_GEN)cd $(DESTDIR)$(bindir) && \
Expand All @@ -49,12 +54,41 @@ $(vc_list_files): mk-bindir
$(AM_V_GEN)cd $(DESTDIR)$(bindir) && \
test -h $@ || $(LN_S) $(GNULIB_SRCDIR)/build-aux/$@

if HAVE_GNULIB_SRCDIR
install-data-hook: $(gnulib_scripts)
uninstall-hook:
.PHONY: rm-gnulib-scripts
rm-gnulib-scripts:
$(AM_V_GEN)cd $(DESTDIR)$(bindir) && \
rm -f $(gnulib_scripts)

if HAVE_GNULIB_SRCDIR
install_data_targets += $(gnulib_scripts)
uninstall_targets += rm-gnulib-scripts
endif

.PHONY: mk-gnupgdir
mk-gnupgdir:
$(AM_V_GEN)test -e $(DESTDIR)$(gnupgdir) || \
$(MKDIR_P) -m 0700 $(DESTDIR)$(gnupgdir)

.PHONY: gpg-agent-pinentry-mac
gpg-agent-pinentry-mac: mk-gnupgdir
$(AM_V_GEN)$(GREP) '^pinentry-program' $(DESTDIR)$(gpg_agent_conf) &>/dev/null || \
printf 'pinentry-program %s\n' $(PINENTRY_MAC) >>$(DESTDIR)$(gpg_agent_conf)

.PHONY: rm-gpg-agent-pinentry-mac
rm-gpg-agent-pinentry-mac: mk-gnupgdir
$(AM_V_GEN)$(GREP) -v '^pinentry-program $(PINENTRY_MAC)' $(DESTDIR)$(gpg_agent_conf) &>/dev/null || \
rm $(DESTDIR)$(gpg_agent_conf)

if HAVE_GPG_AGENT
if HAVE_PINENTRY_MAC
install_data_targets += gpg-agent-pinentry-mac
uninstall_targets += rm-gpg-agent-pinentry-mac
endif
endif

install-data-hook: $(install_data_targets)

uninstall-hook: $(uninstall_targets)

dist-hook: gen-ChangeLog
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
65 changes: 50 additions & 15 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ AC_CONFIG_SRCDIR([data/bash/common/bashrc.in])
AM_INIT_AUTOMAKE([-Wall -Wno-portability -Werror dist-bzip2])
AM_SILENT_RULES([yes])

## determine host os ##
AC_CANONICAL_HOST

AM_CONDITIONAL([HOST_OS_DARWIN], [grep darwin <<<$host_os &>/dev/null])

AC_PREFIX_DEFAULT([$HOME/.local])

AC_SUBST([homedir], [$HOME])
Expand All @@ -33,6 +38,7 @@ QH_VAR_ENSURE([REFDIR],

AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MKDIR_P
AC_PROG_SED

## aws-cli ##
Expand All @@ -58,18 +64,23 @@ AM_COND_IF([HAVE_BASH_PATH],
[AC_SUBST([BASH_PATH])
MULTI_BASH_HACK=data/bash/common/multi-bash-hack.sh
AC_CONFIG_FILES([data/bash/common/multi-bash-hack.sh])],
[MULTI_BASH_HACK=data/bash/common/single-bash.sh])
[MULTI_BASH_HACK=data/bash/common/single-bash.sh])
AC_SUBST_FILE([MULTI_BASH_HACK])

# option to enable local bash-completion
AC_ARG_ENABLE([local-bash-completion],
[AS_HELP_STRING([--enable-local-bash-completion]
[install bash-completion configuration locally])],
[enable_local_bash_comp=$enableval],
[enable_local_bash_comp=no])
AM_CONDITIONAL([ENABLE_LOCAL_BASH_COMP],
[test "x$enable_local_bash_comp" = xyes])

# bash-completion not enabled by default on Darwin
AM_COND_IF([HOST_OS_DARWIN],
[QH_VAR_ENSURE([BASH_COMPLETION],
[path to bash completion script],
[/usr/local/etc/bash_completion])
QH_VAR_ENSURE([BASH_COMPLETION_DIR],
[path to bash completion directory],
[/usr/local/etc/bash_completion.d])
QH_VAR_ENSURE([BASH_COMPLETION_COMPAT_DIR],
[path to bash completion compat directory],
[/usr/local/etc/bash_completion.d])
AC_CONFIG_FILES([data/bash/common/bashrc.d/bash-completion.sh])])

# readline configuration
AM_CONDITIONAL([BIND_INPUTRC], [test "x$INPUTRC" != x])

# customization of PS1 color
Expand Down Expand Up @@ -106,13 +117,24 @@ AM_COND_IF([HAVE_EXUBERANT_CTAGS],
[AC_SUBST([EXUBERANT_CTAGS], [$ac_cv_path_EXUBERANT_CTAGS])
AC_CONFIG_FILES([data/bash/common/bashrc.d/ctags-alias.sh])])

## gpg2 ##
## gpg ##

AC_ARG_VAR([GPG], [path to gpg])
# gpg2 #
AC_ARG_VAR([GPG], [gpg program])
AC_CHECK_PROGS([GPG], [gpg2 gpg], [gpg])
AM_CONDITIONAL([HAVE_GPG2], [test "x$GPG" = xgpg2])
AM_COND_IF([HAVE_GPG2], [AC_CONFIG_FILES([data/bash/common/bashrc.d/gpg2.sh])])

# gpg-agent
AC_ARG_VAR([GPG_AGENT], [gpg-agent program])
AC_CHECK_PROGS([GPG_AGENT], [gpg-agent], [no])
AM_CONDITIONAL([HAVE_GPG_AGENT], [test "x$GPG_AGENT" != xno])

# pinentry-mac
AC_ARG_VAR([PINENTRY_MAC], [path to pinentry-mac])
AC_PATH_PROG([PINENTRY_MAC], [pinentry-mac], [no])
AM_CONDITIONAL([HAVE_PINENTRY_MAC], [test "x$PINENTRY_MAC" != xno])

## git ##

QH_VAR_ENSURE([GIT_AUTHOR_NAME],
Expand Down Expand Up @@ -177,6 +199,14 @@ AM_COND_IF([HAVE_GREP_COLOR],
[AC_SUBST([GREP_COLOR], [$ac_cv_path_GREP_COLOR])
AC_CONFIG_FILES([data/bash/common/bashrc.d/grep.sh])])

## homebrew gnubin paths ##

AM_COND_IF([HOST_OS_DARWIN],
[QH_VAR_ENSURE([HOMEBREW_PREFIX],
[Homebrew prefix],
[/usr/local])
AC_CONFIG_FILES([data/bash/common/gnubin-pathmung])])

## systemd ##

# check for systemd-path
Expand All @@ -196,6 +226,10 @@ AC_CHECK_PROG([EDITOR], [vim], [vim], [vi])
AM_CONDITIONAL([HAVE_VIM], [test "x$EDITOR" = xvim])
AM_COND_IF([HAVE_VIM], [AC_CONFIG_FILES([data/vim/.gvimrc])])

QH_VAR_ENSURE([VIMRC_EXAMPLE_PATH],
[path to vimrc_example.vim],
[`(rpm -ql vim-common 2>/dev/null | grep '/vimrc_example.vim') || echo /dev/null`])

QH_VAR_ENSURE([GVIM_FONT],
[gvim font],
[Monospace])
Expand All @@ -204,9 +238,10 @@ QH_VAR_ENSURE([GVIM_FONT_SIZE],
[gvim font size],
[11])

QH_VAR_ENSURE([VIMRC_EXAMPLE_PATH],
[path to vimrc_example.vim],
[`(rpm -ql vim-common 2>/dev/null | grep '/vimrc_example.vim') || echo /dev/null`])
AM_COND_IF([HOST_OS_DARWIN],
[GVIM_FONT_SEPARATOR=:h],
[GVIM_FONT_SEPARATOR='\ '])
AC_SUBST([GVIM_FONT_SEPARATOR])

AC_CONFIG_FILES([Makefile
data/Makefile
Expand Down
2 changes: 1 addition & 1 deletion data/autoconf/config-site-sysvinit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vim:ft=sh

test "$sysconfdir" = '${prefix}/etc' && sysconfdir="${XDG_CONFIG_HOME:-$HOME/.config}"
test "$libdir" = '${exec_prefix}/lib' && libdir="$HOME/.local/lib/`/bin/arch`"
test "$libdir" = '${exec_prefix}/lib' && libdir="$HOME/.local/lib/`uname -m`"
5 changes: 5 additions & 0 deletions data/bash/common/.bashrc.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ fi
pathmung @bindir@
pathmung @sbindir@

# Add Homebrew gnubin directories to PATH
if [ -f "@pkgconfdir@/gnubin-pathmung" ]; then
source "@pkgconfdir@/gnubin-pathmung"
fi

if [ -f "@pkgconfdir@/bashrc" ]; then
source "@pkgconfdir@/bashrc"
fi
1 change: 1 addition & 0 deletions data/bash/common/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
bashrc
functions
global-bash
gnubin-pathmung
multi-bash-hack.sh
profile
5 changes: 5 additions & 0 deletions data/bash/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ bashrc_h = .bashrc
bashrc = bashrc
functions = functions
global_bash = global-bash
gnubin_pathmung = gnubin-pathmung
profile = profile

# data/scripts generated by configure (source file automatically distributed)
conf_data = $(functions) \
$(global_bash)

if HOST_OS_DARWIN
conf_data += $(gnubin_pathmung)
endif

pkgconf_DATA = $(conf_data)

DISTCLEANFILES = $(conf_data)
Expand Down
11 changes: 4 additions & 7 deletions data/bash/common/bashrc.d/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ if HAVE_GREP_COLOR
conf_data += $(grep)
endif

if HOST_OS_DARWIN
conf_data += $(bash_completion)
endif

bashrc_DATA = $(conf_data)

DISTCLEANFILES = $(conf_data)

# data/scripts generated by make (require explicit distribution of source file)
make_data =

if ENABLE_LOCAL_BASH_COMP
make_data += $(bash_completion)
endif

bashrc_DATA += $(make_data)

$(make_data): Makefile
Expand All @@ -87,9 +87,6 @@ EXTRA_DIST = $(make_sources) \

CLEANFILES = $(make_output)

# sed command to build data/scripts
EDIT = -e 's:@sysconfdir[@]:$(sysconfdir):g'

mk-bashrcdir:
$(AM_V_GEN)test -e $(DESTDIR)$(bashrcdir) || \
mkdir -p $(DESTDIR)$(bashrcdir)
Expand Down
6 changes: 3 additions & 3 deletions data/bash/common/bashrc.d/bash-completion.sh.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Check for interactive bash and that we haven't already been sourced.
[ -z "$BASH_VERSION" -o -z "$PS1" -o -n "$BASH_COMPLETION" ] && return

BASH_COMPLETION=@sysconfdir@/bash_completion
BASH_COMPLETION_DIR=@sysconfdir@/bash_completion.d
BASH_COMPLETION_COMPAT_DIR=@sysconfdir@/bash_completion.d
BASH_COMPLETION=@BASH_COMPLETION@
BASH_COMPLETION_DIR=@BASH_COMPLETION_DIR@
BASH_COMPLETION_COMPAT_DIR=@BASH_COMPLETION_COMPAT_DIR@

# Check for recent enough version of bash.
bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}
Expand Down
5 changes: 5 additions & 0 deletions data/bash/common/gnubin-pathmung.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# vim: ft=sh

for dir in $(find @HOMEBREW_PREFIX@/opt -follow -type d -name gnubin | sort -r); do
pathmung $dir
done
2 changes: 1 addition & 1 deletion data/vim/.gvimrc.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" vim: set ft=vim :

" set the default font for gvim
set guifont=@GVIM_FONT@\ @GVIM_FONT_SIZE@
set guifont=@GVIM_FONT@@GVIM_FONT_SEPARATOR@@GVIM_FONT_SIZE@

set guioptions=aei

Expand Down

0 comments on commit cbaaba3

Please sign in to comment.