# 1 "implicit.c"
 

















# 1 "make.h" 1
 

















# 1 "/usr/include/sys/types.h" 1
 

 



























 













































 



 


 


 


typedef	unsigned char	u_char;
typedef	unsigned short	u_short;
typedef	unsigned int	u_int;
typedef	unsigned int	uint;		 
typedef	unsigned long	u_long;
typedef	unsigned short	ushort;		 

typedef	volatile char		v_char;
typedef	volatile short		v_short;
typedef	volatile long		v_long;
typedef	volatile unsigned char	vu_char;
typedef	volatile unsigned short	vu_short;
typedef	volatile unsigned long	vu_long;

typedef



		char	s_char;


typedef	struct	_physadr { int r[1]; } *physadr;
typedef	struct	label_t	{
	int	val[14];
} label_t;


# 126 "/usr/include/sys/types.h"


typedef	struct	_quad { long val[2]; } quad;
typedef	long	daddr_t;
typedef	char *	caddr_t;
typedef u_long	gno_t;
typedef short	cnt_t;			 
typedef	long	swblk_t;
typedef long	paddr_t;		 
typedef	long	audit_ID_t;


typedef	short	dev_t;
typedef short	gid_t;			 
typedef	unsigned long	ino_t;
typedef unsigned short	mode_t;		 
typedef short	nlink_t;		 
typedef	int	off_t;


typedef int	pid_t;			 

typedef short	uid_t;			 


typedef int	time_t;





typedef	unsigned int	size_t;



typedef int	clock_t;			 

typedef long	key_t;			 




 









 

typedef long	fd_mask;






typedef	struct fd_set {
	fd_mask	fds_bits[(((64 )+(( (sizeof(fd_mask) * 8		)	)-1))/( (sizeof(fd_mask) * 8		)	)) ];
} fd_set;








# 19 "make.h" 2

# 1 "/usr/include/sys/stat.h" 1

 

 



























 



























struct	stat
{
	dev_t		st_dev;
	ino_t		st_ino;
	mode_t		st_mode;
	nlink_t		st_nlink;
	uid_t		st_uid;
	gid_t		st_gid;
	dev_t		st_rdev;
	off_t		st_size;
	time_t		st_atime;
	int		st_spare1;
	time_t		st_mtime;
	int		st_spare2;
	time_t		st_ctime;
	int		st_spare3;
	long		st_blksize;
	long		st_blocks;
	unsigned long	st_gennum;
	long		st_spare4;
};

 



















 












 

 


 


 


 


 




 







 









 



 








 








 




 




























extern	mode_t	umask();
extern	int
	chmod(),
	fstat(),
	mkdir(),
	mkfifo(),
	stat();



# 20 "make.h" 2

# 1 "/usr/include/signal.h" 1
 

 


























 














































 












































 






# 143 "/usr/include/signal.h"






 

typedef long	sig_atomic_t;
typedef int sigset_t;	 


 


struct	sigvec {
	void	 (*sv_handler)();	 
	sigset_t sv_mask;		 
	int	sv_flags;		 
};


 



struct	sigaction {
	void	 (*sa_handler)();	 
	sigset_t sa_mask;		 
	int	 sa_flags;		 
};














 







 


struct	sigstack {
	char	*ss_sp;			 
	int	ss_onstack;		 
};

 















struct	sigcontext {






	int	sc_onstack;		 
	int	sc_mask;		 

	int	sc_sp;			 
	int	sc_pc;			 
	int	sc_ps;			 

# 259 "/usr/include/signal.h"

};























 



extern void	(*signal(int __sig, void(*__func)(int)))(int);
int	raise( int __sig );
int 	kill( pid_t __pid, int __sig );
int 	sigemptyset( sigset_t *__set );
int 	sigfillset( sigset_t *__set );
int 	sigaddset( sigset_t *__set, int __signo );
int	sigdelset( sigset_t *__set, int __signo );
int	sigismember( const sigset_t *__set, int __signo );
int 	sigaction( int __sig, const struct sigaction *__act,
		struct sigaction *__oact );
