[AD] updated fix.bat to simplify MSVC target

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hello,

I posted the following on the a.cc thread. I tested on XP with MSVC6.
I think the changes are compatible with Win98. I use the following to
add better error messages:

if not "%ERRORLEVEL%" == "0" goto nogcc
if not "%ERRORLEVEL%" == "0" goto helper_error

Newbies always seem to pick MSVC as their target, and have huge
problems interpretating the current usage of fix.bat. I've seen many
cases where the person's only problem is that he doesn't use
--msvcpaths...

--
Matthew Leverton
http://www.allegro.cc

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Attached is a proposed change to the fix.bat for Windows.

It does two things:

   1. Changes the --quick parameter to --crlf
   2. Changes the --msvcpaths parameter to --disable-8.3

In both cases, the switches have been reversed to default to the
opposite behavior. Justification:

   1. No one needs to convert from LF to CR/LF if they use the ZIP
distribution. The --quick parameter is a nuisance, and is
auto-disabled anyway for most of the targets. Furthermore, there is no
way to enable it if you are on one of those targets...

      The --crlf converts from LF to CR/LF if the user has entered it.
Otherwise, no conversion is ever done.

      The --quick switch was probably set up to mimic the UNIX build,
but I don't think there needs to be any relationship between the two.

   2. MSVCDir with spaces is perhaps the #1 problem newbies face when
compiling Allegro for MSVC. Even if they know they need to change it,
they don't know how. The --msvcpaths switch is a step in the right
direction, but it needs to be the default.

      I have changed it to --disable-8.3 which turns off the feature.
Otherwise, it is enabled for MSVC and MSVC7. In addition, I have added
verbose error messages, informing the user that he needs GCC if it is
not present and to set the MSVCDir if it is not.
@echo off

rem Sets up the Allegro package for building with the specified compiler,
rem and if possible converting text files from LF to CR/LF format.

rem Test if there are too many args.
if [%4] == []        goto arg3
goto help

:arg3
rem Test if third arg is ok.
if [%3] == [--crlf]     goto arg2
if [%3] == [--disable-8.3] goto arg2
if [%3] == []            goto arg2
goto help

:arg2
rem Test if second arg is ok.
if [%2] == [--crlf]     goto arg1
if [%2] == [--disable-8.3] goto arg1
if [%2] == []            goto arg1
goto help

:arg1
rem Test if first arg is ok.
if [%1] == [bcc32]   goto head
if [%1] == [djgpp]   goto head
if [%1] == [mingw32] goto head
if [%1] == [msvc]    goto head
if [%1] == [msvc7]   goto head
if [%1] == [icl]     goto head
if [%1] == [watcom]  goto head
goto help


:head
rem Generate header of makefile and alplatf.h,
rem then go to platform specific function.
echo # generated by fix.bat > makefile
echo /* generated by fix.bat */ > include\allegro\platform\alplatf.h

if [%1] == [bcc32]   goto bcc32
if [%1] == [djgpp]   goto djgpp
if [%1] == [mingw32] goto mingw32
if [%1] == [msvc]    goto msvc6
if [%1] == [msvc7]   goto msvc7
if [%1] == [icl]     goto icl
if [%1] == [watcom]  goto watcom

echo fix.bat internal error: not reached
goto help

:bcc32
echo Configuring Allegro for Windows/BCC32...
echo MAKEFILE_INC = makefile.bcc >> makefile
echo #define ALLEGRO_BCC32 >> include\allegro\platform\alplatf.h
goto tail

:djgpp
echo Configuring Allegro for DOS/djgpp...
echo MAKEFILE_INC = makefile.dj >> makefile
echo #define ALLEGRO_DJGPP >> include\allegro\platform\alplatf.h
goto tail

:mingw32
echo Configuring Allegro for Windows/Mingw32...
echo MAKEFILE_INC = makefile.mgw >> makefile
echo #define ALLEGRO_MINGW32 >> include\allegro\platform\alplatf.h
goto tail

:icl
echo Configuring Allegro for Windows/ICL...
echo COMPILER_ICL = 1 >> makefile
goto msvccommon

:msvc7
echo Configuring Allegro for Windows/MSVC7...
echo COMPILER_MSVC7 = 1 >> makefile
goto msvccommon

:msvc6
echo Configuring Allegro for Windows/MSVC6...
goto msvccommon

:msvccommon
echo MAKEFILE_INC = makefile.vc >> makefile
echo #define ALLEGRO_MSVC >> include\allegro\platform\alplatf.h
goto tail

:watcom
echo Configuring Allegro for DOS/Watcom...
echo MAKEFILE_INC = makefile.wat >> makefile
echo #define ALLEGRO_WATCOM >> include\allegro\platform\alplatf.h
goto tail

:help
echo.
echo Usage: fix platform [--crlf] [--disable-8.3]
echo.
echo Where platform is one of: bcc32, djgpp, mingw32, msvc, msvc7, icl or watcom.
echo.
echo The --crlf parameter is used to turn on LF to CR/LF conversion.
echo.
echo By default, fix.bat will shorten your MSVCDir variable into
echo the DOS 8.3 format. This is done to prevent any problems a long
echo path with spaces might cause.
echo.
echo Use the --disable-8.3 parameter if you do not want fix.bat to
echo shorten your MSVCDir variable. 
echo.
goto end

:convertmsvcdir
echo Shortening MSVCDir path...
gcc -s -o msvchelp.exe misc/msvchelp.c
if not "%ERRORLEVEL%" == "0" goto nogcc
msvchelp MSVCDir
if not "%ERRORLEVEL%" == "0" goto helper_error
del msvchelp.exe
echo include makefile.helper >> makefile
goto realtail

:nogcc
echo.
echo *** ERROR ***
echo GCC was not found in your path. To compile Allegro for MSVC, you need to
echo have gcc (MinGW or DJGPP) installed. See the documentation for more info.
echo If you have GCC installed already, you can add it to the path by the following:
echo.
echo SET PATH=%%PATH%%;c:\path-to-gcc\bin
echo.
echo After correcting this problem, you will need to run "fix.bat %1" again.
goto end

:helper_error
echo.
echo *** ERROR ***
echo There was a problem convering the MSVCDir variable to the 8.3 short format.
echo Make sure that MSVCDir is set and that you are on a drive that is writeable.
echo.
echo After correcting this problem, you will need to run "fix.bat %1" again.
echo.
goto end

:tail

if [%3] == [--disable-8.3] goto realtail
if [%2] == [--disable-8.3] goto realtail

goto convertmsvcdir

:realtail
rem Generate last line of makefile and optionally convert CR/LF.
echo include makefile.all >> makefile

if [%2] == [--crlf] goto crlf_convert
if [%3] == [--crlf] goto crlf_convert

goto done

:crlf_convert
echo Converting Allegro files to DOS CR/LF format...
utod .../*.bat .../*.sh .../*.c *.cfg .../*.h .../*.inc .../*.rc
utod .../*.rh .../*.inl .../*.s .../*.txt .../*._tx makefile.*

:done
echo Done!

:end


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/