github.com/sylabs/singularity/v4@v4.1.3/makeit/install.sh (about)

     1  #!/bin/sh -
     2  # Copyright (c) 2015-2018, Yannick Cote <yhcote@gmail.com>. All rights reserved.
     3  # Use of this source code is governed by a BSD-style license that can be found
     4  # in the LICENSE file.
     5  set -e
     6  
     7  name=
     8  rootdir=
     9  
    10  usage () {
    11  	echo "Usage: ${0##*/} PROJECT_NAME PROJECT_ROOTDIR"
    12  	echo
    13  	echo "  Where :"
    14  	echo "    PROJECT_NAME: name of source code project"
    15  	echo "    PROJECT_ROOTDIR: the path to the root directory of the source code"
    16  	echo
    17  	exit 2
    18  }
    19  
    20  help () {
    21  	echo
    22  	echo "  Getting Start With Makeit"
    23  	echo " ==========================="
    24  	echo
    25  	echo "  ${0##*/} replaces the mconfig \`package_name' var with PROJECT_NAME the first"
    26  	echo "  option to the command and sets up a makeit tree inside the root directory of"
    27  	echo "  the source code project designated by PROJECT_ROOTDIR the second option passed"
    28  	echo "  to the command."
    29  	echo
    30  	echo "  At this point, to use makeit to bootstrap a \`make' (non-recursive Makefile)"
    31  	echo "	build system:"
    32  	echo
    33  	echo "    * Edit to remove or augment:"
    34  	echo "      - mlocal/frags/{release_opts.mk, Makefile.stub, common_opts.mk, etc.}"
    35  	echo "      - mlocal/checks/{project-pre.chk, project-post.chk}"
    36  	echo "    * Create {prog,lib}.mconf files for each elements to build"
    37  	echo "    * Run ./mconfig from the project rootdir"
    38  	echo "    * Build the project with make"
    39  	echo
    40  	echo "  Example:"
    41  	echo "  1) ./install.sh myproject /home/yhcote/projects/myproject"
    42  	echo "  2) cd /home/yhcote/projects/myproject"
    43  	echo "  3) Adjust CFLAGS, CPPFLAGS, LDFLAGS, etc., from files in mlocal/frags/*"
    44  	echo "  4) write project specific configure checks in project-pre.chk (to be run"
    45  	echo "     before basechecks.chk) or in project-post.chk (to be run after"
    46  	echo "     basechecks.chk)."
    47  	echo "  5) create an mconf file (myprog.mconf) for \`myprog' program to build:"
    48  	echo "  -----------------------------------------------------------------------"
    49  	echo "  name := myprog"
    50  	echo "  prog := myprog"
    51  	echo "  csrc := src/file1.c src/file2.c src/file3.c"
    52  	echo "  -----------------------------------------------------------------------"
    53  	echo "  6) ./mconfig"
    54  	echo "  7) cd builddir && make"
    55  	echo
    56  }
    57  
    58  if [ $# != 2 ]; then
    59  	usage
    60  fi
    61  
    62  name=$1
    63  if ! rootdir=`(cd $2 2>/dev/null && pwd -P)`; then
    64  	echo "error: $2 non-existent or permission denied"
    65  	exit 2
    66  fi
    67  
    68  echo "  => INSTALL: makeit for project $name -> $rootdir ..."
    69  
    70  install -d $rootdir/makeit
    71  install -d $rootdir/makeit/tmpl
    72  install -d $rootdir/mlocal/checks
    73  install -d $rootdir/mlocal/frags
    74  install -d $rootdir/mlocal/scripts
    75  install -m 0644 mlocal/frags/* $rootdir/mlocal/frags
    76  install -m 0644 mlocal/checks/* $rootdir/mlocal/checks
    77  install -m 0644 mlocal/scripts/* $rootdir/mlocal/scripts
    78  install -m 0644 tmpl/* $rootdir/makeit/tmpl
    79  install -m 0644 CONTRIBUTORS INSTALL.md LICENSE README.md $rootdir/makeit
    80  install -m 0755 genmod.awk install.sh $rootdir/makeit
    81  install -m 0755 mconfig $rootdir
    82  
    83  echo "  => NAME: setting variable \`package_name' to $name in $rootdir/mconfig..."
    84  sed -i "s/PROJECT_NAME/$name/g" $rootdir/mconfig
    85  
    86  echo "  => DONE: mconfig, mlocal/* and makeit/* added to project structure!"
    87  
    88  help