#
# Makefile for lpdev, lpflush and the corresponding manpages.
# Everything must be compiled with 16-bit integers.
#

CC     = gcc
AS     = gcc-as
ZOO    = zoo

CFLAGS = -mshort -Wall $(OPTIM)
LFLAGS = -mshort -s
OPTIM  = -O2 -fomit-frame-pointer

all: programs manpages

#
# The executables. On Minix partitions we have to set their 'x' bit because
# older versions of the Gcc won't do it automatically. The 'makefast'
# utility sets the fastload bit of the executables; if you don't have it
# you can ignore it, or use 'toglclr' or 'prgflags' instead.
#

OBJ1   = lpdev.o centr.o
LPDEV  = lpdev.ttp

OBJ2   = lpflush.o
LPFLS  = lpflush.ttp

programs: $(LPDEV) $(LPFLS)

$(LPDEV): $(OBJ1)
	$(CC) -o $(LPDEV) $(OBJ1) $(LFLAGS)
	chmod +x $(LPDEV)
	makefast $(LPDEV)

$(LPFLS): $(OBJ2)
	$(CC) -o $(LPFLS) $(OBJ2) $(LFLAGS)
	chmod +x $(LPFLS)
	makefast $(LPFLS)

clean:
	rm -f *.o *.ttp *.asc

#
# Man pages. The .asc files are already provided in the archive, so
# you probably won't need this rules.
#

manpages: lpdev.asc lpflush.asc

lpdev.asc: lpdev.8
	cawf -man -fn lpdev.8 > lpdev.asc

lpflush.asc: lpflush.1
	cawf -man -fn lpflush.1 > lpflush.asc

#
# Dependencies
#

lpdev.o : lpdev.c lpdev.h filesys.h atarierr.h
centr.o : centr.s
lpflush.o: lpflush.c lpdev.h filesys.h atarierr.h

#
# Archiving
#

SOURCES = \
	atarierr.h filesys.h COPYING \
	Makefile README lpdev.8 lpflush.1 \
	centr.s lpdev.h lpdev.c lpflush.c

OTHER_FILES = \
	$(LPDEV) lpdev.asc \
	$(LPFLS) lpflush.asc

ARCHIVE_DIR = /h/Archives

archive:
	$(ZOO) aunhP: Lpdev $(SOURCES) $(OTHER_FILES)
	cp -a Lpdev.zoo $(ARCHIVE_DIR)
