
# RMS Makefile for CooL Compiler
#
# $__Header$
#

# --------------------------------------------------------------------
#		system specification 
# --------------------------------------------------------------------

# Path to this node system relative to the root of the
# repository area defined above (e.g. src/vc/save).

NODEPATH = cool/src

# A short name for this node system

NODENAME = Compiler

# --------------------------------------------------------------------
#		the system's components
# --------------------------------------------------------------------

#
# The system (program, library, etc.) to be built. If you want to
# manage multiple programs, you should introduce multiple targets
# (like BIN1TARGET BIN2TARGET or any better names). In this case you 
# have to adjust the system building actions accordingly.

BINTARGET = cool
LIBTARGET =
SHAREDLIBTARGET =

# Aliases for (filesystem links to) $(BINTARGET).

ALIASES =

# The release number generator. The version number of this file will
# be used as release identifier for the whole system.

VERSIONFILE   = Release.c	   # source
VERSIONOBJECT =	Release.$(OBJSUFF) # derived (if source contains program code)

# The names of the subdirectories containing subsystems which are also
# to be built.

SUBSYSTEMS =

# The regular source and header files.
#
# PUBLIC headers (of a library) would be delivered (INCLUDEPATH) to the user.
# GLOBAL and LOCAL headers wouldn't be installed.

# GENTLE Sources

GENTLE_SRC = ast.g extspecs.g misc.g print.g \
	     grammar.g \
	     context.g const.g decls.g expr.g scopes.g stmts.g types.g \
	     coder.g mapping.g codetype.g codeexpr.g codestmt.g codedecl.g
LEX_SRC    = COMMENTS.b LAYOUT.b LITBLOCK.b LEXDEF.b LEXFUNC.b SETPOS.b \
	     IDENTIFIER.t INTCONST.t DOUBLECONST.t CHARCONST.t STRINGCONST.t \
	     NEXTUNIT.t EOFILE.t

# C Sources

PUBLIC_C_HDR =
GLOBAL_C_HDR =
LOCAL_C_HDR  =         errmsg.h files.h idents.h output.h pos.h strlit.h
C_SRC        = arith.c errmsg.c files.c idents.c output.c pos.c strlit.c \
	       main.c grts.c

# Templates

PUBLIC_TMPL =
GLOBAL_TMPL =
LOCAL_TMPL  =

# All sources

HEADERS = $(PUBLIC_C_HDR) $(GLOBAL_C_HDR) $(LOCAL_C_HDR) \
          $(PUBLIC_TMPL) $(GLOBAL_TMPL) $(LOCAL_TMPL)
SOURCES = $(GENTLE_SRC) $(LEX_SRC) $(C_SRC)

# Special derived sources

DERIVED_C = $(GENTLE_SRC:.g=.c) gen.c lex.c
DERIVED_H = gen.h
DERIVED_O = $(GENTLE_SRC:.g=.o) gen.$(OBJSUFF) lex.$(OBJSUFF)

# The manuals

MANUALS = $(MAN1) $(MAN3) $(MAN4) $(MAN5) $(MAN7)
MAN1 = cool.1
MAN3 =
MAN4 =
MAN5 =
MAN7 =

# All source components of the system (should not be changed)

COMPONENTS = $(MANUALS) $(HEADERS) $(SOURCES) \
	     Shapefile Makefile win.mak Dependencies

# The derived files. All files, that are automatically produced during
# a build process should be listed here.

OBJSUFF = o
OBJECTS = $(VERSIONOBJECT) $(DERIVED_O) $(C_SRC:.c=.o)

PUBLIC_HEADERS = $(PUBLIC_C_HDR) $(PUBLIC_TMPL)
GLOBAL_HEADERS = $(GLOBAL_C_HDR) $(GLOBAL_TMPL)

TMPS    = gen.c lex.c

# --------------------------------------------------------------------
#		environment specifications and locations
# --------------------------------------------------------------------

# The operating system, $(_TARGET) shall be built for.

SYSTEM = s_svr_4

# The processor type.

MACHINE = t_i386

# The object file format

OFILEFMT = 

# The C Compiler

CCOMP = c_att
#CCOMP = gcc

# The base directory of the project's repository area.

BASE = /project/cpe/development

# Locations and modes for the installation of executables, header
# files, libraries and manuals.

INSTALLBASE    = /project/hoods/V2.0A/wx-541-att
INSTALLBINPATH = $(INSTALLBASE)/bin
INSTALLBINMODE = 555
INSTALLINCPATH = $(INSTALLBASE)/include
INSTALLINCMODE = 444
INSTALLLIBPATH = $(INSTALLBASE)/lib
INSTALLLIBMODE = 444
INSTALLMANPATH = $(INSTALLBASE)/man
INSTALLMANMODE = 444

