# Makefile for "p2c", the Pascal to C translator.
#  Copyright (C) 1989, 1990, 1991 Free Software Foundation.
#  Author: Dave Gillespie.
#  Author's address: daveg@csvax.caltech.edu; 256-80 Caltech/Pasadena CA 91125.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation (any version).

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# this makefile is for Aztec C 5.2a

# Compiler options
CC = cc                    
OPT =  -mcd -fa -so
DEB = 
DEFS = 	   
CFLAGS = $(OPT) $(DEB) $(DEFS)
LFLAGS = 

# Custom translator modules
CUSTSRCS = hpmods.c citmods.c
CUSTOBJS = hpmods.o citmods.o
CUSTDEFS = -DCUST1=hpmods -DCUST2=citmods


# File names
P2CSRCS = trans.c stuff.c out.c comment.c lex.c parse.c decl.c \
          expr.c pexpr.c funcs.c dir.c
P2COBJS = trans.o stuff.o out.o comment.o lex.o parse.o decl.o \
          expr.o pexpr.o funcs.o dir.o

SRCS = $(P2CSRCS) $(CUSTSRCS)
OBJS = $(P2COBJS) $(CUSTOBJS)

LIBSRCS = p2clib.c loc.p2clib.c
LIBOBJS = p2clib.o loc.p2clib.o
OTHERLIBOBJS =


ABSHOMEDIR = P2C:home

MISCSRCS = makeproto.c
PROTOS = p2c.proto p2c.hdrs
HDRS = trans.h p2c.h


# Top-level targets
all: proto p2c p2c.lib 
proto: $(PROTOS)


# Making p2c
p2c: $(OBJS)
	ln $(LFLAGS) $(OBJS) -o p2c -lmal -lcl

dir.o: dir.c trans.h
	$(CC) $(CFLAGS) $(CUSTDEFS) dir.c

trans.o: trans.c trans.h
	$(CC) $(CFLAGS) -dHASDUMPS -dP2C_HOME="$(ABSHOMEDIR)" trans.c


# Making and using makeproto

p2c.hdrs: $(SRCS) makeproto
	makeproto -n -m -h -t16 -a35 -s0 -x $(SRCS) -o p2c.hdrs

p2c.proto: $(SRCS) makeproto
	makeproto -n -m -h -t16 -a35 -s1 -i $(SRCS) -o p2c.proto

makeproto: makeproto.c
	$(CC) -so makeproto.c
        ln makeproto -lc
        


# Making the p2c runtime library

p2c.lib: $(LIBOBJS)
	lb  p2c.lib $(LIBOBJS) $(OTHERLIBOBJS)

p2clib.o: p2clib.c
	$(CC) -so p2clib.c

