From b34193c25cff2b4789446cf402b383bdbaa08206 Mon Sep 17 00:00:00 2001 From: Tim Wanders Date: Mon, 3 Jul 2017 19:09:22 +0200 Subject: [PATCH] [install] Add `make install` target (#684) The `make install` target can be used on Unixy platforms to install Xamarin.Android into a system-wide location. By default it installs into a prefix of `/usr/local`: make install The prefix may be changed by overriding the `$(prefix)` make variable: # Install system-wide make install prefix=/usr Installation is performed by copying the contents of `bin/$(CONFIGURATION)` into `$(prefix)/lib/xamarin.android`. Only `xabuild` is installed into `$(prefix)/bin` and (presumably) accessible within `$PATH`. --- Makefile | 25 +++++++++++++++++-- .../dependencies/linux-prepare-Arch.sh | 3 ++- tools/scripts/xabuild | 6 +++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index fc1089937..0ec3758b5 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ export OS := $(shell uname) export OS_ARCH := $(shell uname -m) export NO_SUDO ?= false V ?= 0 +prefix = /usr/local CONFIGURATION = Debug RUNTIME := $(shell if [ -f "`which mono64`" ] ; then echo mono64 ; else echo mono; fi) --debug=casts SOLUTION = Xamarin.Android.sln @@ -25,7 +26,27 @@ all:: all-tests:: MSBUILD="$(MSBUILD)" tools/scripts/xabuild $(MSBUILD_FLAGS) Xamarin.Android-Tests.sln - + +install:: + @if [ ! -d "bin/$(CONFIGURATION)" ]; then \ + echo "run 'make all' before you execute 'make install'!"; \ + exit 1; \ + fi + -mkdir -p "$(prefix)/lib/mono/xbuild-frameworks" + -mkdir -p "$(prefix)/lib/xamarin.android" + -mkdir -p "$(prefix)/lib/mono/xbuild/Xamarin/" + cp -a "bin/$(CONFIGURATION)/." "$(prefix)/lib/xamarin.android/" + cp tools/scripts/xabuild "$(prefix)/bin/xabuild" + -rm "$(prefix)/lib/mono/xbuild/Xamarin/Android" + -rm "$(prefix)/lib/mono/xbuild-frameworks/MonoAndroid" + ln -s "$(prefix)/lib/xamarin.android/lib/xbuild/Xamarin/Android/" "$(prefix)/lib/mono/xbuild/Xamarin/Android" + ln -s "$(prefix)/lib/xamarin.android/lib/xbuild-frameworks/MonoAndroid/" "$(prefix)/lib/mono/xbuild-frameworks/MonoAndroid" + +uninstall:: + rm -rf "$(prefix)/lib/xamarin.android/" "$(prefix)/bin/xabuild" + rm "$(prefix)/lib/mono/xbuild/Xamarin/Android" + rm "$(prefix)/lib/mono/xbuild-frameworks/MonoAndroid" + ifeq ($(OS),Linux) export LINUX_DISTRO := $(shell lsb_release -i -s || true) export LINUX_DISTRO_RELEASE := $(shell lsb_release -r -s || true) @@ -33,7 +54,7 @@ prepare:: linux-prepare endif # $(OS)=Linux prepare:: prepare-msbuild - + linux-prepare:: BINFMT_MISC_TROUBLE="cli win" \ BINFMT_WARN=no ; \ diff --git a/build-tools/scripts/dependencies/linux-prepare-Arch.sh b/build-tools/scripts/dependencies/linux-prepare-Arch.sh index 2f34cccdf..43d6f2d47 100644 --- a/build-tools/scripts/dependencies/linux-prepare-Arch.sh +++ b/build-tools/scripts/dependencies/linux-prepare-Arch.sh @@ -29,10 +29,11 @@ ARCH_DEPS="autoconf texinfo unzip which + zip xxd " if [ $NO_SUDO = "false" ]; then - sudo pacman -S --noconfirm $ARCH_DEPS + sudo pacman -S --noconfirm --needed $ARCH_DEPS else echo "Sudo is required!" fi diff --git a/tools/scripts/xabuild b/tools/scripts/xabuild index 5e44de8cd..fc9d67cbb 100755 --- a/tools/scripts/xabuild +++ b/tools/scripts/xabuild @@ -72,8 +72,10 @@ if [[ "$prefix" == */tools/scripts ]] ; then exit 1 fi prefix="$real_prefix" + xa_prefix="$real_prefix" elif [[ "$prefix" == */bin ]] ; then prefix="$prefix/.." + xa_prefix="$prefix/../lib/xamarin.android" else (>&2 echo "$name: Could not determine Xamarin.Android prefix.") exit 1 @@ -109,8 +111,8 @@ fi declare -a XABUILD_FLAGS XABUILD_FLAGS=( - /p:MonoAndroidBinDirectory="$prefix/bin" - /p:MonoAndroidToolsDirectory="$prefix/lib/mandroid" + /p:MonoAndroidBinDirectory="$xa_prefix/bin" + /p:MonoAndroidToolsDirectory="$xa_prefix/lib/mandroid" /p:MonoDroidInstallDirectory="$MONO_ANDROID_PATH" )