ultimatepp/uppbox/Scripts/domake
amrein d668aeb488 Replace ' * Message' by ' - Message' to prevent shell substitution in error message
git-svn-id: svn://ultimatepp.org/upp/trunk@10713 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2017-01-15 21:21:41 +00:00

161 lines
4.7 KiB
Bash
Executable file

#!/bin/sh
# domake:
# Compile U++ main tools: theide and umk
### Variables
minimum_gcc_dumpversion="4.9.0"
show_debug_info="true"
show_debug_warning="true"
show_debug_error="true"
### Constants
script_name=$(echo "$0" | tr '[:lower:]' '[:upper:]' )
### Function declarations
. ./function_library
convert_version_to_number()
{
if [ -z "$1" ]
then
log_debug_error "Function 'convert_version_to_number' called with empty parameter"
return 1
fi
echo "$1" | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$/&00/'
return 0
}
### Main script start here
log_debug_info "Searching for g++ compiler"
minimum_gcc_version=$(convert_version_to_number "$minimum_gcc_dumpversion")
if which g++
then
log_debug_info "Found $(which g++)"
gcc_dumpversion=$(gcc -dumpversion)
gcc_version=$(convert_version_to_number "$gcc_dumpversion")
if [ "$gcc_version" -gt "$minimum_gcc_version" ]
then
use_gcc="true"
else
use_gcc="false"
log_debug_warning "The g++ compiler found (e.q $gcc_dumpversion) has a lower version than the minimum required version (e.q $minimum_gcc_dumpversion)"
fi
else
use_gcc="false"
fi
if [ "$use_gcc" = "false" ]
then
log_debug_info "Searching for clang++ compiler"
if which clang++
then
use_clang="true"
else
use_clang="false"
log_debug_warning "Can't find clang++ compiler in PATH"
log_debug_error "No compatible c++ compiler found in PATH"
log_debug "${COLOR_WHITE}SOLUTIONS (a few):${COLOR_NC}"
log_debug " - Install a compatible gcc-c++ version (> $minimum_gcc_dumpversion)"
log_debug " - Or install clang++ LLVM compiler"
log_debug " - Or add clang++ or g++ path to the PATH variable (if clang++ or a g++ compatible version is already installed)"
exit 1
fi
fi
log_debug_info "Configuring uppsrc/Makefile, uppsrc/uMakefile, GCC.bm and CLANG.bm with pkg-config"
if which pkg-config
then
library_list=""
for i in gtk+-2.0 x11 libnotify freetype2
do
if pkg-config --exists $i
then
library_list="$library_list $i"
log_debug_info "pkg-config: Found library $i"
else
log_debug_warning "pkg-config: '$i' not found in $(pkg-config --variable pc_path pkg-config). Do you need to install $i developpement package?"
fi
done
sed -e "s@-I((INCLUDES))@`pkg-config --cflags-only-I $library_list`@g" -e "s@-L\"((LIBRARIES))\"@`pkg-config --libs-only-L $library_list`@g" uppsrc/Makefile.in >uppsrc/Makefile
sed -e "s@-I((INCLUDES))@`pkg-config --cflags-only-I $library_list`@g" -e "s@-L\"((LIBRARIES))\"@`pkg-config --libs-only-L $library_list`@g" uppsrc/uMakefile.in >uppsrc/uMakefile
sed -e "s@((INCLUDES))@`pkg-config --cflags-only-I $library_list|sed -e s/-I//g -e \"s/ /;/g\"`@g" -e "s@((LIBRARIES))@`pkg-config --libs-only-L $library_list|sed -e s/-L//g -e \"s/ /;/g\"`@g" GCC.bm.in >GCC.bm
sed -e "s@((INCLUDES))@`pkg-config --cflags-only-I $library_list|sed -e s/-I//g -e \"s/ /;/g\"`@g" -e "s@((LIBRARIES))@`pkg-config --libs-only-L $library_list|sed -e s/-L//g -e \"s/ /;/g\"`@g" CLANG.bm.in >CLANG.bm
else
log_debug_warning "Can't find pkg-config in PATH. Will do configuration without it. Compilation will probably fail"
log_debug_warning "If compilation fail because of missing include, please install pkg-config before reporting"
sed -e "s@-I((INCLUDES))@@g" -e 's@-L"((LIBRARIES))"@@g' uppsrc/Makefile.in >uppsrc/Makefile
sed -e "s@-I((INCLUDES))@@g" -e 's@-L"((LIBRARIES))"@@g' uppsrc/uMakefile.in >uppsrc/uMakefile
sed -e "s@((INCLUDES));@@g" -e "s@((LIBRARIES));@@g" GCC.bm.in >GCC.bm
sed -e "s@((INCLUDES));@@g" -e "s@((LIBRARIES));@@g" CLANG.bm.in >CLANG.bm
fi
if [ ! -f /usr/lib/libdl.so -a ! -f /usr/lib64/libdl.so ]
then
sed -i -e s/-ldl//g uppsrc/Makefile
sed -i -e s/-ldl//g uppsrc/uMakefile
fi
log_debug_info "Searching for gmake or make"
if which gmake
then
make_binary="gmake"
elif which make
then
make_binary="make"
else
log_debug_error "No 'make' application found in PATH"
exit 2
fi
log_debug_info "Found $make_binary. Compiling..."
if [ "$use_gcc" = "true" ]
then
$make_binary -C uppsrc
$make_binary -C uppsrc -f uMakefile
elif [ "$use_clang" = "true" ]
then
$make_binary -C uppsrc -e CXX="clang++" -e CXXFLAGS="-O3 -ffunction-sections -fdata-sections -Wno-logical-op-parentheses -std=c++11"
$make_binary -C uppsrc -f uMakefile -e CXX="clang++" -e CXXFLAGS="-O3 -ffunction-sections -fdata-sections -Wno-logical-op-parentheses -std=c++11"
fi
if [ -f uppsrc/ide.out ]
then
log_debug_info "Installing theide in current directory"
cp -p uppsrc/ide.out ./theide
fi
if [ -f uppsrc/umk.out ]
then
log_debug_info "Installing umk in current directory"
cp -p uppsrc/umk.out ./umk
fi