diff options
author | rofl0r <retnyg@gmx.net> | 2018-06-17 11:22:38 +0100 |
---|---|---|
committer | rofl0r <retnyg@gmx.net> | 2018-06-17 11:22:38 +0100 |
commit | 38c2aea709b47e2e3c08ecebe0c51a3a4f528635 (patch) | |
tree | 3b8830f0b2b28d8142427c4c49caa6be5ded02de | |
parent | edf21ef7aa9423b95aa49e2018eacfbcf1f3eac9 (diff) | |
download | libnl-tiny-38c2aea709b47e2e3c08ecebe0c51a3a4f528635.tar.gz |
fix install command for retarded OS's (Mac OS X)
install.sh taken from https://github.com/rofl0r/install.sh
-rw-r--r-- | Makefile | 7 | ||||
-rwxr-xr-x | install.sh | 67 |
2 files changed, 71 insertions, 3 deletions
@@ -5,6 +5,7 @@ includedir=$(prefix)/include CC=gcc AR=ar RANLIB=ranlib +INSTALL=./install.sh WFLAGS=-Wall CFLAGS?=-O2 INCLUDES=-Iinclude @@ -50,13 +51,13 @@ $(PCFILE): $(PCFILE).in $(DESTDIR)$(includedir)/libnl-tiny/%: include/% - install -D -m 644 $< $@ + $(INSTALL) -D -m 644 $< $@ $(DESTDIR)$(libdir)/%: % - install -D -m 644 $< $@ + $(INSTALL) -D -m 644 $< $@ $(DESTDIR)$(libdir)/pkgconfig/%: % - install -D -m 644 $< $@ + $(INSTALL) -D -m 644 $< $@ .PHONY: all clean install diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..0410883 --- /dev/null +++ b/install.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# +# Written by Rich Felker, originally as part of musl libc. +# Multi-licensed under MIT, 0BSD, and CC0. +# +# This is an actually-safe install command which installs the new +# file atomically in the new location, rather than overwriting +# existing files. +# + +usage() { +printf "usage: %s [-D] [-l] [-m mode] src dest\n" "$0" 1>&2 +exit 1 +} + +mkdirp= +symlink= +mode=755 + +while getopts Dlm: name ; do +case "$name" in +D) mkdirp=yes ;; +l) symlink=yes ;; +m) mode=$OPTARG ;; +?) usage ;; +esac +done +shift $(($OPTIND - 1)) + +test "$#" -eq 2 || usage +src=$1 +dst=$2 +tmp="$dst.tmp.$$" + +case "$dst" in +*/) printf "%s: %s ends in /\n", "$0" "$dst" 1>&2 ; exit 1 ;; +esac + +set -C +set -e + +if test "$mkdirp" ; then +umask 022 +case "$2" in +*/*) mkdir -p "${dst%/*}" ;; +esac +fi + +trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP + +umask 077 + +if test "$symlink" ; then +ln -s "$1" "$tmp" +else +cat < "$1" > "$tmp" +chmod "$mode" "$tmp" +fi + +mv -f "$tmp" "$2" +test -d "$2" && { +rm -f "$2/$tmp" +printf "%s: %s is a directory\n" "$0" "$dst" 1>&2 +exit 1 +} + +exit 0 |