Re: [AD] [AL] Mingw complation

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


Javier GonzÓlez <xaviergonz@xxxxxxxxxx> writes:

> > I'm currently trying to compile allegro cvs for
> > mingw32 solely under a windows box. I was wondering if
> > anyone else had tried and failed / succeeded.
> > 
> > I need various tools, make, sed, etc. So I installed
> > mingw and listed, then I did a full install of cygwin,
> > and put in after mingw in my path...
> > 
> > When I try to run the makefile, I have to change a
> > couple of the makefile.mgw file where the build target
> > is a file in a subdirectory, i.e.
> > 
> > obj\mingw\mmx.h -> obj/mingw/mmx.h to get it to
> > recognise it.. but then the compliation just keeps
> > dying toward the end. Just wanted to know if anyone
> > else had managed it and could tell me what software
> > they used...
> 
> first do fixming
> then do (with DJGPP gcc and make)
> make depend
> fixdll
> and then (with MINGW32 gcc and make)
> make

The problem is when there is sh utility in the PATH.  Ming make will
use it instead of command.com to execute programs and sh will
interpret escape sequences (\) and treat # as a beginning of comment.

Problem with backslashes can be solved by doubling them and it will
not break compilation with command.com too.  Problem with # is harder,
because DOS echo does not understand quoting.  We can echo without #,
and change resulting file with sed, but this means everyone will need
sed.

Another way is to create simple test program that will output
anything we want.  There might be problems with cross compiling where
it is not possible to run compiled programs.  Sample test program is
given below.  Compile and run for the first time to make initial
mmx.h, then compile with TEST_MMX define and run (suppressing errors
in make for compilation and when running) to add ALLEGRO_MMX to mmx.h
if MMX is supported by compiler.

#include <stdio.h>
#include <stdlib.h>

#ifdef TEST_MMX
void unused (void)
{
  __asm__ __volatile__ (".text\n\temms");
}
#endif

int
main (int argc, char *argv[])
{
   FILE *file;

   if (argc < 2) {
      fprintf (stderr, "Usage: %s mmx.h\n", argv[0]);
      exit (EXIT_FAILURE);
   }

   file = fopen (argv[1], "wt");
   if (file == 0) {
      fprintf (stderr, "%s: can not open '%s' for writing\n",
               argv[0], argv[1]);
      exit (EXIT_FAILURE);
   }

#ifdef TEST_MMX
   fprintf (file, "#define ALLEGRO_MMX 1\n");
#else
   fprintf (file, "// no MMX\n");
#endif

   if (ferror (file)) {
      fclose (file);
      fprintf (stderr, "%s: can not write to '%s'\n", argv[0], argv[1]);
      exit (EXIT_FAILURE);
   }
   if (fclose (file)) {
      fprintf (stderr, "%s: can not close '%s'\n", argv[0], argv[1]);
      exit (EXIT_FAILURE);
   }

   return EXIT_SUCCESS;
}

-- 
Michael Bukin



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