From ab4c68601e8dd0a22668b73565495a0a7b05171f Mon Sep 17 00:00:00 2001 From: Johann ELSASS Date: Tue, 3 Nov 2020 10:57:48 +0100 Subject: [PATCH] add configure script --- configure | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ configure.bat | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100755 configure create mode 100644 configure.bat diff --git a/configure b/configure new file mode 100755 index 00000000..8aa9e813 --- /dev/null +++ b/configure @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +echo For help type: ./configure --help +args=("$@") +haserror=false +defaultfpc=fpc +wantedfpc=$defaultfpc +if [ -f "debian/CONFIGURE_DEFAULT_FPCBIN" ]; then + wantedfpc=$(cat debian/CONFIGURE_DEFAULT_FPCBIN) +fi +defaultprefix=/usr/local +wantedprefix=$defaultprefix +if [ -f "debian/CONFIGURE_DEFAULT_LAZDIR" ]; then + wantedlazdir=$(cat debian/CONFIGURE_DEFAULT_LAZDIR) +else + wantedlazdir= +fi +for param in "${args[@]}" +do + if [ "$param" == "-h" ] || [ "$param" == "--help" ]; then + echo "Usage: ./configure [OPTIONS]" + echo "" + echo " --prefix=PREFIX" + echo " Specifies the install prefix." + echo " By default prefix is \"$defaultprefix\"" + echo " For packages use \"/usr\"" + echo "" + echo " --lazdir=BASE_DIRECTORY_OF_LAZARUS" + echo " Specifies to compile with FPC using the specified Lazarus sources." + echo " Otherwise lazbuild will be used." + echo "" + echo " --fpcbin=FPC_BINARY" + echo " Specifies the command to call Free Pascal Compiler." + echo " Default is \"$defaultfpc\"" + exit 0 + elif [ "${param:0:9}" == "--prefix=" ]; then + wantedprefix=${param:9} + elif [ "${param:0:9}" == "--lazdir=" ]; then + wantedlazdir=${param:9} + elif [ "${param:0:9}" == "--fpcbin=" ]; then + wantedfpc=${param:9} + else + echo "Warning: unknown option $param" + fi +done +echo "Prefix set to: $wantedprefix" +echo $wantedprefix >prefix +if [ "$wantedlazdir" == "" ]; then + echo "Using lazbuild" + rm -f lazdir + touch lazdir + rm -f fpcbin +else + echo "Using FPC with Lazarus source: $wantedlazdir" + if [ ! -d "$wantedlazdir" ]; then + echo "Error: directory not found!" + haserror=true + elif [ ! -d "$wantedlazdir/lcl" ]; then + echo "Warning: it does not seem to be the directory of Lazarus!" + fi + echo $wantedlazdir >lazdir + echo "Compiler set to: $wantedfpc" + rm -f fpcbin + echo $wantedfpc >fpcbin +fi +if [ "$haserror" = true ]; then + exit 1 +else + if [ "$(uname)" == "FreeBSD" ]; then + echo "You can now type: gmake" + else + echo "You can now type: make" + fi + exit 0 +fi diff --git a/configure.bat b/configure.bat new file mode 100644 index 00000000..84fd1979 --- /dev/null +++ b/configure.bat @@ -0,0 +1,70 @@ +@echo off +echo For help type: configure /? +set defaultfpc=fpc +set wantedfpc=%defaultfpc% +set wantedlazdir= + +:nextparam +set param=%~1 +if "%param%" == "" goto endparam +if "%param%" == "--help" goto showhelp +if "%param%" == "-h" goto showhelp +if "%param%" == "/help" goto showhelp +if "%param%" == "/?" goto showhelp +if "%param:~0,9%" == "--lazdir=" ( + set wantedlazdir=%param:~9% +) else if "%param%" == "--lazdir" ( + set wantedlazdir=%~2 + shift +) else if "%param:~0,9%" == "--fpcbin=" ( + set wantedfpc=%param:~9% +) else if "%param%" == "--fpcbin" ( + set wantedfpc=%~2 + shift +) else ( + echo Error: unknown option %param% + exit /b 1 +) + +shift +goto nextparam +:endparam + +if exist fpcbin del fpcbin +lazdir +if "%wantedlazdir%" == "" ( + echo Using lazbuild + lazbuild -h > NUL 2> NUL + if errorlevel 1 ( + echo Error: Lazarus needs to be in the PATH + exit /b 1 + ) +) else ( + echo Using FPC with Lazarus source: %wantedlazdir% + if not exist "%wantedlazdir%\" ( + echo Error: directory not found + exit /b 1 + ) else if not exist "%wantedlazdir%\lcl\" ( + echo Warning: it does not seem to be the directory of Lazarus! + ) + fpcbin + %wantedfpc% -h > NUL 2> NUL + if errorlevel 1 ( + echo Error: FPC needs to be in the PATH + exit /b 1 + ) +) + +echo You can now type: make +exit /b 0 + +:showhelp +echo Usage: configure [OPTIONS] +echo. +echo --lazdir=BASE_DIRECTORY_OF_LAZARUS +echo Specifies to compile with FPC using the specified Lazarus sources. +echo Otherwise lazbuild will be used. +echo. +echo --fpcbin=FPC_BINARY +echo Specifies the command to call Free Pascal Compiler. +echo Default is %defaultfpc%