/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 *
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: rules.c 1.5 90/04/04 $@(#)make:rules.c	1.9.1.1"
#include "defs"
/* DEFAULT RULES FOR UNIX */

/*
 *	These are the internal rules that "make" trucks around with it at
 *	all times. One could completely delete this entire list and just
 *	conventionally define a global "include" makefile which had these
 *	rules in it. That would make the rules dynamically changeable
 *	without recompiling make. This file may be modified to local
 *	needs. 
 *	The makefile for make (make.mk) is parameterized for a different
 *	rules file. The macro $(RULES) defined in "make.mk" can be set
 *	to another file and when "make" is "made" the procedure will
 *	use the new file. The recommended way to do this is on the
 *	command line as follows:
 *		"make -f make.mk RULES=pwbrules"
 */

CHARSTAR builtin[] =
	{
	".SUFFIXES: .o .c .c~ .y .y~ .l .l~ .s .s~ .h .h~ .sh .sh~ .f .for .f~ .for~",

/* PRESET VARIABLES */
	"MAKE=make",
	"AR=ar",	"ARFLAGS=rv",
	"AS=as",	"ASFLAGS=",
	"CC=cc",	"CFLAGS=-O",
	"F77=fortran",	"F77FLAGS=",
	"GET=get",	"GFLAGS=",
	"LEX=lex",	"LFLAGS=",
	"LD=ld",	"LDFLAGS=",
	"YACC=yacc",	"YFLAGS=",


/* SINGLE SUFFIX RULES */
	".c:",
		"\t$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@",
	".c~:",
		"\t$(GET) $(GFLAGS) $< ; \t$(CC) $(CFLAGS) $(LDFLAGS) $*.c -o $* ; \trm -f $*.c",
	".f .for:",
		"\t$(F77) $(F77FLAGS) $(LDFLAGS) $< -o $@",
	".f~ .for~:",
		"\t$(GET) $(GFLAGS) $< ; \t$(F77) $(F77FLAGS) $(LDFLAGS) $< -o $* ; \trm -f $*.f",
	".sh:",
		"\tcp $< $@; chmod 0777 $@",
	".sh~:",
		"\t$(GET) $(GFLAGS) $< ; \tcp $*.sh $*; chmod 0777 $@ ; \trm -f $*.sh",

/* DOUBLE SUFFIX RULES */
	".c.o:",
		"\t$(CC) $(CFLAGS) -c $<",
	".c~.c:",
		"\t$(GET) $(GFLAGS) $<",
	".c~.o:",
		"\t$(GET) $(GFLAGS) $< ; \t$(CC) $(CFLAGS) -c $*.c ; \trm -f $*.c",
	".f.a .for.a:",
		"\t$(F77) $(F77FLAGS) $(LDFLAGS) -c $*.f ; \t$(AR) $(ARFLAGS) $@ $*.o ; \trm -f $*.o",
	".f.o .for.o:",
		"\t$(F77) $(F77FLAGS) $(LDFLAGS) -c $*.f",
	".f~.a .for~.a:",
		"\t$(GET) $(GFLAGS) $< ; \t$(F77) $(F77FLAGS) $(LDFLAGS) -c $*.f ; \t$(AR) $(ARFLAGS) $@ $*.o ; \trm -f $*.[fo]",
	".f~.f .for~.for:",
		"\t$(GET) $(GFLAGS) $<",
	".f~.o .for~.o:",
		"\t$(GET) $(GFLAGS) $< ; \t$(F77) $(F77FLAGS) $(LDFLAGS) -c $*.f ; \trm -f $*.f",
	".s.o:",
		"\t$(AS) $(ASFLAGS) -o $@ $<",
	".s~.o:",
		"\t$(GET) $(GFLAGS) $< ; \t$(AS) $(ASFLAGS) -o $*.o $*.s ; \trm -f $*.s",
	".s~.s:",
		"\t$(GET) $(GFLAGS) $<",
	".sh~.sh:",
		"\t$(GET) $(GFLAGS) $<",
	".y.o:",
		"\t$(YACC) $(YFLAGS) $< ; \t$(CC) $(CFLAGS) -c y.tab.c ; \trm y.tab.c ; \tmv y.tab.o $@",
	".y~.o:",
		"\t$(GET) $(GFLAGS) $< ; \t$(YACC) $(YFLAGS) $*.y ; \t$(CC) $(CFLAGS) -c y.tab.c ; \trm -f y.tab.c $*.y ; \tmv y.tab.o $*.o",
	".l.o:",
		"\t$(LEX) $(LFLAGS) $< ; \t$(CC) $(CFLAGS) -c lex.yy.c ; \trm lex.yy.c ; \tmv lex.yy.o $@",
	".l~.c:",
		"\t$(GET) $(GFLAGS) $< ; \t$(LEX) $(LFLAGS) $*.l ; \tmv lex.yy.c $@ ; \trm -f $*.l",
	".l~.l:",
		"\t$(GET) $(GFLAGS) $<",
	".l~.o:",
		"\t$(GET) $(GFLAGS) $< ; \t$(LEX) $(LFLAGS) $*.l ; \t$(CC) $(CFLAGS) -c lex.yy.c ; \trm -f lex.yy.c $*.l ; \tmv lex.yy.o $*.o",
	".y.c :",
		"\t$(YACC) $(YFLAGS) $< ; \tmv y.tab.c $@",
	".y~.c :",
		"\t$(GET) $(GFLAGS) $< ; \t$(YACC) $(YFLAGS) $*.y ; \tmv y.tab.c $*.c ; \trm -f $*.y",
	".y~.y:",
		"\t$(GET) $(GFLAGS) $<",
	".l.c :",
		"\t$(LEX) $(LFLAGS) $< ; \tmv lex.yy.c $@",
	".c.a:",
		"\t$(CC) -c $(CFLAGS) $< ; \t$(AR) $(ARFLAGS) $@ $*.o ; \trm -f $*.o",
	".c~.a:",
		"\t$(GET) $(GFLAGS) $< ; \t$(CC) -c $(CFLAGS) $*.c ; \t$(AR) $(ARFLAGS) $@ $*.o ; \trm -f $*.[co]",
	".s~.a:",
		"\t$(GET) $(GFLAGS) $< ; \t$(AS) $(ASFLAGS) -o $*.o $*.s ; \t$(AR) $(ARFLAGS) $@ $*.o ; \trm -f $*.[so]",
	".h~.h:",
		"\t$(GET) $(GFLAGS) $<",
	"markfile.o:	markfile",
		"\tA=@;echo \"static char _sccsid[] = \\042`grep $$A'(#)' markfile`\\042;\" > markfile.c ; \t$(CC) -c markfile.c ; \trm -f markfile.c",
	0 };
