
Bootstrapping OpenJDK on DragonFly/i386

Special thanks to the openjdk / bsd-jdk / pkgsrc team and 
Francois Tigeot for the hard work / advise on getting this working.

Basically, the history is as follows:

DISCLAIMER: I wasn't there
DISCLAIMER: I am not a lawyer - 
  my legal take is gathered from various postings around the 'Net 

  - there was java, and it was popular but proprietary
  - so, there was open source java clones (jikes), and clamoring
    to open source java.
  - java was opensourced (~1.5), but was still somewhat encombered
    - source couldn't be redistributed
    - resulting binararies couldn't be redistributed
  - this continued through until openjdk 1.7

  Java requires Java to bootstrap. DragonFlyBSD does not have a supported
  'official' JDK, so this means it needs to be bootstrapped.

  However, the only jdk with enough runtime support to bootstrap, is
  jikes, which is a 1.4 JDK, who's JIT, etc. still needs some stability
  work on dragonfly, or possibly has suffered some bitrot w/r/t later
  gcc's, or both, etc. not sure.

  These steps should also apply to any pkgsrc hosted platform without
  a self-hosting openjdk7 build which is capable of building a running
  jikes, or anyone trying to manually bootstrap the jdk on a new platform.

  Failing this, I did hear some horror stories about rpc wrapper scripts
  being used to invoke the java-dependant portions of the build along
  with native tools on the host architecture for platform-dependant ones.

  Thankfully, this route worked.

  So, without further adieu, steps are:

  1) build jikes without optimization to yield a workable 1.4 jdk

  2) build wip/jdk1.5 (will fallback to jikes)
    - sources require manual fetching
    - resulting binaries cant be distributed

  3) build wip/jdk1.6 (will use the 1.5 jdk)
    - same notes / restrictions apply
    - this required a modification to the makefiles to patch for 
      stricter linker flags on libmawt - the fix was pulled from  
      the openjdk7 build.
    - build using 'bmake install package' - as we will need the 
      build workspace for future steps

  4) Create a tar of the j2sdk-image directory inside the 1.6 build
     workspace::
  
     cd j2sdk-image/..;
     ln -s j2sdk-image bootstrap;
     tar jcvf /path/to/tarball bootstrap/*;

  5) Perform an initial openjdk7 build using the bootstrap created
     in step #4

     - hack boostrap.mk to point to the new file
     - copy in file into distfiles
     - bmake distinfo
     - bmake install package # again, we will be reusing workspace

     This will yield an openjdk7 package that can be distributed,
     but still leaves us without a redistributable boostrap.

     Also note - some fixes were needed for the pkgsrc makefiles:

       - reorganizing so bootstrap.mk variables were defined before
         being referenced
       - EM_ALPHA in sys/elf_common.h needed to be defined - 
         this appears to be a regression since 2.10, but was
         fixed 2011-12-12ish - if it's not present, it should be
         a safe hack to add it to your system makefiles

   6) Create a 'production bootstrap' for the openjdk7 build

      - extract one one of the existing bootstraps for netbsd
      - create an archive containing the same files from your 
        workspace (requires the ln -s j2sdk-image ... from step #4)

       - note: the bootstrap file needs to be named *20110811*
         in this version of the makefiles in order to pull in the
         'common' archive which contains the non-platform-specific
         bootstrap jre/jdk support files.

       - also note: if you are trying to do create a 'clean room' 
         bootstrap, the common archive should also be cloned. 
         this was not done in this case as the goal was to bootstrap
         'into' the existing build, rather than reimplement it.

      - copy the resulting archive into your distfiles
      - bmake distinfo
      - mv workdir workdir.bak # just in case 

   7) Rebuild openjdk7 to ensure the bootstrap functions properly

      - pkg_delete openjdk7 
      - bmake install package

   8) SUCESS!!!

      - the stage #6 bootstrap and stage #7 build are fully openjdk7
        compliant archives and should be able to be integrated into
        the pkgsrc tree.

pkgsrc subtree used for this build also provided as part of this archive.

unfortunately, you'll need to manually fetch, click through the 
various licenses, etc. to fetch the sources as you 'bmake fetch' if you 
are doing this yourself - Hopefully they are still there!
 
