DATE: Wed, 21 Nov 2012 17:10:11 +0000 | SIZE: 13.93 KB | SYNTAX: Bash | HITS: 362 | EXPIRES IN: NEVER


  1. #!/bin/sh
  2. # This script is POSIX compliant and comes with no warranty.
  3. # Tune it up or otherwise adjust as you see fit.
  4. # By Sasha - Jan 22 2010
  5. # My gcc used = 4.3.3
  6. #
  7. # PGO (Profile Guided Optimization) Firefox build
  8. #  for 64bit Slackware 13.0
  9. # Works for me with FF 3.6 (freshly released Jan 22/2010)
  10. # Script based on Slackware 13/64 SlackBuild and other
  11. # examples from here and there, including mozilla.org.
  12. #
  13. # This whole build is a multi-stage clobber-build
  14. # which takes the better part of 1.5 hours, including
  15. # time spent playing with the half-built browser half
  16. # way through the build to generate profiling info.
  17. #
  18. # FF 3.6 build depends on libnotify from Galago and
  19. # some junk from your Wireless Tools package (yes, wtf?!)
  20. # BEGIN:
  21. # First, see that we aren't root, because we _are_ going to
  22. # fire up the new browser half-way through the build, to generate
  23. # some profiling information. Don't wanna browse as root, and
  24. # also, root is not allowed to connect to the X server by
  25. # default, so the build will fail when the browser cannot be started.
  26.  
  27. echo "Checking UID and file ownership.."
  28. if [ $(id -u) = 0 ]; then
  29.  echo "You should not do this as root."
  30.  echo "Please change to another UID before running this script."
  31.  exit 1
  32. else
  33. # ensure everything is our UID:GID or quit
  34. # (in case any of it is root owned)
  35.  if [ "$(chown -R $(id -u):$(id -g) ./* 2>&1 >/dev/null)" ]; then
  36.   echo "Stuff in here is not chownable to our UID:GID."
  37.   echo "Please fix it and run this script again."
  38.   exit 1
  39.  fi;
  40. fi;
  41.  
  42. # my favorite compiler optimizations:
  43. #CFLAGS="-fPIC -O3 -Wall -pipe -march=native -mtune=native -fomit-frame-pointer"
  44. #I read O2 is often faster. so...
  45. CFLAGS="-fPIC -O2 -Wall -pipe -march=native -mtune=native -fomit-frame-pointer"
  46. CXXFLAGS="${CFLAGS}"
  47. CPPFLAGS="${CFLAGS} -I/usr/include"
  48. MAKEFLAGS="-j4"
  49.  
  50. # FF apparently won't build properly with autoconf != 2.13 so
  51. # in case this is still the case, I installed autoconf 2.13 in
  52. # /usr/local/bin and this PATH makes it be found first, before
  53. # my regular autoconf 2.6:
  54. PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.
  55. export PATH CPPFLAGS CXXFLAGS CFLAGS MAKEFLAGS
  56.  
  57. CWD=$(pwd)                       # where am I now (start base dir)
  58. TMP=$CWD/temp                    # a slackpkg will be constructed in here.
  59. LIBDIR=lib64                     # slack64 libdir.
  60. SRCDIR=$CWD/SOURCE               # FF source dir.
  61. OBJDIR=$CWD/OBJDIR               # build dest dir.
  62. PKGDIR=$CWD/PGO_FINISHED_PROD    # slack package or tarball ends up in here.
  63. PROFIL=$CWD/_PROFILEPROFILE      # PGO profile folder
  64.                                  #  (stick your places.sqlite in there if you want)
  65. MOZAPP=browser                   # in mozconfig, which mozilla component to build
  66. APP=firefox                      # self evident.
  67. VERSION=17.0                     # self evident.
  68. EXTENSION=en-US.linux            # FF tarball name includes this piece.
  69.                                  #  but may change depending on your locale.
  70. ARCH=x86_64                      # architecture.
  71. BUILD=1mps                       #
  72.  
  73. PYTHON=/usr/bin/python
  74.  
  75. # Download all the parts here?
  76.  
  77. # make sure we have all the necessary pieces for
  78. # creating a slackpackage, and the source archive too:
  79. for i in firefox.png mimeTypes.rdf.gz firefox.moz_plugin_path.diff.gz \
  80.          mozilla-firefox.desktop slack-desc $APP-$VERSION.source.tar.bz2; do
  81.  if [ ! -f "$CWD/$i" ]; then
  82.   echo "Error: $CWD/$i missing. Get it somewhere and try again."
  83.   exit 1
  84.  fi;
  85. done
  86.  
  87. # clean away old build dirs and make fresh ones:
  88. rm -Rf $SRCDIR $OBJDIR $TMP $PKGDIR
  89. mkdir -p $SRCDIR $OBJDIR $PROFIL $TMP $PKGDIR
  90.  
  91. # run-script.sh ##################################################
  92. # create the app startup script for profile generation:
  93. cat << EOF > run-$APP.sh
  94. #!/bin/sh
  95. NO_EM_RESTART=1
  96. DISPLAY=:0.0
  97. export NO_EM_RESTART DISPLAY
  98. $OBJDIR/dist/bin/$APP -no-remote -profile $PROFIL
  99.  
  100. EOF
  101. chmod a+x run-$APP.sh
  102. # /run-script.sh ##################################################
  103.  
  104. # extract the FF source tar.bz2 into $SRCDIR..
  105. echo "Extracting source.."
  106. cd $SRCDIR
  107. tar xvf $CWD/$APP-$VERSION.source.tar.bz2 || exit 1
  108. sync
  109. SRCDIR=$(pwd)/$(ls)
  110. cd $SRCDIR || exit 1
  111.  
  112. #/usr/local/bin/autoreconf || exit 1
  113.  
  114. # Enable x86_64 Tracemonkey Support
  115. # FIXME: deprecated? there is no ENABLE_JIT anymore...
  116. #patch $SRCDIR/js/src/configure.in < $CWD/enable-x86_64-tracemonkey.patch || exit 1
  117.  
  118. # Pat Volkerding says:
  119. # Fix a long standing bug that's prevented staying current on GTK+.
  120. # Thanks to the BLFS folks.  :-)
  121. cat << EOF >> layout/build/Makefile.in
  122.  
  123. ifdef MOZ_ENABLE_CANVAS
  124. EXTRA_DSO_LDOPTS += \$(XLDFLAGS) -lX11 -lXrender
  125. endif
  126.  
  127. EOF
  128.  
  129. # mozconfig #######################################################
  130. # and create our mozconfig in $SRCDIR:
  131. cat << EOF > mozconfig
  132.  
  133. # FF PGO-build mozconfig file
  134. # option to say use objdir (build dir):
  135. mk_add_options MOZ_OBJDIR=$OBJDIR
  136.  
  137. # startup script, for generating profile info for optimize:
  138. #mk_add_options PROFILE_GEN_SCRIPT=$CWD/run-$APP.sh
  139.  
  140. # Automated script; comment this and uncomment the above for a manual script
  141. mk_add_options PROFILE_GEN_SCRIPT='${PYTHON} ${OBJDIR}/_profile/pgo/profileserver.py'
  142.  
  143. # which mozilla app to build:
  144. ac_add_options --enable-application=$MOZAPP
  145.  
  146. ########################################: Stuff that always worked:
  147. ###################### (mostly) stuff from the -current slackbuild:
  148. ac_add_options --enable-official-branding
  149. ac_add_options --prefix=/usr --libdir=/usr/$LIBDIR
  150. ac_add_options --host="x86_64-slackware-linux-gnu"
  151. ac_add_options --with-default-mozilla-five-home=/usr/$LIBDIR/$APP-$VERSION
  152. ac_add_options --with-system-zlib
  153. ac_add_options --enable-default-toolkit=cairo-gtk2
  154. ac_add_options --enable-crypto
  155. ac_add_options --enable-svg
  156. ac_add_options --enable-canvas
  157. ac_add_options --enable-xft
  158. ac_add_options --enable-webm
  159. ac_add_options --enable-xinerama
  160. ac_add_options --enable-optimize="-fPIC -O2 -Wall -pipe -march=native -mtune=native -fomit-frame-pointer" #not needed? cflags etc? was Os...?hmm
  161. ac_add_options --enable-reorder
  162. ac_add_options --enable-strip
  163. #ac_add_options --enable-system-cairo          #breaks build (https://bugzilla.mozilla.org/show_bug.cgi?id=722975)
  164. ac_add_options --enable-cpp-rtti
  165. ac_add_options --enable-single-profile
  166. ac_add_options --disable-ldap
  167. ac_add_options --disable-accessibility
  168. ac_add_options --disable-debug
  169. ac_add_options --disable-tests
  170. ac_add_options --disable-logging
  171. ac_add_options --disable-pedantic
  172. ac_add_options --disable-installer
  173. ac_add_options --disable-mailnews
  174. ac_add_options --disable-composer
  175. ac_add_options --disable-profilesharing
  176. # End official slackbuild opts
  177. ########################################: stuff I'm 98% sure always works:
  178. ac_add_options --with-gxx-include-dir=/usr/include/c++/4.7.1
  179. ac_add_options --quiet
  180. ac_add_options --with-system-bz2
  181. ac_add_options --with-pthreads
  182. ac_add_options --enable-threads=posix
  183. ac_add_options --enable-system-lcms
  184. ac_add_options --disable-system-sqlite          #enable breaks build in packaging state...
  185. ac_add_options --enable-pango
  186. ac_add_options --enable-install-strip
  187. ac_add_options --disable-updater
  188. ac_add_options --disable-gnomeui
  189. ac_add_options --disable-gnomevfs
  190. ########################################: stuff I'm 95% sure works fine:
  191. #ac_add_options --enable-libxul
  192. #ac_add_options --with-system-jpeg              
  193. #ac_add_options --with-system-nssac_add_options
  194. ac_add_options --disable-crashreporter
  195. ac_add_options --disable-help-viewer
  196. ac_add_options --disable-debug-modules
  197. ac_add_options --disable-debugger-info-modules
  198. ac_add_options --disable-parental-controls
  199. ac_add_options --disable-safe-browsing
  200. ac_add_options --disable-startup-notification
  201. ########################################: Completely Experimental below..
  202. ########################################: Questionable/Optional stuff
  203. ########################################: that may, or just may not work:
  204. #ac_add_options --enable-javaxpcom
  205. #ac_add_options --enable-oji
  206. #ac_add_options --enable-xpcom-fastload
  207. #ac_add_options --enable-plugins
  208. #ac_add_options --enable-jemalloc
  209. #ac_add_options --enable-mathml
  210. #ac_add_options --disable-xpcom-obsolete
  211. #ac_add_options --enable-svg-foreignobject
  212. # ac_add_options --enable-chrome-format=jar
  213. # ac_add_options --enable-native-uconv # not needed/not recommended
  214. # ac_add_options --enable-image-encoders=all # should not need
  215. # ac_add_options --enable-update-channel=release # needed by moz.org people only?
  216. # ac_add_options --enable-prebinding # OSX only?
  217. # ac_add_options --enable-reflow-perf # try without.. may slow down FF for non-devel user?
  218. ac_add_options --enable-glitz # this thing won't install into lib64
  219. # END of mozconfig file
  220.  
  221. EOF
  222. # /mozconfig #######################################################
  223.  
  224. # configure the sources:
  225. cd $OBJDIR
  226. echo ; echo "Info: Running configure in 5" ; sleep 5
  227. $SRCDIR/configure || exit 1
  228.  
  229. # make the sources:
  230. cd $SRCDIR
  231. #disabled because would not produce a real pgo build!
  232. #see bottom: https://groups.google.com/forum/?fromgroups=#!topic/mozilla.dev.builds/VeR2zDtQ0qM
  233. #echo ; echo "Info: Starting non-PGO build in 5" ; sleep 5
  234. #make -s -f client.mk build MOZ_MAKE_FLAGS="${MAKEFLAGS}" || exit 1
  235.  
  236. # make PGO build in same objdir, on top of what's already built:
  237. #echo ; echo "Info: Done non-PGO build... Continuing in 5" ; sleep 5
  238. make -s -f client.mk profiledbuild MOZ_MAKE_FLAGS="${MAKEFLAGS}" || exit 1
  239.  
  240. # Here is when the profiling build should fire up. Use it for a while,
  241. # do some browsing, give it a hard time; sometimes a bad build will
  242. # run for 5, 10 or 15 minutes until it hits a snag, bug, segfault
  243. # or whatever, so you want to make it happen NOW, not when you've
  244. # got 25 tabs open tomorrow and the whole thing locks up on you.
  245. # When you're done, and confident that the browser is stable,
  246. # click File->Quit and the build will resume.
  247.  
  248. # OPTIONS HERE (functions):
  249.  
  250. make_tarball () {
  251. # make tarball: This makes a generic tarball of the newly
  252. # compiled Firefox and related components, and zips it up
  253. # into a bzip2 archive. You can then do what you like with
  254. # it, such as install it manually, or just unpack it somewhere
  255. # and use it as-is.
  256. # Package it into a tarball to fix symlinks & gather all pieces:
  257. ( cd $OBJDIR
  258.   echo ; echo "Info: Packaging tarball in 5" ; sleep 5
  259.   make package ) || exit 1
  260. #move tarball to $CWD (start directory)
  261. ( cd $PKGDIR
  262.   cp -fvt . $OBJDIR/dist/$APP-$VERSION.$EXTENSION-$ARCH.tar.bz2
  263. ) || exit 1
  264.  
  265. cd $CWD
  266. # Now do what you want with the finished tarball in $PKGDIR.
  267. }
  268.  
  269. # 2) make slackpkg:
  270. make_slackpkg () {
  271. # make a slackware package according to the general idea
  272. # of what happens in the Slack13.0/64 SlackBuild script:
  273. ( cd $OBJDIR
  274.   echo ; echo "Info: Creating slackpkg dir structure in 5" ; sleep 5
  275.   make install DESTDIR=$TMP
  276.   # We don't need these things:
  277.   rm -Rf $TMP/usr/$LIBDIR/$APP-devel-$VERSION
  278.   rm -Rf $TMP/usr/include
  279. )
  280.  
  281. #useless
  282. #fails mimeTypes, plugin_path useless since 7.x
  283. #( cd $TMP/usr/$LIBDIR/$APP-$VERSION
  284. #  zcat $CWD/mimeTypes.rdf > defaults/profile/mimeTypes.rdf || exit 1
  285. #  zcat $CWD/firefox.moz_plugin_path.diff.gz \
  286. #    | sed -e "s#usr/lib#usr/$LIBDIR#g" \
  287. #    | patch -p1 --verbose --backup --suffix=.orig || exit 1
  288. #  # Clean up if the above patch was successful:
  289. #  # On my system, that patch is successful, but a bit fuzzy :/
  290. #  rm -f firefox.orig
  291. #) || exit 1
  292.  
  293. mkdir -p $TMP/usr/$LIBDIR/mozilla/plugins
  294. mkdir -p $TMP/usr/share/applications
  295. cat $CWD/mozilla-$APP.desktop > $TMP/usr/share/applications/mozilla-$APP.desktop
  296. mkdir -p $TMP/usr/share/pixmaps
  297. cat $CWD/$APP.png > $TMP/usr/share/pixmaps/$APP.png
  298.  
  299. # These files/directories are usually created if Firefox is run
  300. # as root which technically should be never. Anyhow, if we don't
  301. # see these items, put stubbies in place (whatever those are) to
  302. # prevent startup errors:
  303. ( cd $TMP/usr/$LIBDIR/$APP-$VERSION
  304.   if [ -d extensions/talkback\@mozilla.org ]; then
  305.     if [ ! -r extensions/talkback\@mozilla.org/chrome.manifest ]; then
  306.       echo > extensions/talkback\@mozilla.org/chrome.manifest
  307.     fi
  308.   fi
  309.   if [ ! -d updates ]; then
  310.     mkdir -p updates/0
  311.   fi
  312. )
  313.  
  314. # Install icons/imgs/license/slack-desc:
  315. mkdir -p $TMP/usr/$LIBDIR/$APP-$VERSION/chrome/icons/default
  316. install -m 644 $SRCDIR/browser/branding/official/default16.png $TMP/usr/$LIBDIR/$APP-$VERSION/icons/
  317. install -m 644 $SRCDIR/browser/branding/official/default16.png $TMP/usr/$LIBDIR/$APP-$VERSION/chrome/icons/default/
  318. install -p -c -m 644 $SRCDIR/LICENSE $TMP/usr/$LIBDIR/$APP-$VERSION/
  319. mkdir $TMP/install
  320. cat $CWD/slack-desc > $TMP/install/slack-desc
  321.  
  322. if [ -e $TMP/usr/share/idl/$APP-$VERSION/.mkdir.done ]; then
  323.         rm -f $TMP/usr/share/idl/$APP-$VERSION/.mkdir.done
  324. fi
  325.  
  326. cd $TMP
  327. # whip up the Slackpackage:
  328. echo "Ready to zip up the slackpkg."
  329. echo "1) su to root."
  330. echo "2) Make sure you are in this folder: $TMP"
  331. echo "3) Now, as root, type:"
  332. echo "chown -R root:root ."
  333. echo "makepkg -l y -c y $PKGDIR/mozilla-$APP-$VERSION-$ARCH-$BUILD.txz"
  334. } # end of make_slackpkg()
  335.  
  336. #NOTE: Below here, uncomment whichever function-call you
  337. # plan to use: either "make_slackpkg" or "make_tarball"
  338. # You can probably do both if you have some reason to do so..
  339.  
  340. #make_tarball
  341. make_slackpkg
  342.  
  343. #EOF