int 	sigprocmask( int __how, const sigset_t *__set, sigset_t *__oset );
int	sigpending( sigset_t *__set );
int	sigsuspend( const sigset_t *__sigmask );











 









# 21 "make.h" 2

# 1 "/local/gnu/lib/gcc/include/stdio.h" 1
 




 


























 




















































			 




extern	struct	_iobuf {
	int	_cnt;
	char	*_ptr;
	char	*_base;
	int	_bufsiz;
	short	_flag;
	char	_file;
} _iob[3 ];
typedef	struct _iobuf	FILE;

typedef	long	fpos_t;

















 










 



extern int 	getc( FILE *__stream );
extern int	getchar( void );
extern int	putc( int __c, FILE *__stream);
extern int	putchar( int __c);
extern int	feof( FILE *__stream );
extern int	ferror( FILE *__stream );
extern int	fileno( FILE *__stream );
















typedef char *va_list;

 



extern void	clearerr( FILE *__stream); 
extern int	fclose( FILE *__stream );
extern FILE *	fdopen( int __filedes, char *__type );
extern int	fflush( FILE *__stream );
extern int	fgetc( FILE *__stream );
extern int	fgetpos( FILE *__stream, fpos_t *__pos );
extern char *	fgets( char *__s, int __n, FILE *__stream );
extern FILE *	fopen( char *__filename, char *__type );
extern int	fprintf( FILE *__stream, const char *__format, ... );
extern int	fputc( int __c, FILE *__stream );
extern int	fputs( const char *__s, FILE *__stream );
extern size_t	fread( void *__ptr, size_t __size,
			size_t __nitems, FILE *__stream ); 
extern FILE *	freopen( char *__filename, char *__type, FILE *__stream );
extern int	fscanf( FILE *__stream, const char *__format, ... );
extern int	fseek( FILE *__stream, long __offset, int __ptrname );
extern int	fsetpos( FILE *__stream, fpos_t *__pos );
extern long	ftell( FILE *__stream );
extern size_t	fwrite( void *__ptr, size_t __size,
			size_t __nitems, FILE *__stream );
extern char *	gets( char *__s );	
extern int	getw(FILE *__stream);
extern void	perror( char *__s );
extern int	pclose( FILE *__stream );
extern FILE  *	popen(char *__command, char *__type );
extern int	printf( const char *__format, ... );	
extern int	puts( const char *__s );	
extern int	putw( int __w, FILE *__stream );
extern int	remove( char *__filename );
extern int	rename( const char *__from, const char *__to );
extern void	rewind( FILE *__stream );
extern int	scanf( const char *__format, ... );	
extern void	setbuf( FILE *__stream, char *__buf );
extern int	setvbuf( FILE *__stream, char *__buf,
			int __type, size_t __size );
extern int	sscanf( char *__s, const char *__format, ... );
extern FILE *	tmpfile( void );	
extern char *	tmpnam( char *__s );
extern char *	tempnam( char *__dir, char *__pfx);
extern int	ungetc( int __c, FILE *__stream );
extern int	vfprintf( FILE *__stream, const char *__format, va_list __ap );
extern int	vprintf( const char *__format, va_list __ap );
extern int	vsprintf( char *__s, const char *__format, va_list __ap);

# 278 "/local/gnu/lib/gcc/include/stdio.h"



 
extern int	sprintf( char *__s, const char *__format, ... );



















# 22 "make.h" 2

# 1 "/usr/include/ctype.h" 1
 




 


























 







































extern	unsigned short *_pctype;
extern  unsigned short _ctype__[];


 



int	isalnum( int __c );
int	isalpha( int __c );
int	isascii( int __c );
int	iscntrl( int __c );
int	isdigit( int __c );
int	isgraph( int __c );
int	islower( int __c );
int	isprint( int __c );
int	ispunct( int __c );
int	isspace( int __c );
int	isupper( int __c );
int	isxdigit( int __c );
int	toascii( int __c );
int	_tolower( int __c );
int	_toupper( int __c );
int	tolower( int __c );
int	toupper( int __c );























# 23 "make.h" 2




























# 1 "/usr/include/sys/param.h" 1
 

 



























 









































































 

 





# 1 "/usr/include/machine/param.h" 1
 



 



























 





























 









 



























 


 



 




 


 


 






