3 # install-mk - install mk files
6 # install-mk [options] [var=val] [dest]
9 # This tool installs mk files in a semi-intelligent manner into
14 # -n just say what we want to do, but don't touch anything.
16 # -f use -f when copying sys,mk.
23 # Use "mode" for installed files (444).
26 # Use "owner" for installed files.
29 # Use "group" for installed files.
32 # Set "var" to "val". See below.
34 # All our *.mk files are copied to "dest" with appropriate
35 # ownership and permissions.
37 # By default if a sys.mk can be found in a standard location
38 # (that bmake will find) then no sys.mk will be put in "dest".
41 # If set, we will avoid installing our 'sys.mk'
42 # This is probably a bad idea.
45 # If set, we will skip making bsd.*.mk links to *.mk
49 # By default (and provided we are not installing to the system
50 # mk dir - '/usr/share/mk') we install our own 'sys.mk' which
51 # includes a sys specific file, or a generic one.
55 # Simon J. Gerraty <sjg@crufty.net>
58 # $Id: install-mk,v 1.150 2017/10/19 03:50:51 sjg Exp $
60 # @(#) Copyright (c) 1994 Simon J. Gerraty
62 # This file is provided in the hope that it will
63 # be of use. There is absolutely NO WARRANTY.
64 # Permission to copy, redistribute or otherwise
65 # use this file is hereby granted provided that
66 # the above copyright notice and this notice are
69 # Please send copies of changes and bug-fixes to:
85 *=*) eval "$1"; shift;;
88 -m) MODE=$2; shift 2;;
89 -o) OWNER=$2; shift 2;;
90 -g) GROUP=$2; shift 2;;
91 -v) ECHO=echo; shift;;
93 -n) ECHO=echo SKIP=:; shift;;
100 0) echo "$0 [options] <destination> [<os>]"
102 echo "$0 -o bin -g bin -m 444 /usr/local/share/mk"
108 osrel=${3:-`uname -r`}
121 echo "WARNING: $@" >&2
124 [ "$FORCE_SYS_MK" ] && Warning "ignoring: FORCE_{BSD,SYS}_MK (no longer supported)"
126 SYS_MK_DIR=${SYS_MK_DIR:-/usr/share/mk}
127 SYS_MK=${SYS_MK:-$SYS_MK_DIR/sys.mk}
130 [ -d $1 ] && cd $1 && 'pwd' && return
134 if [ -s $SYS_MK -a -d $dest ]; then
135 # if this is a BSD system we don't want to touch $SYS_MK
136 dest=`realpath $dest`
137 sys_mk_dir=`realpath $SYS_MK_DIR`
138 if [ $dest = $sys_mk_dir ]; then
144 if [ ! -d $dest/sys -a ! -s $dest/Generic.sys.mk ]; then
145 SKIP_SYS_MK=: # play safe
153 [ -d $dest/sys ] || Do mkdir -p $dest/sys
154 [ -d $dest/sys ] || Do mkdir $dest/sys || exit 1
155 [ -z "$SKIP" ] && dest=`realpath $dest`
159 if [ $mksrc = $dest ]; then
162 # we do not install the examples
163 mk_files=`grep '^[a-z].*\.mk' FILES | egrep -v '(examples/|^sys\.mk|sys/)'`
164 mk_scripts=`egrep '^[a-z].*\.(sh|py)' FILES | egrep -v '/'`
165 sys_mk_files=`grep 'sys/.*\.mk' FILES`
167 [ -z "$SKIP_SYS_MK" ] && mk_files="sys.mk $mk_files"
169 $SKIP_MKFILES Do cp $cp_f $mk_files $dest
170 $SKIP_MKFILES Do cp $cp_f $sys_mk_files $dest/sys
171 $SKIP_MKFILES Do cp $cp_f $mk_scripts $dest
173 $SKIP_MKFILES Do chmod $MODE $mk_files $sys_mk_files
174 $SKIP_MKFILES Do chmod $BINMODE $mk_scripts
175 [ "$GROUP" ] && $SKIP_MKFILES Do chgrp $GROUP $mk_files $sys_mk_files
176 [ "$OWNER" ] && $SKIP_MKFILES Do chown $OWNER $mk_files $sys_mk_files
177 # if this is a BSD system the bsd.*.mk should exist and be used.
178 if [ -z "$SKIP_BSD_MK" ]; then
179 for f in dep doc files inc init lib links man nls obj own prog subdir
182 [ -s $b ] || Do ln -s $f.mk $b