bootstrap 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/sh
  2. # Copyright © 2011 Rafaël Carré
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  17. export LC_ALL=
  18. NEEDED=
  19. if [ ! -f tools.mak ]
  20. then
  21. echo "You must run me in ./extras/tools !"
  22. exit 1
  23. fi
  24. check_tar() {
  25. if ! tar PcJ /dev/null >/dev/null 2>&1
  26. then
  27. echo "tar doesn't support xz (J option)"
  28. NEEDED="$NEEDED .tar .xz"
  29. fi
  30. }
  31. check_sed() {
  32. tmp="`pwd`/check_sed"
  33. trap "rm $tmp{,-e} 2>/dev/null" EXIT
  34. echo "test file for GNU sed" > $tmp
  35. if ! sed -i -e 's/sed//' $tmp >/dev/null 2>&1
  36. then
  37. echo "sed doesn't do in-place editing (-i option)"
  38. NEEDED="$NEEDED .sed"
  39. fi
  40. }
  41. check() {
  42. if ! $1 --version >/dev/null 2>&1
  43. then
  44. echo "$1 not found"
  45. NEEDED="$NEEDED .$1"
  46. else
  47. # found, need to check version ?
  48. [ -z "$2" ] && return # no
  49. gotver=`$1 --version | head -1 | sed s/'.* '//`
  50. gotmajor=`echo $gotver|cut -d. -f1`
  51. gotminor=`echo $gotver|cut -d. -f2`
  52. gotmicro=`echo $gotver|cut -d. -f3`
  53. [ -z "$gotmicro" ] && gotmicro=0
  54. needmajor=`echo $2|cut -d. -f1`
  55. needminor=`echo $2|cut -d. -f2`
  56. needmicro=`echo $2|cut -d. -f3`
  57. [ -z "$needmicro" ] && needmicro=0
  58. if [ "$needmajor" -gt "$gotmajor" \
  59. -o "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" \
  60. -o "$needmajor" -eq "$gotmajor" -a "$needminor" -eq "$gotminor" -a "$needmicro" -gt "$gotmicro" ]
  61. then
  62. echo "$1 too old"
  63. NEEDED="$NEEDED .$1"
  64. fi
  65. fi
  66. }
  67. check autoconf 2.69
  68. check automake 1.15
  69. check m4 1.4.17
  70. check libtool 2.4.6
  71. check pkg-config
  72. check cmake 3.2.2
  73. check yasm
  74. check_tar
  75. check_sed
  76. check gettext
  77. [ -n "$NEEDED" ] && mkdir -p build/ && echo "To-be-built packages: `echo $NEEDED | sed 's/\.//g'`"
  78. CPUS=
  79. CC=
  80. CXX=
  81. case `uname` in
  82. Linux)
  83. CPUS=`grep -c ^processor /proc/cpuinfo`
  84. ;;
  85. Darwin)
  86. CPUS=`sysctl hw.ncpu|cut -d: -f2`
  87. gcc-4.2 --version >/dev/null 2>&1 && CC=CC=gcc-4.2
  88. g++-4.2 --version >/dev/null 2>&1 && CXX=CXX=g++-4.2
  89. ;;
  90. SunOS)
  91. CPUS=`/usr/bin/kstat -p :::state | grep 'on-line$' | wc -l | sed 's/ //g'`
  92. ;;
  93. *)
  94. CPUS=1 # default
  95. ;;
  96. esac
  97. cat > Makefile << EOF
  98. MAKEFLAGS += -j$CPUS
  99. $CC
  100. $CXX
  101. PREFIX=\$(abspath ./build)
  102. all: $NEEDED
  103. @echo "You are ready to build SFLPhone and its contribs"
  104. include tools.mak
  105. EOF