# $Header: Makefile,v 1.7 86/07/18 06:03:46 peter Exp $
# (C) Copyright 1985 Third Eye Software, Inc. - All Rights Reserved
#
#  This Makefile makes two versions of `trans':
#
#	cdbtrans  - Runs native on a System V machine
#	xtrans - Runs on 4.2 and works with System V exectuables.
#

HFILES	= trans.h
CFILES	= aux.c init.c main.c map.c misc.c print.c sym.c type.c
ALLFILES =	Makefile $(HFILES) $(CFILES)

OFILES	= aux.o init.o main.o map.o misc.o print.o sym.o type.o ldlib.o
BFILES	= aux.b init.b main.b map.b misc.b print.b sym.b type.b ldlib.b

CC	= cc
CFLAGS	= -g
LFLAGS	= -g

XCC	= m68cc
XLIBLD	= /usr/local/src/cmd/sgs/m68k/lib/libld.a

.SUFFIXES: .b

.c.b:
	-mv $*.o $*.x
	$(XCC) $(CFLAGS) -c -I/usr/5include $*.c
	mv $*.o $*.b
	-mv $*.x $*.o

all:	sym.h config.h ext.h cdbtrans

cdbtrans:	$(OFILES) Makefile
	$(CC) $(LFLAGS) -o $@ $(OFILES) -lld

xtrans: $(BFILES) Makefile
	$(XCC) $(LFLAGS) -o $@ $(BFILES) $(XLIBLD)

ext.h:	$(CFILES)
	grep "^export" $(CFILES) | sed -f ext.sed > ext.h

config.h:	../cdb/config.h
	rm -f config.h SYS.h
	ln ../cdb/config.h .
	ln ../cdb/SYS.h .

sym.h:	../cdb/sym.h
	rm -f sym.h
	ln ../cdb/sym.h .

.PRECIOUS:	save

save:	$(ALLFILES)
	backup transV $?
	rm -f save
	touch save
	chmod 0 save

tags:	$(CFILES)
	ctags $(CFILES) > /dev/null

clean:
	@rm -f cdbtrans xtrans config.h SYS.h sym.h ext.h $(OFILES) $(BFILES)

$(OFILES):	trans.h sym.h
