/* SETMOZENV.CMD - A utility for setting up the build environment for Warpzilla */
/* V 1.1  - mkaply   - proper support for GLIB and LIBIDL */
/* V 1.2  - mkaply   - use EMX2, not emx_string */
/* V 1.3  - mkaply   - Support for a better PERL */
/* V 1.4  - mkaply   - Support for an even better PERL */
/* V 1.5  - mkaply   - Support for changing FLOCK and perl shell */
/* V 1.6  - mkaply   - Make VACPP the default */
/* V 1.7  - mkaply   - GCC 3.2.1 support */
/* V 1.8  - pedemont - GCC 3.2.2 Beta 1 support */
/* V 1.9  - pedemont - remove VACPP support */
/* V 1.10 - pedemont - replace bash.exe with ash.exe */
/* V 1.11 - pedemont - add INCLUDE env variable */
/* V 1.12 - mozilla@weilbacher.org - add cairo support package mzfntcfgft */
/* V 1.13 - mozilla@weilbacher.org - change for use with GCC 3.3.5 */
/* V 1.14 - mozilla@weilbacher.org - revise glib/libIDL handling to go with new package */
/* V 1.15 - wuno@lsvw - add Python */
/* V 1.16 - wuno@lsvw - correct Python setup */
/* V 1.17 - paul@smedley.id.au - change for use with GCC 4.4.2 */

/* be quiet */
'@ECHO OFF'

/* If SETMOZENV has alread been run, don't run it again */
if value('MOZENV',,'OS2ENVIRONMENT') = '1' THEN
DO
   exit
END
'set MOZENV=1'
'set LANG=en_US'
'set PYTHONHOME=u:/python26'
'SET PYTHONPATH=u:/python26/Lib;u:/python26/Lib/plat-os2emx;u:/python26/Lib/lib-dynload;u:/python26/Lib/site-packages'
'rem SET PYTHONHOME=u:/python25'
'rem SET PYTHONPATH=u:/python25/Lib;u:/python25/Lib/plat-os2knix;u:/python25/Lib/lib-dynload;u:/python25/Lib/site-packages'

/* Figure out what drive the utility was run on and set it as ROOT */
PARSE SOURCE command
PARSE VAR command word1 word2 path
PARSE UPPER VALUE path WITH root':\'therest
'SET ROOT='root':'

/* the combined FontConfig/Freetype package needed for cairo builds */
'set MZFTCFGFT=%ROOT%\mzfntcfgft'
/* Create an environment variable MZFTCFGFT2 with forward slashes instead of backslashes */
'set MZFTCFGFT2='backtoforward(value('MZFTCFGFT',,'OS2ENVIRONMENT'));

/* If PYTHONLOC is not set, assume PYTHON is a directory off of ROOT */
'SET PYTHONLOC=%ROOT%\python26'
'rem SET PYTHONLOC=%ROOT%\PYTHON25'
if value('PYTHONHOME',,'OS2ENVIRONMENT') = '' THEN
DO
'set PYTHONHOME='backtoforward(value('PYTHONLOC',,'OS2ENVIRONMENT'));
END

/* If the environment variable PERLLOC is set, use it, otherwise assume PERLLIB is a directory off of ROOT */
if value('PERLLOC',,'OS2ENVIRONMENT') = '' THEN
DO
'SET PERLLOC=%ROOT%\PERL'
END

/* If the environment variable GLIBIDL is set, use it, otherwise assume GLIBIDL is a directory off of ROOT */
if value('GLIBIDL',,'OS2ENVIRONMENT') = '' THEN
DO
'SET GLIBIDL=%ROOT%\GLIBIDL\gcc335'
END
/* Create an environment variable GLIBIDL2 with forward slashes instead of backslashes */
'SET GLIBIDL2='backtoforward(value('GLIBIDL',,'OS2ENVIRONMENT'));

