# This makefile supports all UNIX-like systems.
# Uncomment one of the SYS definitions below, or
# use a make command like:
#	make SYS=esix
# (For compiling on MS-DOS, see make_msc.bat)
# (To compile on Minix, use:  make minix)
#
# Uncomment for ESIX  Sys.V/386 Rel. 3.2
#SYS=esix
#Uncomment for versions of System V/386 Rel. 4 # Saul
#SYS=svr4
# Uncomment below two lines for MSDOS with Manx Aztec C compiler, and code
# optimized for small size
#SYS=aztec
#CFLAGS=+C
# Uncomment for other Sys.V/386 systems (ISC,SCO,Intel...)
#SYS=i386
# Uncomment for MSDOS with UNIX-style make (i.e. ndmake)
#SYS=msdos
# Uncomment for other UNIX-like systems
SYS=unix

# Compilation options:
CC=cc
#CFLAGS=-O
#uncomment above line for normal, optimized, compilation, on Unix systems

FILES1=	README pfdisk.man Changes Makefile pfdisk.c syscodes.c \
 syscodes.h sysdep.h s_esix.c s_i386.c s_unix.c s_msdos.c s_svr4.c s_aztec.c \
 pfdiskaz.c
# Last three entries: Saul
FILES2= bootmenu.doc pfdisk.doc SStor.txt bootmenu.asm bootauto.asm \
 asm2bin.bat make_msc.bat bootmenu.hex bootauto.hex hex2bin.c

OBJS= pfdisk.o syscodes.o s_$(SYS).o
LSRC= pfdisk.c syscodes.c s_$(SYS).c
#For the aztec msdos C compiler, comment above 2 lines, and uncomment 2
#below.  Then enter "make pfdisk.com", or "make pfdisk.exe".
#OBJS= pfdiskaz.o syscodes.o s_$(SYS).o
#LSRC= pfdiskaz.c syscodes.c s_$(SYS).c

#For microsoft C compiler, and Unix-style make, do the same as for Manx Aztec
#C compiler.  Or, easier, simply execute "make_msc.bat", included.

test: pfdisk
	(echo "g 1222 15 34";\
	 echo "1  4   0  127 MS-LOSS";\
	 echo "4 99 128 1221 ESIX";\
	 echo "a 4"; echo l; echo wq \
	) | pfdisk /dev/null

all: pfdisk bootmenu.bin bootauto.bin

pfdisk: $(OBJS)
	$(CC) $(CFLAGS) -o $@ $(OBJS)

pfdisk.exe: $(OBJS)
	ln -o $@ -g $(OBJS) -q -lm -lc

pfdisk.com: $(OBJS)
	ln -o $@ -g $(OBJS) -q -lm -lc

minix: bootmenu.bin bootauto.bin
	$(CC) $(CFLAGS) -o pfdisk $(LSRC)

pfdisk.o : syscodes.h sysdep.h
pfdiskaz.o : syscodes.h sysdep.h
syscodes.o : syscodes.h
s_$(SYS).o : sysdep.h

lint: $(LSRC)
	lint $(CFLAGS) $(LSRC)

bootmenu.bin: hex2bin
	hex2bin <bootmenu.hex >bootmenu.bin
bootauto.bin: hex2bin
	hex2bin <bootauto.hex >bootauto.bin

pfdisk.doc: pfdisk.man
	nroff tmac.an pfdisk.man |col -bh >pfdisk.doc

clean:
	rm -f *.o

Shar1.out: Head1.txt $(FILES1)
	(cat Head1.txt ; shar -v -c $(FILES1)) > $@
Shar2.out: Head2.txt $(FILES2)
	(cat Head2.txt ; shar -v -c $(FILES2)) > $@

