# Makefile.gcc - 20:56 GMT +10:00 Wed 18 Aug 93 - Geoffrey Tobin.
# - make dvgt for gcc.
# Tested on Suns and Sparcs running Sun/OS 4.0.3c and Solaris.
# - for dvgt 3.51 (DVItoVDU version 3.0, gt modification 5, revision 1).
# Compile (without optimization) and link dvgt.

# Targets are all, depend, dvgt, tag and clean.

SHELL = /bin/sh
.SUFFIXES: .h

# INC = -I/usr/local/include	# Where stdlib.h lives?
# INC = -I/usr/local/lib/gcc-include	# Where gcc's stdlib.h lives?
# OPT = -O    # Optimise - many compilers get this horribly wrong.

# Compile-time options:
#	-DNOLOG		Supresses all log files
#	-DNOGL		Use plain vga calls instead of gl calls.  If
#			dvgt doesn't work, or complains that it can't
#			find a 256 color mode, try recompiling it with
#			NOGL set on.

CC = gcc
CFLAGS = -ansi -Wall
DEBUG = -g  
DEFN =
INC =
LDFLAGS =  
LIB = -lm -lggi
OPT = -O2 -ffast-math -finline-functions -fomit-frame-pointer 

USUALS = config.h globals.h

# Standard Header dependencies:
#   <ctype.h>
#   <fcntl.h>
#   <math.h>
#   <stddef.h>
#   <stdio.h>
#   <stdlib.h>
#   <strings.h>
#   <time.h>
#   <unistd.h>

objs =  dvireader.o dvitovdu.o fontreader.o lstring.o options.o \
	screenio.o 

termobjs = ggi.o

objects = $(objs) $(termobjs)


srcs =  dvireader.c dvitovdu.c fontreader.c lstring.c options.c \
	screenio.c

termsrcs = ggi.c

CSRCS = $(srcs) $(termsrcs)

all: dview

.c.o:
	$(CC) $(CFLAGS) $(DEBUG) -c $(INC) $(OPT) $(DEFN) $<

install: all
	install -s dview /usr/local/bin
	install dview.1 /usr/local/man/man1

depend: $(CSRCS)
	$(CC) -M $(CSRCS) > makedep
	@echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	@echo '$$r makedep' >>eddep
	@echo 'w' >>eddep
	@cp Makefile Makefile.bak
	ed - Makefile < eddep
	@rm -f eddep makedep
	@echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
	@echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
	@echo '# see make depend above' >> Makefile
	- diff Makefile Makefile.bak
	@rm -f Makefile.bak


dview: $(objects)
	$(CC) $(LDFLAGS) $(DEBUG) $(objects) $(LIB) -o dview
# Only strip when not DEBUG-ging.
#	strip dvgt

clean:
	rm -f dview core *.o *~ *.vlg


# DO NOT DELETE THIS LINE

dvireader.o : dvireader.c \
  $(USUALS) \
  dvireader.h  files.h  fontreader.h  options.h  screenio.h

dvitovdu.o : dvitovdu.c \
  $(USUALS) \
  defaults.h  dvireader.h  fontreader.h  help.h  new.h  options.h \
  screenio.h  vdu.h  version.h

fontreader.o : fontreader.c \
  $(USUALS) \
  dvireader.h  files.h  fontreader.h  lstring.h  new.h  options.h \
  screenio.h  vdu.h

lstring.o : lstring.c \
  lstring.h  new.h

options.o : options.c \
  $(USUALS) \
  options.h  screenio.h  defaults.h

screenio.o : screenio.c \
  $(USUALS) \
  screenio.h  vdu.h

