# Makefile for zgv etc.

# set BINDIR to directory for binaries, MANDIR to directory for man page,
# and JPEGDIR to directory where you have the Independant JPEG Group's
# JPEG software (header files are automatically copied from there).
# Note you need the source to the JPEG software, or at least the
# required header files and libjpeg.a!

BINDIR = /usr/bin
MANDIR = /usr/man/man1
JPEGDIR = /usr/src/jpeg

CC = gcc
MAKE = make


# uncomment the -DHANDS_ON... etc. if you want less impressive VC switching
# and effectively no SVGA modes. :)
CFLAGS = -O6 -static #-DHANDS_ON_VC_CODE

LIBSZGV = -lvga -ljpeg
LIBSTNPIC = -ljpeg

all : zgv tnpic

zgv : zgv.o gifeng.o vgadisp.o usejpeg.o font.o 3deffects.o handlevt.o \
  readnbkey.o rcfile.o zgvlogopck.o helppage.o
	$(CC) $(CFLAGS) -o $@ $^ $(LIBSZGV)

munglogo: munglogo.o gifeng.o
	$(CC) -o $@ $^

# texterrors.o gives an alternative msgbox() that just uses printf().
tnpic: tnpic.o gifeng.o usejpeg.o writejpeg.o texterrors.o
	$(CC) $(CFLAGS) -o $@ $^ $(LIBSTNPIC)

tnmungfont: tnmungfont.o
	$(CC) -o $@ $^

install : all
	strip zgv tnpic
	cp zgv tnpic $(BINDIR)
	cp zgv.1 tnpic.1 $(MANDIR)
	chmod a+x $(BINDIR)/{zgv,tnpic}
	chmod +s $(BINDIR)/zgv
	chmod a+r $(MANDIR)/{zgv,tnpic}.1

clean :
	rm -f *.o *~ zgv tnpic tnmungfont munglogo core.*
	rm -f jinclude.h jconfig.h jpegdata.h
	rm -f zgvlogo.h tnpicfont.h

# Dependancies (using 'gcc -MM')
3deffects.o : 3deffects.c 3deffects.h readnbkey.h 
font.o : font.c 
gifeng.o : gifeng.c gifeng.h 42.h 
handlevt.o : handlevt.c 
helppage.o : helppage.c 3deffects.h font.h readnbkey.h handlevt.h 
munglogo.o : munglogo.c gifeng.h 42.h 
rcfile.o : rcfile.c rc_config.h 
readnbkey.o : readnbkey.c readnbkey.h 
texterrors.o : texterrors.c 
tnmungfont.o : tnmungfont.c 
tnpic.o : tnpic.c gifeng.h 42.h usejpeg.h tnpicfont.h 
usejpeg.o : usejpeg.c 3deffects.h jinclude.h jconfig.h jpegdata.h gifeng.h 42.h \
  usejpeg.h 
vgadisp.o : vgadisp.c gifeng.h 42.h usejpeg.h readnbkey.h handlevt.h helppage.h \
  3deffects.h 
writejpeg.o : writejpeg.c jinclude.h jconfig.h jpegdata.h 
zgv.o : zgv.c gifeng.h 42.h vgadisp.h readnbkey.h font.h 3deffects.h handlevt.h \
  helppage.h rc_config.h rcfile.h usejpeg.h zgvlogopck.h 
zgvlogopck.o : zgvlogopck.c zgvlogo.h 

# more involved dependancy stuff
jinclude.h :
	cp $(JPEGDIR)/jinclude.h .
jconfig.h :
	cp $(JPEGDIR)/jconfig.h .
jpegdata.h :
	cp $(JPEGDIR)/jpegdata.h .
zgvlogo.h : munglogo zgvlogo.gif
	./munglogo
tnpicfont.h : tnmungfont tnpicfont.dat
	./tnmungfont