# Directories, where local libraries and header files are to be
# installed for project wide use.

LOCAL        = $(BASE)
LOCALBINPATH = $(LOCAL)/bin
LOCALBINMODE = 775
LOCALINCPATH = $(LOCAL)/include
LOCALINCMODE = 664
LOCALLIBPATH = $(LOCAL)/lib
LOCALLIBMODE = 664

# --------------------------------------------------------------------
#		tools, flags, libraries etc.
# --------------------------------------------------------------------

# The following macros will be overwritten by the system root makefile

MAKE  = make
SHELL = /bin/sh

# Gentle

GENTLE      = g
GENTLEFLAGS = 
CHANGEPRINT = $(BASE)/bin/changePrint
REFLEX      = reflex

# Lex

LEX    = /usr/local/bin/flex

# Yacc (debug : SWITCHES += -DYYDEBUG, bison : YFLAGS += -t)
#       if bison use gcc

#YACC   = /usr/local/bin/bison
#MAKEYFLAGS = -ytl
YACC   = /usr/bin/yacc

CC  = /usr/ccs/bin/cc
#CC  = gcc
CPP = 
LD  = $(CC)

MAKELFLAGS = -L
MAKEYFLAGS = -l

MAKECPPFLAGS  = -P
MAKECOOLFLAGS =
MAKECFLAGS    = -O
#MAKECFLAGS    = -O -fno-builtin # if CC=gcc
MAKELDFLAGS   =

SYSLIBS  =

RANLIB   = 

# The following macros will NOT be overwritten by the system root makefile

# Preprocessor switches. (eg. -DDEBUG)

SWITCHES  = -D$(MACHINE) -D$(SYSTEM) 
#SWITCHES  = -DYYDEBUG -D$(MACHINE) -D$(SYSTEM) # if parser debug

INCLUDES  = 

LOCALLIBS = 

LFLAGS = $(MAKELFLAGS)
YFLAGS = $(MAKEYFLAGS)

CFLAGS     = $(INCLUDES) $(MAKECFLAGS) $(SWITCHES)
LDFLAGS    = $(MAKELDFLAGS)

# --------------------------------------------------------------------
#			default targets
# --------------------------------------------------------------------

# The default action (do not change)

all: build

# --------------------------------------------------------------------
#		Dependencies
# --------------------------------------------------------------------

include Dependencies

# --------------------------------------------------------------------
#		implicit rules 
# --------------------------------------------------------------------

.SUFFIXES: .g

.g.c:
	$(GENTLE) $(GENTLEFLAGS) $*.g

.c.o:
	$(CC) $(CFLAGS) -c $*.c

# --------------------------------------------------------------------
#		special rules 
# --------------------------------------------------------------------

ast.c : ast.g extspecs.g
	$(GENTLE) $(GENTLEFLAGS) ast.g
	$(CHANGEPRINT) ast.c

gen.c : gen.y
	$(YACC) $(YFLAGS) gen.y
	mv y.tab.c $@

lex.l : $(LEX_SRC) gen.lit gen.tkn gen.h
	$(REFLEX)
	mv gen.l $@

lex.c : lex.l
	$(LEX) $(LFLAGS) -t lex.l > $@

# --------------------------------------------------------------------
#		other targets
# --------------------------------------------------------------------

# The final system building action.

targets: $(BINTARGET) $(LIBTARGET) $(SHAREDLIBTARGET)

# Construction of a binary would look like:
$(BINTARGET): $(OBJECTS)
	$(LD) $(LDFLAGS) -o $(BINTARGET) $(OBJECTS) \
              $(LOCALLIBS) $(SYSLIBS)
	@_aliases="$(ALIASES)"; \
	for i in $$_aliases; \
	do \
	  rm -f $$i; \
	  echo linking $(BINTARGET) to $$i; \
	  ln $(BINTARGET) $$i; \
	done

# The install actions. 

# Contruction of derived sources (portable binaries)

GENTLE_TMP = $(GENTLE_SRC:.g=.c)
preinstall: $(GENTLE_TMP) lex.l
#preinstall: 

localinstalltargets: localinstallbin \
		localinstalllib \
		localinstallsharedlib \
		localinstallheaders

installtargets: installbin \
		installlib installsharedlib \
		installheaders installmanuals


# The cleanup action. Removes all automatically rederivable files.

cleanall : doclean
	rm -f $(DERIVED_C) $(DERIVED_H) lex.l gen.* y.output

doclean:
	rm -f $(BINTARGET) $(ALIASES) $(LIBTARGET) $(SHAREDLIBTARGET) \
	      $(OBJECTS) $(TMPS)

include $(LOCALINCPATH)/general_targets