# 113 "/usr/include/sys/param.h" 2








 







 




















 






# 173 "/usr/include/sys/param.h"



 






				 
				 
				 
				 

 




 











 















 


 






# 1 "/usr/include/signal.h" 1
 

 


























 






























# 321 "/usr/include/signal.h"

# 231 "/usr/include/sys/param.h" 2








 






 




 


















 

 




 








# 1 "/usr/include/sys/types.h" 1
 

 



























 









































# 197 "/usr/include/sys/types.h"

# 286 "/usr/include/sys/param.h" 2








# 1 "/usr/include/sys/smp_lock.h" 1
 

 



























 










































































 












 

















 



struct __lock_t {
	volatile unsigned long 	
			l_call:8,	 
			l_hierpos:8,	 
			l_ipl:8,	 
			l_type:7,	 
			l_lock:1;	 
	struct __lock_t	*l_plock;	 
	char *		l_pc;
	unsigned long 	l_lost; 	 
	unsigned long 	l_spin;		 
	unsigned long 	l_won;		 
	unsigned short 	l_wanted;	 

};




 



struct lock_trace {
	long tr_pid;	 
	caddr_t tr_pc;	 
	long tr_psl;	 
	struct __lock_t  *tr_lock;	 
};



struct debug_entry {
		unsigned int spinct;
		caddr_t calling_pc;
		caddr_t holding_pc;
	};
struct debug_lock_trace {
	struct __lock_t  *traced_lock;
	int current_lock_trace;	
	int debug_lock_entries;
	struct debug_entry element[200 ];
};

extern struct debug_lock_trace *debug_lock_trace;

 
struct lock_data {
	char	l_hierpos;
	char	l_type;
	char	l_ipl;
};

# 365 "/usr/include/sys/smp_lock.h"




# 294 "/usr/include/sys/param.h" 2







 






























 







 












 





 







 





 





# 51 "make.h" 2




















































# 1 "/local/gnu/lib/gcc/include/strings.h" 1
 



 


























 

















 





 




extern char
	*strcat( char *__s1, const char *__s2 ),	
	*strchr( const char *__s, int __c ),
	*strcpy( char *__s1, const char *__s2 ),
	*strerror( int __n ),		
	*strncat( char *__s1, const char *__s2, size_t __n ),
	*strncpy( char *__s1, const char *__s2, size_t __n ),
	*strpbrk(const char *__s1, const char *__s2 ),	
	*strrchr( const char *__s, int __c ),
	*strstr( const char *__s, const char *__t ),
	*strtok( char *__s1, const char *__s2 );	

extern int
	memcmp( const void *__s1, const void *__s2, size_t __n ),
	strcmp( const char *__s1, const char *__s2 ),
	strcoll( const char *__s1, const char *__s2 ),
	strncmp( const char *__s1, const char *__s2, size_t __n );

extern void
	*memchr( const void *__s, int __c, size_t __n ),	
	*memcpy( void *__s1, const void *__s2, size_t __n ),
	*memmove( void *__s1, const void *__s2, size_t __n ),
	*memset( void *__s, int __c, size_t __n );

extern size_t
	strcspn( const char *__s1, const char *__s2 ),
	strlen( const char *__s ),
	strspn( const char *__s1, const char *__s2 ),
	strxfrm( char *__to, const char *__from, size_t __maxsize  );

# 124 "/local/gnu/lib/gcc/include/strings.h"

# 103 "make.h" 2



extern int bcmp ();


extern void bzero ();


extern void bcopy ();






extern char *malloc (), *realloc ();
extern void free ();


































 









extern void die ();
extern void message (), fatal (), error ();
extern void makefile_error (), makefile_fatal ();
extern void pfatal_with_name (), perror_with_name ();
extern char *savestring (), *concat ();
extern char *xmalloc (), *xrealloc ();
extern char *find_next_token (), *next_token (), *end_of_token ();
extern void collapse_continuations (), remove_comments ();
extern char *sindex (), *lindex ();
extern int alpha_compare ();
extern void print_spaces ();
extern struct dep *copy_dep_chain ();
extern char *find_percent ();


