# makefile

VERSION = 1

DOC	=

TEST = test.kg okout

PROGS   = uflat2

SKELFILES = make.local

MAKEFILE = Makefile

LINKER = cc

TM = tm

JUNK = tmp core makelog tags lint \
       testout

DISTOTHERS = 
DISTFILES = $(DISTSRCS) $(DISTHDRS) $(DOC) $(MAKEFILE) $(TMFILES) \
	    $(DISTOTHERS) $(TEST)

CFLAGS = -I$(IDIR) -D$(SYS) $(SYSCFLAGS) -g

LINTFLAGS = -I$(IDIR) -D$(SYS)

LIBS = $(LDIR)/libcvr.a $(LDIR)/libtmc.a $(CLIBLOC)

.SUFFIXES:
.SUFFIXES: .out .o .c .h .e .r .f .y .l .s .p .ht .ct

#when entering make do a make all 
default: all

#++ make module local start, do NOT touch this line. ++
# Installation dependent make variables for riet on Orion.

# full path of the ESPRIT environment
ESPRITDIR = /home1/forfun

#  BDIR     : bin directory
BDIR = $(ESPRITDIR)/bin

#  IDIR     : include directory
IDIR = $(ESPRITDIR)/include

#  LDIR     : library directory
LDIR = $(ESPRITDIR)/lib

FULLDS = $(ESPRITDIR)/ds/fullglass.ds
KERNDS = $(ESPRITDIR)/ds/kernglass.ds

NFULLDS = $(ESPRITDIR)/ds/nfullgl.ds
NKERNDS = $(ESPRITDIR)/ds/nkerngl.ds

#  HOSTNAME : name of installation machine.
HOSTNAME=phoibos

# SYS     : name of operating system or machine type
#     BSD	For generic BSD systems
#     HPUX	For all HP-UX systems
#     SUN	For all SUN systems
#     APOLLO	For all Apollo systems
SYS = SUN

# CLIBLOC : required C libraries
CLIBLOC =

LINTLIBLOC =

PASLIBLOC =

# CBADADR : address that will cause a core-dump if read or written.
CBADADR = 0

SYSLINTFLAGS = -hac
SYSCFLAGS =
SYSCPROFFLAGS =
SYSCDBUGFLAGS =
SYSPFLAGS =

# Collection of host dependent make rules.

### libinstall ###
# MODULE	- module to install
libinstall:
	cp $(MODULE) $(LDIR)/$(MODULE)

### includeinstall ###
# MODULE	- module to install
includeinstall:
	cp $(MODULE) $(IDIR)/$(MODULE)

### maninstall ###
# MAN		- manual page to install
maninstall:
	cp $(MAN) /usr/man/manl

### bininstall ###
# MODULE	- module to install
bininstall:
	cp $(MODULE) $(BDIR)/$(MODULE)
	strip $(BDIR)/$(MODULE)

### arlibinstall ###
# MODULE	- module to install
arlibinstall:
	cp $(MODULE) $(LDIR)/$(MODULE)
	ranlib $(LDIR)/$(MODULE)
#++ make module local end, do NOT touch this line. ++

LINTLIBS =  $(LDIR)/llib-lcvr.ln $(LDIR)/llib-ltmc.ln $(LINTLIBLOC)

# .h files generated from tm modules
TMHDRS	      = tmcode.h 

HDRS	      = tmcode.h \
		uflat2config.h \
		uflat2const.h \
		utils.h

OBJS         = tmcode.o utils.o uflat2.o

# .c files generated from tm modules
TMSRCS        = tmcode.c

SRCS          = uflat2.c tmcode.c utils.c

# distributed tm source files
TMFILES = uflat2config.t tmcode.ct tmcode.ht

# distributed .h files
DISTHDRS      = uflat2config.h \
		uflat2const.h \
		utils.h

# distributed .c files
DISTSRCS      = uflat2.c utils.c

help :
	@echo " Possible make targets:"
	@echo "all		Create local running programs."
	@echo "clean		Free disk space."
	@echo "distfiles	List distribution files."
	@echo "install		Install relevant files."
	@echo "setup		Adapt sources to local situation."
	@echo "test		Run tests."

all	: $(PROGS)

uflat2: $(OBJS)
	$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o uflat2

# make rules for testing
test:

# run program and check output

install:  uflat2 uflat2x
	make bininstall 'MODULE=uflat2'
	cp uflat2x $(BDIR)

clean:
	rm -f $(OBJS) $(TMSRCS) $(TMHDRS) $(JUNK) $(PROGS)

distfiles:
	@echo $(DISTFILES) | tr ' ' '\012'

setup:
	modmake local ../make.local $(MAKEFILE)

# Non-standard make rules

index:
	ctags -wx $(HDRS) $(SRCS)

tags: $(HDRS) $(SRCS)
	ctags $(HDRS) $(SRCS)

depend: $(TMSRCS) $(TMHDRS)
	mkmf -I$(IDIR) -f $(MAKEFILE)

.ht.h:
	$(TM) uflat2.ds $< > $*.h

.ct.c:
	$(TM) uflat2.ds $< > $*.c

lint: $(SRCS) $(HDRS)
	lint $(LINTFLAGS) $(SRCS) $(LINTLIBS) > lint

# Dependencies not detected by 'mkmf'
$(TMHDRS) : uflat2.ds uflat2config.t
$(TMSRCS) : uflat2.ds uflat2config.t
###
uflat2.o: uflat2const.h tmcode.h utils.h
tmcode.o: uflat2config.h tmcode.h uflat2const.h
utils.o: uflat2const.h tmcode.h utils.h
