#!/bin/sh cd "$(dirname "$0")" #******************************************************************************# # Defaults # #******************************************************************************# # Project variables name="$(make -s getname)" version="$(make -s getversion)" maintainer="$(make -s getmaintainer)" # Make options make_full_log= more_warnings= # Build options target= windows= default_zoom=8 default_storage=fls0 BUILD_p7=1 BUILD_p7screen=1 BUILD_p7os=0 BUILD_mcsfile=0 # Installation directories root='' prefix='${root}/usr' bindir='${prefix}/bin' mandir='${prefix}/share/man' # Installation options install_manpages=yes # # Tool name checking # check() { if [ $1 = "p7" ] || [ $1 = "p7screen" ] || [ $1 = "p7os" ] || [ $1 = "mcsfile" ]; then return 1 # true if there is a tool fi return 0 # false if not a tool } #******************************************************************************# # Help message # #******************************************************************************# usage() { cat < build and install the selected tool --disable- do not build or install the selected tool Tools: p7 enabled (default) p7screen enabled (default) p7os disabled (default) mcsfile disabled (default) Installation options: --noinstall-manpages do not install manpages Installation directories: --root=ROOT installation root [$root] --prefix=PREFIX main installation prefix [$prefix] Fine tuning of the installation directories: --bindir=DIR user executables, not "dustbin" [$bindir] --mandir=DIR man root [$mandir] Report bugs to ${maintainer}. EOF exit 0 } #******************************************************************************# # Version message # #******************************************************************************# version() { cat </dev/null ]; then echo "--default-zoom: a number is expected (got \"$zoom\")" >&2 elif [ $zoom -lt 1 ]; then echo "--default-zoom: should be 1 or more (got $zoom)" >&2 elif [ $zoom -gt 16 ]; then echo "--default-zoom: should be 16 or less (got $zoom)" >&2 else default_zoom=$zoom; fi ;; --default-storage=*) storage="${arg#*=}" # check if 4 chars long if [ ! $(echo "$storage" | wc -c ) -eq 5 ]; then echo "$0: --default-storage: must be 4 characters long" continue fi # then set default_storage="$storage" ;; --noinstall-manpages) install_manpages= ;; --root=*) root="${arg#*=}" ;; --prefix=*) prefix="${arg#*=}" ;; --bindir=*) bindir="${arg#*=}" ;; --mandir=*) mandir="${arg#*=}" ;; --enable-*) tool="${arg#--enable-}" if check $tool; then echo "error: connot enable $tool: unknown tool" exit 1 fi eval BUILD_$tool=1;; --disable-*) tool="${arg#--disable-}" if check $tool; then echo "error: connot disable $tool: unknown tool" exit 1 fi eval BUILD_$tool=0;; *) echo "$arg: didn't read" ;; esac; done #******************************************************************************# # Little things # #******************************************************************************# # Cross-compilation things if [ ! $prefix_set ] && [ $target ]; then prefix="$prefix"/"$target" fi # Check MS-Windows targets case "$target" in *-mingw32) windows=y ;; esac # Evaluate variables for var in prefix bindir mandir; do eval $var'='$(eval 'echo $'$var) done # Check if is on Cygwin [ "$(expr substr "$(uname -s)" 1 10)" = "MINGW32_NT" ] && windows=y # If on MS-Windows, do not make the manpages. [ "$windows" ] && install_manpages= #******************************************************************************# # Create Makefile configuration # #******************************************************************************# # Clean before. make mrproper MAKE_FULL_LOG=y 1>/dev/null 2>/dev/null # gen makefile function gen() { echo " #!/usr/bin/make -f #******************************************************************************# # Makefile configuration generated by ./configure # #******************************************************************************# # Configuration version and messages configuration CONFIG_VERSION := $version MAKE_FULL_LOG := $make_full_log MORE_WARNINGS := $more_warnings " echo -n "BINARIES :=" if [ $BUILD_p7 = 1 ]; then echo -n " p7" fi if [ $BUILD_p7screen = 1 ]; then echo -n " p7screen" fi if [ $BUILD_p7os = 1 ]; then echo -n " p7os" fi if [ $BUILD_mcsfile = 1 ]; then echo -n " mcsfile" fi echo " # Build options TARGET := $target FOR_WINDOWS := $windows DEFAULT_ZOOM := $default_zoom DEFAULT_STORAGE := $default_storage # Installation directories IBINDIR := $bindir IMANDIR := $mandir # Installation options INSTALL_MANPAGES := $install_manpages # End of file. " } gen | tee Makefile.cfg chmod +x Makefile.cfg #******************************************************************************# # Finish # #******************************************************************************# echo "Configuration loaded, you can make now." # End of file.