extern int ar_name ();
extern void ar_parse_name ();
extern int ar_touch ();
extern time_t ar_member_date ();


extern void dir_load ();
extern int dir_file_exists_p (), file_exists_p (), file_impossible_p ();
extern void file_impossible ();
extern char *dir_name ();

extern void define_default_variables ();
extern void set_default_suffixes (), install_default_implicit_rules ();
extern void convert_to_pattern (), count_implicit_rule_limits ();
extern void create_pattern_rule ();

extern void build_vpath_lists (), construct_vpath_list ();
extern int vpath_search ();

extern void construct_include_path ();
extern void uniquize_deps ();

extern int update_goal_chain ();
extern void notice_finished_file ();

extern void user_access (), make_access (), child_access ();
















extern int sigsetmask ();
extern int sigblock ();

extern int kill ();
extern void abort (), exit ();
extern int unlink (), stat ();
extern void qsort ();
extern int atoi ();
extern int pipe (), close (), read (), write (), open ();
extern long int lseek ();
extern char *ctime ();










extern char *getwd ();






extern int vfork ();



extern char **environ;

extern char *reading_filename;
extern unsigned int *reading_lineno_ptr;

extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
extern int debug_flag, print_data_base_flag, question_flag, touch_flag;
extern int env_overrides, no_builtin_rules_flag, print_version_flag;
extern int print_directory_flag;

extern unsigned int job_slots;
extern double max_load_average;

extern char *program;

extern unsigned int makelevel;





# 19 "implicit.c" 2

# 1 "rule.h" 1
 
















 

struct rule
  {
    struct rule *next;
    char **targets;		 
    unsigned int *lens;		 
    char **suffixes;		 
    struct dep *deps;		 
    struct commands *cmds;	 
    char terminal;		 
    char subdir;		 
    char in_use;		 
  };

 
struct pspec
  {
    char *target, *dep, *commands;
  };


extern struct rule *pattern_rules;
extern struct rule *last_pattern_rule;
extern unsigned int num_pattern_rules;

extern unsigned int max_pattern_deps;
extern unsigned int max_pattern_dep_length;

extern struct file *suffix_file;
extern unsigned int maxsuffix;


extern void install_pattern_rule ();
# 20 "implicit.c" 2

# 1 "dep.h" 1
 
















 





struct dep
  {
    struct dep *next;
    char *name;
    struct file *file;
    int changed;
  };


 

struct nameseq
  {
    struct nameseq *next;
    char *name;
  };


extern struct nameseq *multi_glob (), *parse_file_seq ();








# 21 "implicit.c" 2

# 1 "file.h" 1
 
















 



struct file
  {
    struct file *next;
    char *name;
    struct dep *deps;
    struct commands *cmds;	 
    char *stem;			 

    struct dep *also_make;	 
    time_t last_mtime;		 
    struct file *prev;		 



     

    struct file *renamed;

     
    struct variable_set_list *variables;

     

    struct file *parent;

    short int update_status;	 


    enum			 
      {		 
	cs_not_started,		 
	cs_deps_running,	 
	cs_running,		 
	cs_finished		 
      } command_state :2 ;

    unsigned int double_colon:1; 
    unsigned int precious:1;	 
    unsigned int tried_implicit:1; 


    unsigned int updating:1;	 
    unsigned int updated:1;	 
    unsigned int is_target:1;	 
    unsigned int cmd_target:1;	 
    unsigned int phony:1;	 

    unsigned int intermediate:1; 
    unsigned int dontcare:1;	 

  };

 

extern unsigned int num_intermediates;

extern struct file *default_goal_file, *suffix_file, *default_file;


extern struct file *lookup_file (), *enter_file ();
extern void remove_intermediates (), snap_deps ();
extern void rename_file ();


extern time_t f_mtime ();








# 22 "implicit.c" 2


static int pattern_search ();

 





