home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d523 / bmake.lha / BMake / source.lzh / builtin.c next >
C/C++ Source or Header  |  1991-06-30  |  2KB  |  103 lines

  1. /*    builtin.c
  2.  *    (c) Copyright 1991 by Ben Eng, All Rights Reserved
  3.  *
  4.  */
  5.  
  6. #include <fcntl.h>
  7. #include <clib/exec_protos.h>
  8.  
  9. #include "make.h"
  10. #include "depend.h"
  11.  
  12. extern void NewList( struct List *);
  13.  
  14. /*    creates a new BUILTIN rule (of any type)
  15.  *    accepts optional command lines as arguments, ending in a NULL
  16.  *    returns the first target created
  17.  */
  18. static struct target *
  19. new_targetline( char *tline, ... )
  20. {
  21.     va_list argptr;
  22.     struct List cmdList;
  23.     struct target *targ;
  24.     struct command *cmd;
  25.     char *nextcmd;
  26.  
  27.     NewList( &cmdList );
  28.     va_start( argptr, tline );
  29.     while( nextcmd = va_arg( argptr, char *)) {
  30.         cmd = new_command( nextcmd );
  31.         if( !cmd ) break;
  32.         AddTail( &cmdList, &cmd->node );
  33.     }
  34.  
  35.     targ = process_targetline( tline, &cmdList );
  36.     if( !targ ) delete_commandlist( &cmdList );
  37.     va_end( argptr );
  38.     return( targ );
  39. }
  40.  
  41. int
  42. input_builtins( void )
  43. {
  44.     static char *name_list[] = {
  45.         "builtins.make",
  46.         "S:builtins.make",
  47.         NULL
  48.     };
  49.     char *filename;
  50.     int i = 0;
  51.  
  52.     while( filename = name_list[ i++ ] ) {
  53.         if( !access( filename, 0 )) { /* file exists */
  54.             if( input_makefile( filename )) return( 1 );
  55.         }
  56.     }
  57.     return( 0 );
  58. }
  59.  
  60. int
  61. init_builtins( void )
  62. {
  63.     struct target *targ;
  64.  
  65.     if( Param.no_builtins ) return( 0 );
  66.  
  67.     set_simplemacro( "CC", "dcc" );
  68.     set_simplemacro( "LN", "dcc" );
  69.     set_simplemacro( "CFLAGS", "-proto" );
  70.     set_simplemacro( "AS", "dcc" );
  71.     set_simplemacro( "CI", "ci" ); /* RCS */
  72.     set_simplemacro( "CO", "co" ); /* RCS */
  73.  
  74.     set_macro( "@D", "$(dir $@)" );
  75.     set_macro( "*D", "$(dir $*)" );
  76.     set_macro( "<D", "$(dir $<)" );
  77.     set_macro( "@F", "$(nodir $@)" );
  78.     set_macro( "*F", "$(nodir $*)" );
  79.     set_macro( "<F", "$(nodir $<)" );
  80.  
  81.     targ = new_targetline( "%,v:", NULL ); /* no commands for RCS files */
  82.  
  83.     targ = new_targetline( "%.a: RCS/%.a,v", "$(CO) -u $@", NULL );
  84.     targ = new_targetline( "%.a:", NULL ); /* no commands for a files */
  85.  
  86.     targ = new_targetline( "%.c: RCS/%.c,v", "$(CO) -u $@", NULL );
  87.     targ = new_targetline( "%.c:", NULL ); /* no commands for c files */
  88.  
  89.     targ = new_targetline( "%.h: RCS/%.h,v", "$(CO) -u $@", NULL );
  90.     targ = new_targetline( "%.h:", NULL ); /* no commands for c headers */
  91.  
  92.     targ = new_targetline( "%.i: RCS/%.i,v", "$(CO) -u $@", NULL );
  93.     targ = new_targetline( "%.i:", NULL ); /* no commands for asm headers */
  94.  
  95.     targ = new_targetline( "%.o: %.c", "$(CC) -c $(CFLAGS) -o $@ $<", NULL );
  96.     targ = new_targetline( "%.o: %.a", "$(AS) -c $(AFLAGS) -o $@ $<", NULL );
  97.  
  98.     if( input_builtins()) return( 1 );
  99.  
  100.     return( 0 );
  101. }
  102.  
  103.