home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 1 / FFMCD01.bin / useful / dist / gnu / gcc / build / config.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-24  |  7.4 KB  |  224 lines

  1. /*  Configuration for GNU C-compiler for Commodore Amiga, running AmigaDOS.
  2.    Copyright (C) 1992 Free Software Foundation, Inc.
  3.    Contributed by Markus M. Wild (wild@amiga.physik.unizh.ch).
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* first include the generic header, then modify some parts.. */
  22.  
  23. #include "m68k/xm-m68k.h"
  24.  
  25. #undef GCC_INCLUDE_DIR
  26. #define GCC_INCLUDE_DIR ":GCC_INCLUDE_DIR is not used under AmigaDOS!:"
  27.  
  28. /* use this list of header files instead of the Unix'ish default */
  29. #define INCLUDE_DEFAULTS \
  30. {                                    \
  31.   { "gcc:g++-include", 1},                        \
  32.   { "gcc:gcc-include", 0}, /* gcc-specific changes to system headers. none currently.. */ \
  33.   { "gcc:os-include", 0},  /* here go amiga specific headers */     \
  34.   { "gcc:include", 0},     /* here go the usual headers */         \
  35.   { 0, 0}                                \
  36. }
  37.  
  38. /* Fork one piped subcommand.  SEARCH_FLAG is the system call to use
  39.    (either execv or execvp).  ARGV is the arg vector to use.
  40.    NOT_LAST is nonzero if this is not the last subcommand
  41.    (i.e. its output should be piped to the next one.)  */
  42.  
  43. #ifdef AMIGADOS_FORK_GCC
  44.  
  45. /* the vfork() version. This one has the drawback, that gcc is not 
  46.    interruptible when started from make, since ixemul.library doesn't yet
  47.    propagate ^C to subprocesses.  To generate this version, define
  48.    AMIGADOS_FORK_GCC when compiling gcc.c.  This is not the default. */
  49.  
  50. #define PEXECUTE(SEARCH_FLAG,PROGRAM,ARGV,NOT_LAST) \
  51. ({int (*_func)() = (SEARCH_FLAG ? execv : execvp);            \
  52.   int _pid;                                \
  53.   int _pdes[2];                                \
  54.   int _input_desc = last_pipe_input;                    \
  55.   int _output_desc = STDOUT_FILE_NO;                    \
  56.   int _retries, _sleep_interval, _result;                \
  57.                                     \
  58.   /* If this isn't the last process, make a pipe for its output,    \
  59.      and record it as waiting to be the input to the next process.  */    \
  60.                                     \
  61.   if (NOT_LAST)                                \
  62.     {                                    \
  63.       if (pipe (_pdes) < 0)                        \
  64.     pfatal_with_name ("pipe");                    \
  65.       _output_desc = _pdes[WRITE_PORT];                    \
  66.       last_pipe_input = _pdes[READ_PORT];                \
  67.     }                                    \
  68.   else                                    \
  69.     last_pipe_input = STDIN_FILE_NO;                    \
  70.                                     \
  71.   /* Fork a subprocess; wait and retry if it fails.  */            \
  72.   _sleep_interval = 1;                            \
  73.   for (_retries = 0; _retries < 4; _retries++)                \
  74.     {                                    \
  75.       _pid = vfork ();                            \
  76.       if (_pid >= 0)                            \
  77.     break;                                \
  78.       sleep (_sleep_interval);                        \
  79.       _sleep_interval *= 2;                        \
  80.     }                                    \
  81.                                     \
  82.   switch (_pid)                                \
  83.     {                                    \
  84.     case -1:                                \
  85.       pfatal_with_name ("vfork");                    \
  86.       /* NOTREACHED */                            \
  87.       _result = 0;                            \
  88.       break;                                \
  89.                                     \
  90.     case 0: /* child */                            \
  91.       /* Move the input and output pipes into place, if nec.  */    \
  92.       if (_input_desc != STDIN_FILE_NO)                    \
  93.     {                                \
  94.       close (STDIN_FILE_NO);                    \
  95.       dup (_input_desc);                        \
  96.       close (_input_desc);                        \
  97.     }                                \
  98.       if (_output_desc != STDOUT_FILE_NO)                \
  99.     {                                \
  100.       close (STDOUT_FILE_NO);                    \
  101.       dup (_output_desc);                        \
  102.       close (_output_desc);                        \
  103.     }                                \
  104.                                     \
  105.       /* Close the parent's descs that aren't wanted here.  */        \
  106.       if (last_pipe_input != STDIN_FILE_NO)                \
  107.     close (last_pipe_input);                    \
  108.                                     \
  109.       /* Exec the program.  */                        \
  110.       (*_func) (PROGRAM, ARGV);                        \
  111.       perror_exec (PROGRAM);                        \
  112.       exit (-1);                            \
  113.       /* NOTREACHED */                            \
  114.       _result = 0;                            \
  115.       break;                                \
  116.                                     \
  117.     default:                                \
  118.       /* In the parent, after forking.                    \
  119.      Close the descriptors that we made for this child.  */        \
  120.       if (_input_desc != STDIN_FILE_NO)                    \
  121.     close (_input_desc);                        \
  122.       if (_output_desc != STDOUT_FILE_NO)                \
  123.     close (_output_desc);                        \
  124.                                     \
  125.       /* Return child's process number.  */                \
  126.       _result = _pid;                            \
  127.       break;                                \
  128.     }                                     \
  129. _result; })                                \
  130.  
  131. #define PEXECUTE_RESULT(STATUS, COMMAND) \
  132.   ({ wait (& STATUS); })
  133.  
  134. #else
  135.  
  136. /* This version uses a more or less amigados-conformant way of running a
  137.    program (in the context of the parent) and is the default way the
  138.    gcc frontend is built. If you want to use -pipe however, you'll have
  139.    to use the vfork() version above. */
  140.  
  141. #define PEXECUTE(SEARCH_FLAG,PROGRAM,ARGV,NOT_LAST) \
  142. ({char *_argline;                        \
  143.   int _arglinelength, _i;                    \
  144.                                 \
  145.   for (_i = 1, _arglinelength=0; ARGV[_i]; ++_i)        \
  146.     _arglinelength += strlen(ARGV[_i]) + 1;            \
  147.                                 \
  148.   _arglinelength += strlen(PROGRAM) + 1;            \
  149.                                 \
  150.   if (!(_argline = (char *)alloca(_arglinelength)))         \
  151.     pfatal_with_name ("alloca");                \
  152.                                 \
  153.   strcpy(_argline, PROGRAM);                    \
  154.   for (_i = 1; ARGV[_i]; ++_i)                     \
  155.     {                                \
  156.       strcat(_argline, " ");                    \
  157.       strcat(_argline, ARGV[_i]);                \
  158.     }                                \
  159.                                 \
  160.   ssystem(_argline); })                        \
  161.  
  162. #define PEXECUTE_RESULT(STATUS, COMMAND) \
  163.   ({ STATUS = COMMAND.pid; })
  164.  
  165. #endif /* AMIGADOS_FORK_GCC */
  166.  
  167. /* the following macros are stolen more or less from xm-vms.h ... */
  168.  
  169. /* This macro is used to help compare filenames in cp-lex.c.
  170.  
  171.    We also need to make sure that the names are all lower case, because
  172.    we must be able to compare filenames to determine if a file implements
  173.    a class.  */
  174.  
  175. #define FILE_NAME_NONDIRECTORY(C)                \
  176. ({                                \
  177.    char * pnt_ = (C), * pnt1_;                    \
  178.    pnt1_ = pnt_ - 1;                        \
  179.    while (*++pnt1_)                        \
  180.      if ((*pnt1_ >= 'A' && *pnt1_ <= 'Z')) *pnt1_ |= 0x20;    \
  181.    pnt1_ = rindex (pnt_, '/');                     \
  182.    pnt1_ = (pnt1_ == 0 ? rindex (pnt_, ':') : pnt1_);        \
  183.    (pnt1_ == 0 ? pnt_ : pnt1_ + 1);                \
  184.  })
  185.  
  186. /* Macro to generate the name of the cross reference file.  The standard
  187.    one does not work, since it was written assuming that the conventions
  188.    of a unix style filesystem will work on the host system.
  189.  
  190.    Contrary to VMS, I'm using the original unix filename, there's no reason
  191.    not to use this under AmigaDOS. */
  192.  
  193. #define XREF_FILE_NAME(BUFF, NAME)    \
  194.   s = FILE_NAME_NONDIRECTORY (NAME);            \
  195.   if (s == NAME) sprintf(BUFF, ".%s.gxref", NAME);    \
  196.   else {                        \
  197.     unsigned char ch = *s; /* could be Latin1 char.. */    \
  198.     /* temporary: cut the filename from the directory */\
  199.     *s = 0;                        \
  200.     sprintf (BUFF, "%s.%c%s.gxref", NAME, ch, s+1);    \
  201.     /* and restore the filename */            \
  202.     *s = ch;                        \
  203.   }                            \
  204.  
  205. /* Macro that is used in cp-xref.c to determine whether a file name is
  206.    absolute or not.
  207.  
  208.    This checks for both, '/' as first character, since we're running under
  209.    ixemul.library which provides for this unix'ism, and for the usual 
  210.    logical-terminator, ':', somewhere in the filename. */
  211.  
  212. #define FILE_NAME_ABSOLUTE_P(NAME) (NAME[0] == '/' || index(NAME, ':'))
  213.  
  214.  
  215. /* the colon conflicts with the name space of logicals */
  216.  
  217. #define PATH_SEPARATOR ','
  218.  
  219. /* AmigaDOS handles rename(2) *much* better than any link(2)/unlink(2)
  220.    hacks. It's actually the inverse case as on Unix. rename(2) was always
  221.    there, link(2) is new with OS 2.0 */
  222.  
  223. #define HAVE_rename 1
  224.