int
try_implicit_rule (file, depth)
     struct file *file;
     unsigned int depth;
{
  if (debug_flag) { print_spaces (depth); printf ("Looking for an implicit rule for `%s'.\n", file->name);	fflush ((&_iob[1]) );  } else ;


   

  if (ar_name (file->name))
    {
      if (debug_flag) { print_spaces (depth); printf ("Looking for archive-member implicit rule for `%s'.\n", file->name);	fflush ((&_iob[1]) );  } else ;
      if (pattern_search (file, 1, depth, 0))
	return 1;
    }


  return pattern_search (file, 0, depth, 0);
}





 













static int
pattern_search (file, archive, depth, recursions)
     struct file *file;
     int archive;
     unsigned int depth;
     unsigned int recursions;
{
   
  char *filename = archive ? index (file->name, '(') : file->name;

   
  unsigned int namelen = strlen (filename);

   
  char *lastslash;

   


  struct file *intermediate_file = 0;

   
  struct file **intermediate_files
    = (struct file **) __builtin_alloca (max_pattern_deps * sizeof (struct file *)) ;

   
  char **intermediate_patterns
    = (char **) __builtin_alloca (max_pattern_deps * sizeof (char *)) ;

   
  char **found_files = (char **) __builtin_alloca (max_pattern_deps * sizeof (char *)) ;
   
  unsigned int deps_found;

   
  register char *depname = (char *) __builtin_alloca (namelen + max_pattern_dep_length) ;

   
  register char *stem;
  register unsigned int stemlen;

   
  struct rule **tryrules
    = (struct rule **) __builtin_alloca (num_pattern_rules * sizeof (struct rule *)) ;

   
  unsigned int nrules;

   

  unsigned int *matches
    = (unsigned int *) __builtin_alloca (num_pattern_rules * sizeof (unsigned int)) ;

   

  char *checked_lastslash
    = (char *) __builtin_alloca (num_pattern_rules * sizeof (char)) ;

   
  unsigned int foundrule;

   
  int intermed_ok;

   

  int specific_rule_matched = 0;

  register unsigned int i;
  register struct rule *rule;
  register struct dep *dep;

  char *p;


  if (archive || ar_name (filename))
    lastslash = 0;
  else

    {
       


      lastslash = rindex (filename, '/');
      if (lastslash != 0 && lastslash[1] == '\0')
	lastslash = 0;
    }

   


  nrules = 0;
  for (rule = pattern_rules; rule != 0; rule = rule->next)
    {
      int specific_rule_may_have_matched = 0;
      int check_lastslash;

       

      if (rule->deps != 0 && rule->cmds == 0)
	continue;

       

      if (rule->in_use)
	{
	  if (debug_flag) { print_spaces (depth); printf ("Avoiding implicit rule recursion.\n",  0,  0); fflush ((&_iob[1]) );  } else ;
	  continue;
	}

      for (i = 0; rule->targets[i] != 0; ++i)
	{
	  char *target = rule->targets[i];
	  char *suffix = rule->suffixes[i];

	   


	  if (recursions > 0 && target[1] == '\0' && !rule->terminal)
	    continue;

	  if (rule->lens[i] > namelen)
	     
	    continue;

	   

	  stem = filename + (suffix - target - 1);
	  stemlen = namelen - rule->lens[i] + 1;

	   


	  check_lastslash = lastslash != 0 && index (target, '/') == 0;
	  if (check_lastslash)
	    {
	       

	      unsigned int difference = lastslash - filename + 1;
	      if (difference > stemlen)
		continue;
	      stemlen -= difference;
	      stem += difference;
	    }

	   
	  if (check_lastslash)
	    {
	      if (stem > (lastslash + 1)
		  && strncmp (target, lastslash + 1, stem - lastslash - 1))
		continue;
	    }
	  else if (stem > filename
		   && strncmp (target, filename, stem - filename))
	    continue;

	   




	  if (*suffix != stem[stemlen]
	      || (*suffix != '\0' && !((&suffix[1]) == ( &stem[stemlen + 1]) || (*(&suffix[1]) == *( &stem[stemlen + 1]) && (*(&suffix[1]) == '\0' || !strcmp ((&suffix[1]) + 1, ( &stem[stemlen + 1]) + 1)))) ))
	    continue;

	   
	  if (target[1] != '\0')
	    specific_rule_may_have_matched = 1;

	   
	  break;
	}

       
      if (rule->targets[i] == 0)
	continue;

      specific_rule_matched |= specific_rule_may_have_matched;

       

      if (rule->deps == 0 && rule->cmds == 0)
	continue;

       

      tryrules[nrules] = rule;
      matches[nrules] = i;
      checked_lastslash[nrules] = check_lastslash;
      ++nrules;
    }

   

  if (specific_rule_matched)
    for (i = 0; i < nrules; ++i)
      if (!tryrules[i]->terminal)
	{
	  register unsigned int j;
	  for (j = 0; tryrules[i]->targets[j] != 0; ++j)
	    if (tryrules[i]->targets[j][1] == '\0')
	      break;
	  if (tryrules[i]->targets[j] != 0)
	    tryrules[i] = 0;
	}

   
  for (intermed_ok = 0; intermed_ok == !!intermed_ok; ++intermed_ok)
    {
       



      for (i = 0; i < nrules; i++)
	{
	  int check_lastslash;

	  rule = tryrules[i];

	   

	  if (rule == 0)
	    continue;

	   

	  if (intermed_ok && rule->terminal)
	    continue;

	   

	  rule->in_use = 1;

	   

	  stem = filename
	    + (rule->suffixes[matches[i]] - rule->targets[matches[i]]) - 1;
	  stemlen = namelen - rule->lens[matches[i]] + 1;
	  check_lastslash = (lastslash != 0
			     && index (rule->targets[matches[i]], '/') == 0);
	  if (check_lastslash)
	    {
	      stem += lastslash - filename + 1;
	      stemlen -= (lastslash - filename) + 1;
	    }

	  if (debug_flag) { print_spaces (depth); printf ("Trying pattern rule with stem `%.*s'.\n", 
		   stemlen,  stem); fflush ((&_iob[1]) );  } else ;

	   

	  deps_found = 0;
	  for (dep = rule->deps; dep != 0; dep = dep->next)
	    {
	       
	      p = index (((dep)->name == 0 ? (dep)->file->name : (dep)->name) , '%');
	      if (p != 0)
		{
		  register unsigned int i;
		  if (check_lastslash)
		    {
		      i = lastslash - filename + 1;
		      bcopy (filename, depname, i);
		    }
		  else
		    i = 0;
		  bcopy (((dep)->name == 0 ? (dep)->file->name : (dep)->name) , depname + i, p - ((dep)->name == 0 ? (dep)->file->name : (dep)->name) );
		  i += p - ((dep)->name == 0 ? (dep)->file->name : (dep)->name) ;
		  bcopy (stem, depname + i, stemlen);
		  i += stemlen;
		  strcpy (depname + i, p + 1);
		  p = depname;
		}
	      else
		p = ((dep)->name == 0 ? (dep)->file->name : (dep)->name) ;

	       

	      if (file_impossible_p (p))
		{
		   



		  if (debug_flag) { print_spaces (depth); printf ("Rejecting impossible %s dependent `%s'.\n", 
			   p == depname ? "implicit" : "rule",  p); fflush ((&_iob[1]) );  } else ;
		  tryrules[i] = 0;
		  break;
		}

	      intermediate_files[deps_found] = 0;

	      if (debug_flag) { print_spaces (depth); printf ("Trying %s dependency `%s'.\n", 
		       p == depname ? "implicit" : "rule",  p); fflush ((&_iob[1]) );  } else ;
	      if (!rule->subdir && lookup_file (p) != 0 || file_exists_p (p))
		{
		  found_files[deps_found++] = savestring (p, strlen (p));
		  continue;
		}
	       

	      if (vpath_search (&p))
		{
		  if (debug_flag) { print_spaces (depth); printf ("Found dependent as `%s'.\n",  p,  0); fflush ((&_iob[1]) );  } else ;
		  found_files[deps_found++] = p;
		  continue;
		}

	       



	      if (intermed_ok)
		{
		  if (intermediate_file == 0)
		    intermediate_file
		      = (struct file *) __builtin_alloca (sizeof (struct file)) ;

		  if (debug_flag) { print_spaces (depth); printf ("Looking for a rule with intermediate file `%s'.\n", 
			   p,  0); fflush ((&_iob[1]) );  } else ;

		  bzero ((char *) intermediate_file, sizeof (struct file));
		  intermediate_file->name = p;
		  if (pattern_search (intermediate_file, 0, depth + 1,
				      recursions + 1))
		    {
		      p = savestring (p, strlen (p));
		      intermediate_patterns[deps_found]
			= intermediate_file->name;
		      found_files[deps_found] = p;
		      intermediate_file->name = p;
		      intermediate_files[deps_found] = intermediate_file;
		      intermediate_file = 0;
		      ++deps_found;
		      continue;
		    }

		   


		  file_impossible (p);
		}

	       

	      break;
	    }

	   
	  rule->in_use = 0;

	  if (dep != 0)
	    {
	       


	      while (deps_found-- > 0)
		{
		  register struct file *f = intermediate_files[deps_found];
		  free (found_files[deps_found]);
		  if (f != 0
		      && (f->stem < f->name
			  || f->stem > f->name + strlen (f->name)))
		    free (f->stem);
		}
	    }
	  else
	     
	    break;
	}

       

      if (i < nrules)
	break;

      rule = 0;
    }

   

  if (rule == 0)
    return 0;

  foundrule = i;

   


  if (recursions > 0)
     
    file->name = rule->targets[matches[foundrule]];

   



  while (deps_found-- > 0)
    {
      register char *s;

      if (intermediate_files[deps_found] != 0)
	{
	   






	  struct file *imf = intermediate_files[deps_found];
	  register struct file *f = enter_file (imf->name);
	  f->deps = imf->deps;
	  f->cmds = imf->cmds;
	  f->stem = imf->stem;
	  imf = lookup_file (intermediate_patterns[deps_found]);
	  if (imf != 0 && imf->precious)
	    f->precious = 1;
	  f->intermediate = 1;
	  f->tried_implicit = 1;
	  for (dep = f->deps; dep != 0; dep = dep->next)
	    {
	      dep->file = enter_file (dep->name);
	      dep->name = 0;
	      dep->file->tried_implicit |= dep->changed;
	    }
	  num_intermediates++;
	}

      dep = (struct dep *) xmalloc (sizeof (struct dep));
      s = found_files[deps_found];
      if (recursions == 0)
	{
	  dep->name = 0;
	  dep->file = enter_file (s);	
	}
      else
	{
	  dep->name = s;
	  dep->file = 0;
	  dep->changed = 0;
	}
      if (intermediate_files[deps_found] == 0 && tryrules[foundrule]->terminal)
	{
	   




	  if (dep->file == 0)
	    dep->changed = 1;
	  else
	    dep->file->tried_implicit = 1;
	}
      dep->next = file->deps;
      file->deps = dep;
    }
 
  uniquize_deps (file->deps);

  if (!checked_lastslash[foundrule])
    file->stem = stem[stemlen] == '\0' ? stem : savestring (stem, stemlen);
  else
    {
      file->stem = (char *) xmalloc (((lastslash + 1) - filename)
				     + stemlen + 1);
      bcopy (filename, file->stem, (lastslash + 1) - filename);
      bcopy (stem, file->stem + ((lastslash + 1) - filename), stemlen);
      file->stem[((lastslash + 1) - filename) + stemlen] = '\0';
    }

  file->cmds = rule->cmds;

   


   
  if (rule->targets[1] != 0)
    for (i = 0; rule->targets[i] != 0; ++i)
      if (i != matches[foundrule])
	{
	  struct dep *new = (struct dep *) xmalloc (sizeof (struct dep));
	  new->name = p = (char *) xmalloc (rule->lens[i] + stemlen + 1);
	  bcopy (rule->targets[i], p,
		 rule->suffixes[i] - rule->targets[i] - 1);
	  p += rule->suffixes[i] - rule->targets[i] - 1;
	  bcopy (stem, p, stemlen);
	  p += stemlen;
	  bcopy (rule->suffixes[i], p,
		 rule->lens[i]
		 - (rule->suffixes[i] - rule->targets[i] - 1) + 1);
	  new->file = enter_file (new->name);
	  new->next = file->also_make;
	  file->also_make = new;
	}


  return 1;
}