/* If the environment variable AUTOCONF is set, use it, otherwise assume AUTOCONF is a directory off of ROOT */
if value('AUTOCONF',,'OS2ENVIRONMENT') = '' THEN
DO
'SET AUTOCONF=%ROOT%/AUTOCONF/BIN/AUTOCONF'
END

/* If the environment variable GCCDIR is set, use it, otherwise assume GCCDIR is a directory off of ROOT */
if value('GCCDIR',,'OS2ENVIRONMENT') = '' THEN
DO
'SET GCCDIR=%ROOT%\usr'
END
/* Create an environment variable GCCDIR2 with forward slashes instead of backslashes */
'SET GCCDIR2='backtoforward(value('GCCDIR',,'OS2ENVIRONMENT'));

/* If the environment variable EMX is set, use it, otherwise assume EMX is a directory off of ROOT */
if value('EMX',,'OS2ENVIRONMENT') = '' THEN
DO
'SET EMX=%ROOT%\EMX'
END
/* Create an environment variable EMX2 with forward slashes instead of backslashes */
'SET EMX2='backtoforward(value('EMX',,'OS2ENVIRONMENT'));

/* If the environment variable VACPP365 is set, use it, otherwise assume VACPP365 is a directory off of ROOT */
if value('VACPP365',,'OS2ENVIRONMENT') = '' THEN
DO
'SET VACPP365=%ROOT%\IBMCXXO'
END

/* If the environment variable TOOLKIT is set, use it, otherwise assume TOOLKIT is a directory off of ROOT */
if value('TOOLKIT',,'OS2ENVIRONMENT') = '' THEN
DO
'SET TOOLKIT=%ROOT%\os2tk45'
END
/* Create an environment variable TOOLKIT2 with forward slashes instead of backslashes */
'SET TOOLKIT2='backtoforward(value('TOOLKIT',,'OS2ENVIRONMENT'));

/* If the environment variable MOZTOOLS is set, use it, otherwise assume MOZTOOLS is a directory off of ROOT */
if value('MOZTOOLS',,'OS2ENVIRONMENT') = '' THEN
DO
'SET MOZTOOLS=%ROOT%\MOZTOOLS'
END

/* If CVSROOT which is set in the environment contains mozilla.org, don't set it. Otherwise set it to */
/* anonymous */
cvsroot = value('CVSROOT',,'OS2ENVIRONMENT')
parse var cvsroot thefirst'mozilla.org'thelast
if (thelast = "") then
DO
'set CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'
END

/* If a HOME environment variable is not set, set it */
if value('HOME',,'OS2ENVIRONMENT') = '' THEN
DO
'set HOME=%ROOT%\HOME'
END
'set PERLLIB_PREFIX=""'
'SET BEGINLIBPATH=%PERLLOC%\lib;%MOZTOOLS%;%EMX%\dll;%PYTHONLOC%;%BEGINLIBPATH%'
'SET PATH=%PERLLOC%\bin\5.8.0;%MOZTOOLS%;%EMX%\bin;%PYTHONLOC%;%PATH%;'
'SET DPATH=%MOZTOOLS%;%TOOLKIT%\msg;%DPATH%;'

/* Use PYTHONPATH if already set, otherwise set to standard sub directories */
if value('PYTHONPATH',,'OS2ENVIRONMENT') = '' THEN
DO
'set PYTHONPATH=%PYTHONHOME%/Lib;%PYTHONHOME%/Lib/plat-os2emx;%PYTHONHOME%/Lib/lib-dynload;%PYTHONHOME%/Lib/site-packages'
END

/* REM *** PERL settings */
'set PERLLIB_PREFIX=L:/Perl/lib;%PERLLOC%\lib'
'set PERL_SH_DIR=%PERLLOC%\BIN\5.8.0'
'set USE_PERL_FLOCK=0'

/* REM *** shell settings **** */
'set SHELL=ash.exe'
'SET CONFIG_SHELL=ash.exe'
'SET MAKESHELL=ash.exe'

