Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #ifndef WEXITSTATUS
  4. #include <sys/wait.h>
  5. #endif
  6.  
  7. char buf[32768];
  8.  
  9. #if (HAS_DEVENV == 0)
  10. char * __dev_env;
  11. #endif
  12.  
  13. #define __GNUC__ 3
  14. // version-specific switches
  15. #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
  16. #define GCCOPT "-fno-stack-protector -mincoming-stack-boundary=2 "
  17. #elif __GNUC__ >= 4 && __GNUC_MINOR__ >= 1
  18. #define GCCOPT "-fno-stack-protector "
  19. #else
  20. #define GCCOPT
  21. #endif
  22.  
  23. static void __env(void)
  24. {
  25.  char * p=getenv("MENUETDEV");
  26.  if(!p)
  27.  {
  28.   printf("MENUETDEV system variable not set !!!\n");
  29.   exit(-1);
  30.  }
  31. #if (HAS_DEVENV == 0)
  32.  __dev_env=p;
  33. #endif
  34. }
  35.  
  36. int main(int argc,char * argv[])
  37. {
  38.  int u;
  39.  __env();
  40.  if(argc<3)
  41.  {
  42.   fprintf(stderr,"Usage: %s infile.c outfile.o\n",argv[0]);
  43.   return 1;
  44.  }
  45. #if (HAS_DEVENV==1)
  46.  sprintf(buf,"win32-gcc -c %s -o %s -Os -nostdinc -fno-builtin -I/dev/env/MENUETDEV/include -fno-pic "
  47.              GCCOPT
  48.              "-mno-stack-arg-probe -mpreferred-stack-boundary=2 "
  49.              "-fno-common -DMENUETDEV='\"/dev/env/MENUETDEV\"' "
  50.              "-D__DEV_CONFIG_H='</dev/env/MENUETDEV/config.h>' -D__MENUETOS__ ",argv[1],argv[2]);
  51. #else
  52.  sprintf(buf,"win32-gcc -c %s -o %s -Os -nostdinc -fno-builtin -I%s/include -fno-pic "
  53.              GCCOPT
  54.              "-mno-stack-arg-probe -mpreferred-stack-boundary=2 "
  55.              "-fno-common -DMENUETDEV='\"%s\"' "
  56.              "-D__DEV_CONFIG_H=\"<%s/config.h>\" -D__MENUETOS__ ",argv[1],argv[2],__dev_env,__dev_env,__dev_env);
  57. #endif
  58.  if(argc>3)
  59.   for(u=3;u<argc;u++)
  60.   {
  61.    strcat(buf,argv[u]);
  62.    strcat(buf," ");
  63.   }
  64.  return WEXITSTATUS(system(buf));
  65. }
  66.