#!/bin/bash

. buildscripts/try

if [ "$#" == "0" ] ; then
echo "
    Usage: prepare <any argument>

    Any argument prepares for the icmake construction

    The file INSTALL.im specifies the absolute directory names where
    the various  components of icmake will be stored.

    A 'physical installation dir' prefixed to the directories
    specified by INSTALL.im can be specified when calling ./install.

    The directories specified in INSTALL.im are hard-coded in icmake's
    programs, so eventually the icmake files should be available under
    rootdir.
"                                     
    exit 0
fi

echo "
Creating the construction directory ./tmp"
    try rm -rf tmp          # remove an existing ./tmp directory
    try mkdir -p tmp        # and refresh a new one
    
# Verifying that the directories in INSTALL.im are absolute"
    . scripts/absdirs 

# Add VERSION's entries to tmp/INSTALL.* 
    . VERSION

    echo "\
#define AUTHOR      \"${AUTHOR}\"
#define VERSION     \"${VERSION}\"
#define YEARS       \"${YEARS}\"" >> tmp/INSTALL.im

    echo "\
AUTHOR=\"${AUTHOR}\"
VERSION=\"${VERSION}\"
YEARS=\"${YEARS}\"" >> tmp/INSTALL.sh

# Show the final installation paths
    echo "Final installation #defines:"
    cat tmp/INSTALL.im
    echo

echo "Creating icmake's construction directories below ./tmp"
try  mkdir -p tmp/usr/bin  tmp/usr/libexec/icmake  tmp/usr/share/icmake
try  mkdir -p tmp/etc/icmake tmp/usr/share/man/man1 
try  mkdir -p tmp/usr/share/man/man7 tmp/usr/share/doc/icmake

echo
echo Next: call ./buildlib x

echo