/* REM *** AUTOCONF settings **** */
'SET AC_PREFIX=%AUTOCONF%/bin'
'SET AC_MACRODIR=%AUTOCONF%/share/autoconf'

/* REM *** Compiler settings **** */
'set CC=gcc'
'set CXX=g++'

'SET PATH=%AUTOCONF%\bin;%GCCDIR%\local44\bin;%GCCDIR%\local44\libexec\gcc\i386-pc-os2-emx\4.4.2;%GCCDIR%\bin;%GLIBIDL%\bin;%PATH%'
'SET BEGINLIBPATH=%GCCDIR%\local44\lib;%GCCDIR%\lib;%GLIBIDL%\lib;%BEGINLIBPATH%'

'SET C_INCLUDE_PATH=%GCCDIR2%/lib/gcc/i386-pc-os2-emx/4.4.2/include;%GCCDIR2%/local44/include;%GCCDIR2%/include;%TOOLKIT2%/H/ARPA;%TOOLKIT2%/H/NET;%TOOLKIT2%/H/NETINET;%TOOLKIT2%/H/NETNB;%TOOLKIT2%/H'
'SET CPLUS_INCLUDE_PATH=%GCCDIR2%/local44/include/c++/4.4.2;%GCCDIR2%/local44/include/c++/4.4.2/i386-pc-os2-emx;%GCCDIR2%/local44/lib/gcc/i386-pc-os2-emx/4.4.2/include'
'SET CPLUS_INCLUDE_PATH=%CPLUS_INCLUDE_PATH%;%GCCDIR2%/local44/include/c++/4.4.2/backward;%GCCDIR2%/local44/include;%GCCDIR2%/include;%TOOLKIT2%/H/ARPA;%TOOLKIT2%/H/NET;%TOOLKIT2%/H/NETINET;%TOOLKIT2%/H/NETNB;%TOOLKIT2%/H'
'SET INCLUDE=%TOOLKIT%\h;%INCLUDE%'
'SET LIBRARY_PATH=%GCCDIR2%/lib/tcpipv4;%GCCDIR2%/local44/lib;%GCCDIR2%/lib;%TOOLKIT2%/lib;'

'SET GCCLOAD=5'
'SET GCCOPT=-pipe'
'SET EMXOPT=-c -n -h256'

'SET TERMCAP=%EMX2%/etc/termcap.dat'
'rem SET TERM=ansi-color-3'
'SET TERM=os2'

'SET INFOPATH=%EMX2%/info'
'SET EMXBOOK=emxdev.inf+emxlib.inf+emxgnu.inf+emxbsd.inf'
'SET HELPNDX=EPMKWHLP.NDX+CPP.NDX+CPPBRS.NDX+emxbook.ndx'

'set GLIB_CONFIG=%GLIBIDL%\bin\glib-config'
'set LIBIDL_CONFIG=%GLIBIDL%\bin\libIDL-config'

/* rem *** ASH SHELL STUFF */
/*   for some reason, ash.exe ignores the first entry in my PATH when called  */
/*   from make; create a dummy path at the beginning in order to make it work */
'SET PATH=%ROOT%\foo;%PATH%'

/* rem *** MOZILLA BUILD **** */
'SET TEMP=%TMP%'
'SET TMPDIR=%TMP%'
'set MAKE=make.exe'
'set RANLIB=echo'
'set AWK=awk'
'set RUN_AUTOCONF_LOCALLY=1'
'SET MOZ_OS2_TOOLS=EMX'

/* REM *** Set user debug info here *** */
'set LOGNAME=%hostname%'
'set USER=%hostname%'
'set SYSTEMNAME=%hostname%'

/* REM *** needed for eComStation */
'set PROGRAMS='

/* REM *** disable assertion dialog *** */
/* 'set XPCOM_DEBUG_BREAK=warn' */
/* REM *** Enable build number in window title bar *** */
/* 'SET BUILD_OFFICIAL=1' */
exit

backtoforward: procedure
  arg pathname
  return Translate(pathname, '/', '\')
