/* Copyright (C) 1992, Digital Equipment Corporation                         */
/* All rights reserved.                                                      */
/* See the file COPYRIGHT for a full description.                            */

/* File: m3makefile                                                          */
/* Last modified on Mon Sep 14 14:00:00 PDT 1992 by rustan                   */

/* This m3makefile is a bit complicated because we want to use it for 
   three different purpose: to build from the sources, to build for the 
   export, and to build from C at the export sites. */

PASS0 = @/ufs/jan/rustan/m3/bin/m3compiler@
PASS1 = @ccmos@
PASS2 = @ccmosM3@-T@8000@

DEFPATH = .:/ufs/jan/rustan/m3/include
LIBPATH = .:/ufs/jan/rustan/m3/lib:/usr/local/lib
INCL =    /ufs/jan/rustan/m3/include

LINKFILES = @-lm3@
/*  Does LINKCOVER also need to be replaced?  */

config.c: $(LIB_USE)/config
	@echo "building config.c ..."
	@/bin/rm -f config.c
	@echo 'static char *args [] = {'              >  config.c
	@echo '  "-Y0$(PASS0)",'                      >> config.c
	@echo '  "-Y1$(PASS1)",'                      >> config.c
	@echo '  "-Y2$(PASS2)",'                      >> config.c
	@echo '  "-Y3$(PASS3)",'                      >> config.c
	@echo '  "-Y4$(PASS4)",'                      >> config.c
	@echo '  "-Y5$(PASS5)",'                      >> config.c
	@echo '  "-D$(DEFPATH)",'                     >> config.c
	@echo '  "-L$(LIBPATH)",'                     >> config.c
	@echo '  "-z0$(CC_O)",'                       >> config.c
	@echo '  "-z1$(CC_G)",'                       >> config.c
	@echo '  "-z2$(LINKFILES)",'                  >> config.c
	@echo '  "-z3$(LINKCOVER)",'                  >> config.c
	@echo '  "-z4$(INCL)",'                       >> config.c
	@echo '  "-z5$(CC_WARNS_FOR_UNKNOWN_FILES)",' >> config.c
	@echo '  "-z6$(KEEP_LIBRARIES_RESOLVED)",'    >> config.c
	@echo '  "-z7$(BASE_ARGS)",'                  >> config.c
	@echo '  "-z8$(OVERLAY_0)",'                  >> config.c
	@echo '  "-z9$(OVERLAY_1)",'                  >> config.c
	@echo '  "-zA$(SERVER_LIMIT)",'               >> config.c
	@echo '  0 };'                                >> config.c
	@echo 'char **DriverConfig__args = args;'      >> config.c
	@chmod -w config.c

/*---------------------------------------------------------- build from C ---*/
#if defined (BOOT) 	/* build from C */

#include "m3makefile.objs"

all:: m3

m3::  $(OBJS)
	IFS=' $(SEP)'; $(PASS2) -o m3 $(OBJS) $(LINKBFILES)

clean::
	rm -f m3

.c.o:
	IFS=' $(SEP)'; $(PASS1) -c $(BOOTOPT) $<
.s.o:
	IFS=' $(SEP)'; $(PASS1) -c $(BOOTOPT) $<

BindExport (m3)
MandExport (m3,1)

/*---------------------------------------------------- build from Modula-3---*/
#else			

source_dir (../../linker/src)
source_dir (../../static/src)

implementation (Main)
module (DriverConfig)
module (OS)
PGM_SOURCES ++= config.c

#if defined (BUILD_BOOT)
all::
	cp SOURCE_DIR##/m3.1 .
#else
all:: config.c
ManPage (m3,1)
#endif

Program (m3)
all::
	chmod 755 m3

#endif /* BOOT */
