setup.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/usr/bin/env bash
  2. revision=0
  3. [[ -s revision.sh ]] && . revision.sh
  4. if [[ -d .svn ]] && which svn >/dev/null 2>&1
  5. then
  6. revision="$( svn info . | awk '$1=="Revision:" {print $2}' )"
  7. if which svnversion >/dev/null 2>&1
  8. then
  9. rev="$(svnversion|sed 's/.*://')"
  10. (( ${revision//[!0-9]/} < ${rev//[!0-9]/} )) && revision=$rev
  11. fi
  12. echo "revision=$revision" > revision.sh
  13. fi
  14. revision_num="${revision//[!0-9]/}"
  15. revision_next=$revision_num
  16. [[ $revision = $revision_num ]] || let revision_next++
  17. tim=($(date '+%s %Y-%m-%d %T'))
  18. defines=
  19. have_fuse=0
  20. [[ $NO_FUSE != 1 && -r /usr/include/fuse.h || -r /usr/local/include/fuse.h ]] \
  21. && have_fuse=1
  22. have_md5=0
  23. [[ -r /usr/include/openssl/md5.h ]] && have_md5=1
  24. have_sha=0
  25. [[ -r /usr/include/openssl/sha.h ]] && have_sha=1
  26. have_zlib=0
  27. if [[ $NO_ZLIB != 1 && -r /usr/include/zlib.h || -r /usr/local/include/zlib.h ]]
  28. then
  29. have_zlib=1
  30. defines="$defines -DHAVE_ZLIB=1"
  31. fi
  32. if [[ $M32 = 1 ]]
  33. then
  34. force_m32=1
  35. have_fuse=0
  36. xflags="-m32"
  37. defines="$defines -DFORCE_M32=1"
  38. else
  39. force_m32=0
  40. xflags=
  41. fi
  42. [[ -r /usr/include/bits/fcntl.h ]] \
  43. && grep -qw fallocate /usr/include/bits/fcntl.h \
  44. && defines="$defines -DHAVE_FALLOCATE=1"
  45. [[ -r /usr/include/fcntl.h ]] \
  46. && grep -qw posix_fallocate /usr/include/fcntl.h \
  47. && defines="$defines -DHAVE_POSIX_FALLOCATE=1"
  48. [[ -r /usr/include/linux/fiemap.h ]] \
  49. && grep -qw fiemap_extent /usr/include/linux/fiemap.h \
  50. && defines="$defines -DHAVE_FIEMAP=1"
  51. [[ $STATIC = 1 ]] || STATIC=0
  52. #--------------------------------------------------
  53. GCC_VERSION="$( gcc --version | head -n1 | sed 's/([^)]*)//'|awk '{print $2}' )"
  54. [[ $GCC_VERSION > 7 ]] && xflags+=" -fdiagnostics-color=always"
  55. gcc $xflags -E -DPRINT_SYSTEM_SETTINGS system.c \
  56. | awk -F= '/^result_/ {printf("%s := %s\n",substr($1,8),gensub(/"/,"","g",$2))}' \
  57. > Makefile.setup
  58. #--------------------------------------------------
  59. INSTALL_PATH=/usr/local
  60. if [[ -d $INSTALL_PATH/bin ]]
  61. then
  62. HAVE_INSTBIN=1
  63. INSTBIN=$INSTALL_PATH/bin
  64. else
  65. HAVE_INSTBIN=0
  66. INSTBIN=/tmp
  67. fi
  68. if [[ -d $INSTALL_PATH/bin32 ]]
  69. then
  70. HAVE_INSTBIN_32=1
  71. INSTBIN_32=$INSTALL_PATH/bin32
  72. else
  73. HAVE_INSTBIN_32=0
  74. INSTBIN_32=/tmp
  75. fi
  76. if [[ -d $INSTALL_PATH/bin64 ]]
  77. then
  78. HAVE_INSTBIN_64=1
  79. INSTBIN_64=$INSTALL_PATH/bin64
  80. elif [[ -d $INSTALL_PATH/bin-x86_64 ]]
  81. then
  82. HAVE_INSTBIN_64=1
  83. INSTBIN_64=$INSTALL_PATH/bin-x86_64
  84. else
  85. HAVE_INSTBIN_64=0
  86. INSTBIN_64=/tmp
  87. fi
  88. #--------------------------------------------------
  89. cat <<- __EOT__ >> Makefile.setup
  90. REVISION := $revision
  91. REVISION_NUM := $revision_num
  92. REVISION_NEXT := $revision_next
  93. BINTIME := ${tim[0]}
  94. DATE := ${tim[1]}
  95. TIME := ${tim[2]}
  96. GCC_VERSION := $GCC_VERSION
  97. FORCE_M32 := $force_m32
  98. HAVE_FUSE := $have_fuse
  99. HAVE_ZLIB := $have_zlib
  100. HAVE_MD5 := $have_md5
  101. HAVE_SHA := $have_sha
  102. STATIC := $STATIC
  103. XFLAGS += $xflags
  104. DEFINES1 := $defines
  105. HAVE_INSTBIN := $HAVE_INSTBIN
  106. HAVE_INSTBIN_32 := $HAVE_INSTBIN_32
  107. HAVE_INSTBIN_64 := $HAVE_INSTBIN_64
  108. INSTALL_PATH := $INSTALL_PATH
  109. INSTBIN := $INSTBIN
  110. INSTBIN_32 := $INSTBIN_32
  111. INSTBIN_64 := $INSTBIN_64
  112. __EOT__