BUILDING binutils-2.17 and other packages for DJGPP for use with FreeBASIC
==========================================================================
Jeff Marshall (a.k.a. coderJeff)
Created     : Jan 1, 2007
Last updated: Mar 10, 2007 - added info about autoconf

This method worked for me.  It might not work for you.  My goal was to 
update my djgpp installation with binutils-2.17 and then use it for 
building FreeBASIC.  A newer version of BFD is required for FreeBASIC.


INSTALL A BASE DJGPP ENVIRONMENT
--------------------------------
Download and unpack the following to the same dir: (e.g. H:\DJ)

djdev203.zip  acnf257b.zip  amak176b.zip  bnu2161b.zip  bsh204b.zip 
bsn23b.zip    bz2-102b.zip  dif281b.zip   ed-02b.zip    edi054b.zip
em2005b.zip   faq230b.zip   fil41b.zip    find41b.zip   flx254b.zip
gcc344b.zip   gdb611b.zip   gpp344b.zip   gprf301b.zip  grep24b.zip
gtxt040b.zip  gwk315b.zip   gzip135b.zip  licv192b.zip  m4-144b.zip
mak3791b.zip  perl561b.zip  objc344b.zip  sed415b.zip   shl2011b.zip
tar112ab.zip  txi48b.zip    txt20b.zip  

Notes:
- gcc 3.4.4 is needed because gcc 4.1 is too strict to build djdev204.
- Remember to preserve directory structure
- Remember to set the environment variables DJDIR, DJGPP, and PATH to 
  point to the right places.  See the djgpp readmes for more information.
- you may need other packages depending on what else you do with djgpp
- a couple of these packages might not be needed (but I'm not going back 
  to figure it out, sorry)
- Remember to put zip.exe in H:\dj\bin

Also needed is zip.exe from http://www.info-zip.org/ to build the 
djdev204 distibs.  (In my opinion the easiest way to install djdev204)

At this point we will have djdev 2.03, gcc 3.4.4, and binutils 2.16.1


BUILDING DJGPP 2.04
-------------------
See the instructions on DJGPP website for obtaining djdev204 sources from CVS 
Assuming we have H:\DJ for the installation and F:\DJGPP for the CVS sources:
(and f:\freebasic for CVS FreeBASIC)

Patch in FreeBASIC constructor modifications:
- copy f:\FreeBASIC\src\contrib\djgpp\crt0\_main.c F:\djgpp\src\libc\crt0\_main.c
- copy f:\FreeBASIC\src\contrib\djgpp\crt0\djgpp-x.djl h:\dj\lib\gcc\djgpp\3.44\djgpp-x.djl

Build the sources
- cd F:\djgpp\src
- make

Make a djdev204 distro
- cd F:\djgpp\distrib
- mkdist.bat
- Unzip F:\djgpp\zips\djdev204.zip to H:\dj

At this point we will have djgpp 2.04, gcc 3.4.4, and binutils 2.16.1


BUILDING BINUTILS-2.17
----------------------
***WARNING, this completely ignores the DJGPP specific mods needed
e.g. updating the default linker scripts.  (Very, very bad)
(TODO: update info with DJGPP specific mods)

Obtain binutils-2.17 from http://ftp.gnu.org/gnu/binutils/
and Unpack to H:\dj\gnu\ preserving directory structure

- cd H:\dj\gnu\binutils-2.17
- sh 
- ./configure --target i386-pc-msdosdjgpp --disable-nls
- cd bfd
- ./configure --target i386-pc-msdosdjgpp --disable-nls
- edit makefile
- search for and remove -Werror from WARN_CFLAGS
- save makefile
- cd ..
- make
- make install

At this point we will have djgpp 2.04, gcc 3.4.4, and binutils 2.17

Also, at this point things will probably work as-is, but if you are 
paranoid like me, go back and rebuild DJGPP 2.04 and binutils-2.17 
again using binutils 2.17 to ensure all object code was built using 
binutils-2.17.

The installed DJGPP environment can build FreeBASIC from sources, 
except for regenerating the configuration using autoconf tools.  
DJGPP last release is 2.57 and we need 2.59.


BUILDING GDB-6.5
----------------
***WARNING, this completely ignores most DJGPP specific mods needed
(TODO: update info with DJGPP specific mods)

Obtain gdb-6.5 from http://ftp.gnu.org/gnu/gdb/
and Unpack to H:\dj\gnu\ preserving directory structure

- cd H:\dj\gnu\gdb-6.5\
- sh 
- ./configure --target i386-pc-msdosdjgpp --disable-nls
- cd bfd
- ./configure --target i386-pc-msdosdjgpp --disable-nls
- edit makefile
- search for and remove -Werror from WARN_CFLAGS
- save makefile
- cd ..
- cd readline
- edit signals.c
- patch line signals.c:line 254:
  act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
- with this:
#if defined (SIGWINCH)
  act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
#else
  act.sa_flags = 0;
#endif
- save signals.c
- cd ..
- make
- make install

At this point we will have djgpp-2.04, gcc-3.4.4, binutils-2.17, gdb-6.5.  
The BFD with gdb-6.5 slightly newer than binutils-2.17 but seems like a good 
match.  gdb-6.5 seems like the best candidate for compatibility with 
binutils-2.17.


HOW TO BUILD AUTOCONF 2.59
-------------------------------------
***autoconf-2.59 is actually available from djgpp ftp in the beta directory.
(This step probably not necessary)

- Assuming that autoconf-2.57 is installed, need to updated to 2.58 first, 
  then 2.59.

- Get Autoconf 2.58 from http://ftp.gnu.org/gnu/autoconf
- Unpack
- sh ./configure
- make
- make install

- Get Autoconf 2.59 from http://ftp.gnu.org/gnu/autoconf
- Unpack
- sh ./configure
- make
- make install


HOW TO BUILD FREEBASIC 0.17 FROM CVS
------------------------------------
- using binutils 2.17
- See: http://www.freebasic.net/wiki/wikka.php?wakka=CVSDOSWin32
  for general instructions
- will probably need to update this or the wiki when this is all figured out.


HOW TO BUILD RHIDE
-------------------------------------
Get djgpp packages:
- gtxt040b.zip

- Get tvision from CVS sources
- ./configure --no-intl
- make
- make install

- get setedit from CVS sources
- ./configure --no-intl
- make
- make install

- many more steps, need to go back and figure out what I had to do here.  
  Many, many changes are required to get it to build plus many many more 
  due to changes in GDB to get it to work even half right.  Later.

EOF