PageRenderTime 62ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/testdisk-6.13/compile.sh

#
Shell | 322 lines | 285 code | 20 blank | 17 comment | 54 complexity | 815d8fced9cf03f3bbae6d688059bbd5 MD5 | raw file
Possible License(s): GPL-2.0
  1. #!/bin/sh
  2. # default, host is empty, no cross compilation
  3. # ./compile.sh [ i586-pc-msdosdjgpp | i386-pc-cygwin | i386-pc-mingw32 | powerpc-mac-darwin ]
  4. # Comment the version definition to not compile the library
  5. VER_E2FSPROGS=
  6. VER_PROGSREISERFS="0.3.1-rc8"
  7. VER_LIBEWF=20100226
  8. #VER_LIBEWF=20110312
  9. smp_mflags="-j 2"
  10. crosscompile_target=
  11. prefix=/usr/
  12. if [ "$CC" = "gcc295" ];
  13. then
  14. VER_NTFSPROGS=
  15. VER_LIBNTFS3G=
  16. fi
  17. if [ -z "$1" ];
  18. then
  19. compiledir=.
  20. else
  21. compiledir=$1
  22. if [ "$1" != "$CC" ];
  23. then
  24. VER_E2FSPROGS=1.41.8
  25. crosscompile_target=$1
  26. TESTDISKCC=$crosscompile_target-gcc
  27. fi
  28. fi
  29. case "$crosscompile_target" in
  30. *-msdosdjgpp|*-cygwin|*-mingw32)
  31. VER_LIBNTFS3G=
  32. VER_NTFSPROGS="2.0.0"
  33. ;;
  34. *)
  35. VER_LIBNTFS3G="2011.3.28-RC"
  36. VER_NTFSPROGS=
  37. ;;
  38. esac
  39. prefix=/usr/$crosscompile_target
  40. LYNX=links
  41. WGET="wget -N"
  42. LIBEXT=$compiledir/e2fsprogs-$VER_E2FSPROGS/lib/ext2fs/libext2fs.a
  43. LIBNTFS=$compiledir/ntfsprogs-$VER_NTFSPROGS/libntfs/.libs/libntfs.a
  44. LIBNTFS3G=$compiledir/ntfs-3g_ntfsprogs-$VER_LIBNTFS3G/libntfs-3g/.libs/libntfs-3g.a
  45. LIBREISER=$compiledir/progsreiserfs-$VER_PROGSREISERFS/libreiserfs/.libs/libreiserfs.a
  46. LIBEWF=$compiledir/ewf-$VER_LIBEWF/libewf/.libs/libewf.a
  47. pwd_saved=`pwd`
  48. confdir=`(dirname "$0") 2>/dev/null`
  49. cd $confdir
  50. confdir=`pwd`
  51. cd $pwd_saved
  52. PWDSRC=`pwd|sed 's#^\w:/#/#'`/$compiledir
  53. CONFIGUREOPT=
  54. mkdir -p $compiledir
  55. echo "This script will try to compile e2fsprogs progsreiserfs ntfsprogs libraries"
  56. if [ "$VER_E2FSPROGS" != "" ];
  57. then
  58. CONFIGUREOPT="$CONFIGUREOPT --with-ext2fs-lib=${PWDSRC}/e2fsprogs-${VER_E2FSPROGS}/lib --with-ext2fs-includes=${PWDSRC}/e2fsprogs-${VER_E2FSPROGS}/lib"
  59. if [ ! -e $compiledir/e2fsprogs-$VER_E2FSPROGS/configure ];
  60. then
  61. if [ ! -e e2fsprogs-$VER_E2FSPROGS.tar.gz ];
  62. then
  63. $LYNX http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-$VER_E2FSPROGS.tar.gz
  64. fi
  65. if [ -e e2fsprogs-$VER_E2FSPROGS.tar.gz ];
  66. then
  67. tar xzf e2fsprogs-$VER_E2FSPROGS.tar.gz -C $compiledir
  68. fi
  69. fi
  70. if [ ! -e $compiledir/e2fsprogs-$VER_E2FSPROGS/Makefile ];
  71. then
  72. if [ -e $compiledir/e2fsprogs-$VER_E2FSPROGS/configure ];
  73. then
  74. rm -f $compiledir/Makefile
  75. cd $compiledir/e2fsprogs-$VER_E2FSPROGS
  76. case "$crosscompile_target" in
  77. arm-marvell-linux-gnu)
  78. CC=$TESTDISKCC CFLAGS="$CFLAGS -g -O2 -DOMIT_COM_ERR" ./configure --host=$crosscompile_target --prefix=$prefix --disable-tls
  79. ;;
  80. *)
  81. CC=$TESTDISKCC CFLAGS="$CFLAGS -g -O2 -DOMIT_COM_ERR" ./configure --host=$crosscompile_target --prefix=$prefix
  82. ;;
  83. esac
  84. cd $pwd_saved
  85. fi
  86. fi
  87. if [ ! -e $LIBEXT ];
  88. then
  89. if [ -e $compiledir/e2fsprogs-$VER_E2FSPROGS/Makefile ];
  90. then
  91. cd $compiledir/e2fsprogs-$VER_E2FSPROGS
  92. make $smp_mflags libs
  93. cd $pwd_saved
  94. fi
  95. fi
  96. fi
  97. if [ "$VER_PROGSREISERFS" != "" ];
  98. then
  99. CONFIGUREOPT="$CONFIGUREOPT --with-reiserfs-lib=${PWDSRC}/progsreiserfs-${VER_PROGSREISERFS}/libreiserfs/.libs/ --with-reiserfs-includes=${PWDSRC}/progsreiserfs-${VER_PROGSREISERFS}/include/ --with-dal-lib=${PWDSRC}/progsreiserfs-${VER_PROGSREISERFS}/libdal/.libs/"
  100. if [ ! -e $compiledir/progsreiserfs-$VER_PROGSREISERFS/configure ];
  101. then
  102. if [ ! -e progsreiserfs-$VER_PROGSREISERFS.tar.gz ];
  103. then
  104. $LYNX http://reiserfs.osdn.org.ua/snapshots/progsreiserfs-$VER_PROGSREISERFS.tar.gz
  105. fi
  106. if [ -e progsreiserfs-$VER_PROGSREISERFS.tar.gz ];
  107. then
  108. tar xzf progsreiserfs-$VER_PROGSREISERFS.tar.gz -C $compiledir
  109. cd $compiledir/progsreiserfs-$VER_PROGSREISERFS
  110. patch -p1 < $pwd_saved/progsreiserfs-journal.patch
  111. patch -p1 < $pwd_saved/progsreiserfs-file-read.patch
  112. cd $pwd_saved
  113. fi
  114. fi
  115. if [ ! -e $compiledir/progsreiserfs-$VER_PROGSREISERFS/Makefile ];
  116. then
  117. if [ -e $compiledir/progsreiserfs-$VER_PROGSREISERFS/configure ];
  118. then
  119. # rm -f $compiledir/Makefile
  120. cd $compiledir/progsreiserfs-$VER_PROGSREISERFS
  121. ./configure --host=$crosscompile_target --prefix=$prefix --disable-nls --disable-Werror
  122. cd $pwd_saved
  123. fi
  124. fi
  125. #vim /home/kmaster/src/testdisk/powerpc-apple-darwin/progsreiserfs-0.3.1-rc8/libtool
  126. #%s/AR="ar"/AR="powerpc-apple-darwin-ar"/
  127. if [ ! -e $LIBREISER ];
  128. then
  129. if [ -e $compiledir/progsreiserfs-$VER_PROGSREISERFS/Makefile ];
  130. then
  131. cd $compiledir/progsreiserfs-$VER_PROGSREISERFS
  132. make $smp_mflags
  133. cd $pwd_saved
  134. fi
  135. fi
  136. fi
  137. if [ "$VER_LIBNTFS3G" != "" ];
  138. then
  139. CONFIGUREOPT="$CONFIGUREOPT --with-ntfs3g-lib=${PWDSRC}/ntfs-3g_ntfsprogs-${VER_LIBNTFS3G}/libntfs-3g/.libs/ --with-ntfs3g-includes=${PWDSRC}/ntfs-3g_ntfsprogs-${VER_LIBNTFS3G}/include/"
  140. if [ ! -e $compiledir/ntfsprogs-$VER_LIBNTFS3G/configure ];
  141. then
  142. if [ ! -e ntfs-3g_ntfsprogs-$VER_LIBNTFS3G.tgz ];
  143. then
  144. $WGET http://tuxera.com/opensource/ntfs-3g_ntfsprogs-$VER_LIBNTFS3G.tgz
  145. fi
  146. if [ -e ntfs-3g_ntfsprogs-$VER_LIBNTFS3G.tgz ];
  147. then
  148. tar xzf ntfs-3g_ntfsprogs-$VER_LIBNTFS3G.tgz -C $compiledir
  149. fi
  150. fi
  151. if [ ! -e $compiledir/ntfs-3g_ntfsprogs-$VER_LIBNTFS3G/Makefile ];
  152. then
  153. if [ -e $compiledir/ntfs-3g_ntfsprogs-$VER_LIBNTFS3G/configure ];
  154. then
  155. # rm -f $compiledir/Makefile
  156. cd $compiledir/ntfs-3g_ntfsprogs-$VER_LIBNTFS3G
  157. case "$crosscompile_target" in
  158. powerpc-apple-darwin|i686-apple-darwin9)
  159. CC=$TESTDISKCC ./configure --host=$crosscompile_target --prefix=$prefix --disable-default-device-io-ops --disable-crypto --disable-nfconv
  160. ;;
  161. *)
  162. CC=$TESTDISKCC ./configure --host=$crosscompile_target --prefix=$prefix --disable-default-device-io-ops --disable-crypto
  163. ;;
  164. esac
  165. # --disable-default-device-io-ops is need for NT 4
  166. cd $pwd_saved
  167. fi
  168. fi
  169. if [ ! -e $VER_LIBNTFS3G ];
  170. then
  171. if [ -e $compiledir/ntfs-3g_ntfsprogs-$VER_LIBNTFS3G/Makefile ];
  172. then
  173. cd $compiledir/ntfs-3g_ntfsprogs-$VER_LIBNTFS3G
  174. # make $smp_mflags libs
  175. make $smp_mflags
  176. cd $pwd_saved
  177. fi
  178. fi
  179. fi
  180. if [ "$VER_NTFSPROGS" != "" ];
  181. then
  182. CONFIGUREOPT="$CONFIGUREOPT --with-ntfs-lib=${PWDSRC}/ntfsprogs-${VER_NTFSPROGS}/libntfs/.libs/ --with-ntfs-includes=${PWDSRC}/ntfsprogs-${VER_NTFSPROGS}/include/"
  183. if [ ! -e $compiledir/ntfsprogs-$VER_NTFSPROGS/configure ];
  184. then
  185. if [ ! -e ntfsprogs-$VER_NTFSPROGS.tar.gz ];
  186. then
  187. $LYNX http://prdownloads.sourceforge.net/linux-ntfs/ntfsprogs-$VER_NTFSPROGS.tar.gz
  188. fi
  189. if [ -e ntfsprogs-$VER_NTFSPROGS.tar.gz ];
  190. then
  191. tar xzf ntfsprogs-$VER_NTFSPROGS.tar.gz -C $compiledir
  192. fi
  193. fi
  194. if [ ! -e $compiledir/ntfsprogs-$VER_NTFSPROGS/Makefile ];
  195. then
  196. if [ -e $compiledir/ntfsprogs-$VER_NTFSPROGS/configure ];
  197. then
  198. # rm -f $compiledir/Makefile
  199. cd $compiledir/ntfsprogs-$VER_NTFSPROGS
  200. # --disable-default-device-io-ops is need for NT 4
  201. ./configure --host=$crosscompile_target --prefix=$prefix --disable-default-device-io-ops --disable-crypto
  202. cd $pwd_saved
  203. fi
  204. fi
  205. if [ ! -e $LIBNTFS ];
  206. then
  207. if [ -e $compiledir/ntfsprogs-$VER_NTFSPROGS/Makefile ];
  208. then
  209. cd $compiledir/ntfsprogs-$VER_NTFSPROGS
  210. make $smp_mflags libs
  211. cd $pwd_saved
  212. fi
  213. fi
  214. fi
  215. if [ "$VER_LIBEWF" != "" ];
  216. then
  217. CONFIGUREOPT="$CONFIGUREOPT --with-ewf-lib=${PWDSRC}/libewf-${VER_LIBEWF}/libewf/.libs/ --with-ewf-includes=${PWDSRC}/libewf-${VER_LIBEWF}/include/"
  218. if [ ! -e $compiledir/libewf-$VER_LIBEWF/configure ];
  219. then
  220. if [ ! -e libewf-$VER_LIBEWF.tar.gz -a ! -e libewf-alpha-$VER_LIBEWF.tar.gz -a ! -e libewf-beta-$VER_LIBEWF.tar.gz ];
  221. then
  222. $LYNX "http://sourceforge.net/project/platformdownload.php?group_id=167783"
  223. fi
  224. if [ -e libewf-$VER_LIBEWF.tar.gz ];
  225. then
  226. tar xzf libewf-$VER_LIBEWF.tar.gz -C $compiledir
  227. fi
  228. if [ -e libewf-alpha-$VER_LIBEWF.tar.gz ];
  229. then
  230. tar xzf libewf-alpha-$VER_LIBEWF.tar.gz -C $compiledir
  231. fi
  232. if [ -e libewf-beta-$VER_LIBEWF.tar.gz ];
  233. then
  234. tar xzf libewf-beta-$VER_LIBEWF.tar.gz -C $compiledir
  235. fi
  236. fi
  237. if [ ! -e $compiledir/libewf-$VER_LIBEWF/Makefile ];
  238. then
  239. if [ -e $compiledir/libewf-$VER_LIBEWF/configure ];
  240. then
  241. # rm -f $compiledir/Makefile
  242. cd $compiledir/libewf-$VER_LIBEWF
  243. CC=$TESTDISKCC ./configure --host=$crosscompile_target --prefix=$prefix
  244. cd $pwd_saved
  245. fi
  246. fi
  247. if [ ! -e $LIBEWF ];
  248. then
  249. if [ -e $compiledir/libewf-$VER_LIBEWF/Makefile ];
  250. then
  251. cd $compiledir/libewf-$VER_LIBEWF
  252. make $smp_mflags lib
  253. cd $pwd_saved
  254. fi
  255. fi
  256. fi
  257. echo "Try to compile TestDisk"
  258. CC=$TESTDISKCC
  259. export CC
  260. if [ -d $compiledir ];
  261. then
  262. if [ ! -e $compiledir/Makefile ];
  263. then
  264. cd $compiledir
  265. case "$crosscompile_target" in
  266. powerpc-apple-darwin)
  267. # libewf should work under MacOSX but it hasn't been tested
  268. # use --with-ncurses-lib=$prefix/usr/lib to get binaries that don't need libncurses
  269. # but users may be unable to navigate...
  270. $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --without-ewf --enable-sudo --with-sudo-bin=/usr/bin/sudo
  271. ;;
  272. i686-apple-darwin9)
  273. $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --enable-sudo --with-sudo-bin=/usr/bin/sudo
  274. ;;
  275. i586-pc-msdosdjgpp)
  276. $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --without-ewf --without-iconv
  277. ;;
  278. i386-pc-cygwin)
  279. $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT
  280. ;;
  281. i386-mingw32)
  282. $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --without-iconv --enable-missing-uuid-ok
  283. ;;
  284. i686-pc-mingw32|x86_64-pc-mingw32|x86_64-w64-mingw32)
  285. $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --enable-missing-uuid-ok
  286. ;;
  287. arm-marvell-linux-gnu)
  288. $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --without-ewf --without-ntfs
  289. ;;
  290. *)
  291. $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT
  292. ;;
  293. esac
  294. cd $pwd_saved
  295. fi
  296. if [ -e $compiledir/Makefile ];
  297. then
  298. cd $compiledir
  299. make $smp_mflags
  300. cd $pwd_saved
  301. fi
  302. fi