#       Makefile for Mtools
#

prefix      = /usr
exec_prefix = ${prefix}
bindir      = ${exec_prefix}/bin
mandir      = ${prefix}/man
man1dir      = ${prefix}/man/man1
man5dir      = ${prefix}/man/man5

CFLAGS   = -D_MINIX -DFCNTL -DNO_CONFIG $(OPT)
LDFLAGS  = -fnone

OBJS1 =	buffer.o codepage.o codepages.o config.o \
	copyfile.o devices.o directory.o expand.o fat.o fat_free.o \
	file.o file_name.o file_read.o filter.o force_io.o hash.o init.o \
	match.o mattrib.o mbadblocks.o mcd.o mcopy.o mdel.o mdir.o \
	mformat.o misc.o missing_functions.o mk_direntry.o mlabel.o \
	mmd.o mmount.o mmove.o mtools.o parse.o plain_io.o signal.o \
	stream.o streamcache.o subdir.o toupper.o vfat.o xdf_io.o

OBJS2 = missing_functions.o mkmanifest.o

all:    mtools mkmanifest

mtools: $(OBJS1)
	rm -f mtools.a
	$(CC) -c.a -o mtools.a $(OBJS1)
	$(CC) $(LDFLAGS) -o $@ mtools.a

mkmanifest: $(OBJS2)
	$(CC) $(LDFLAGS) -o $@ $(OBJS2)

clean:
	rm -f *~ *.orig *.[oa] a.out core mtools mkmanifest

INSTALL = \
	$(bindir)/mattrib $(bindir)/mcd $(bindir)/mcopy $(bindir)/mdel \
	$(bindir)/mdeltree $(bindir)/mdir $(bindir)/mformat \
	$(bindir)/mlabel $(bindir)/mmd $(bindir)/mmove $(bindir)/mrd \
	$(bindir)/mren $(bindir)/mtype $(bindir)/mkmanifest \
	$(man1dir)/mattrib.1 $(man1dir)/mcd.1 \
	$(man1dir)/mcopy.1 $(man1dir)/mdel.1 $(man1dir)/mdeltree.1 \
	$(man1dir)/mdir.1 $(man1dir)/mformat.1 $(man1dir)/mkmanifest.1 \
	$(man1dir)/mlabel.1 $(man1dir)/mmd.1 $(man1dir)/mmove.1 \
	$(man1dir)/mrd.1 $(man1dir)/mren.1 $(man1dir)/mtools.1 \
	$(man1dir)/mtype.1

install:	$(INSTALL)

$(bindir)/mattrib:	mtools
	install -lc $? $@

$(bindir)/mcd $(bindir)/mcopy $(bindir)/mdel $(bindir)/mdeltree \
$(bindir)/mdir $(bindir)/mformat $(bindir)/mlabel $(bindir)/mmd \
$(bindir)/mmove $(bindir)/mrd $(bindir)/mren \
$(bindir)/mtype:	$(bindir)/mattrib
	install -l $? $@

$(bindir)/mkmanifest:	mkmanifest
	install -lc $? $@

$(man1dir)/mattrib.1:	mattrib.1
	install -lc $? $@

$(man1dir)/mcd.1:	mcd.1
	install -lc $? $@

$(man1dir)/mcopy.1:	mcopy.1
	install -lc $? $@

$(man1dir)/mdel.1:	mdel.1
	install -lc $? $@

$(man1dir)/mdeltree.1:	mdeltree.1
	install -lc $? $@

$(man1dir)/mdir.1:	mdir.1
	install -lc $? $@

$(man1dir)/mformat.1:	mformat.1
	install -lc $? $@

$(man1dir)/mkmanifest.1:	mkmanifest.1
	install -lc $? $@

$(man1dir)/mlabel.1:	mlabel.1
	install -lc $? $@

$(man1dir)/mmd.1:	mmd.1
	install -lc $? $@

$(man1dir)/mmove.1:	mmove.1
	install -lc $? $@

$(man1dir)/mrd.1:	mrd.1
	install -lc $? $@

$(man1dir)/mren.1:	mren.1
	install -lc $? $@

$(man1dir)/mtools.1:	mtools.1
	install -lc $? $@

$(man1dir)/mtype.1:	mtype.1
	install -lc $? $@

uninstall:	clean
	rm -f $(INSTALL)

# Dependencies.

buffer.o:	buffer.c
buffer.o:	buffer.h
buffer.o:	config.h
buffer.o:	msdos.h
buffer.o:	mtools.h
buffer.o:	stream.h
buffer.o:	sysincludes.h

codepage.o:	codepage.c
codepage.o:	codepage.h
codepage.o:	config.h
codepage.o:	msdos.h
codepage.o:	mtools.h
codepage.o:	stream.h
codepage.o:	sysincludes.h

codepages.o:	codepage.h
codepages.o:	codepages.c

config.o:	codepage.h
config.o:	config.c
config.o:	config.h
config.o:	msdos.h
config.o:	mtools.h
config.o:	stream.h
config.o:	sysincludes.h

copyfile.o:	config.h
copyfile.o:	copyfile.c
copyfile.o:	file.h
copyfile.o:	msdos.h
copyfile.o:	mtools.h
copyfile.o:	stream.h
copyfile.o:	sysincludes.h

devices.o:	config.h
devices.o:	devices.c
devices.o:	msdos.h
devices.o:	mtools.h
devices.o:	stream.h
devices.o:	sysincludes.h

directory.o:	config.h
directory.o:	directory.c
directory.o:	file.h
directory.o:	fs.h
directory.o:	msdos.h
directory.o:	mtools.h
directory.o:	stream.h
directory.o:	sysincludes.h
directory.o:	vfat.h

expand.o:	config.h
expand.o:	expand.c
expand.o:	sysincludes.h

fat.o:	config.h
fat.o:	fat.c
fat.o:	fs.h
fat.o:	fsP.h
fat.o:	msdos.h
fat.o:	mtools.h
fat.o:	stream.h
fat.o:	sysincludes.h

fat_free.o:	config.h
fat_free.o:	fat_free.c
fat_free.o:	fs.h
fat_free.o:	fsP.h
fat_free.o:	msdos.h
fat_free.o:	mtools.h
fat_free.o:	stream.h
fat_free.o:	sysincludes.h

file.o:	config.h
file.o:	file.c
file.o:	file.h
file.o:	fs.h
file.o:	fsP.h
file.o:	htable.h
file.o:	msdos.h
file.o:	mtools.h
file.o:	stream.h
file.o:	sysincludes.h

file_name.o:	codepage.h
file_name.o:	config.h
file_name.o:	file_name.c
file_name.o:	msdos.h
file_name.o:	mtools.h
file_name.o:	stream.h
file_name.o:	sysincludes.h
file_name.o:	vfat.h

file_read.o:	config.h
file_read.o:	file.h
file_read.o:	file_read.c
file_read.o:	msdos.h
file_read.o:	mtools.h
file_read.o:	stream.h
file_read.o:	sysincludes.h

filter.o:	config.h
filter.o:	filter.c
filter.o:	msdos.h
filter.o:	mtools.h
filter.o:	stream.h
filter.o:	sysincludes.h

force_io.o:	config.h
force_io.o:	force_io.c
force_io.o:	msdos.h
force_io.o:	mtools.h
force_io.o:	stream.h
force_io.o:	sysincludes.h

hash.o:	config.h
hash.o:	hash.c
hash.o:	htable.h
hash.o:	msdos.h
hash.o:	mtools.h
hash.o:	stream.h
hash.o:	sysincludes.h

init.o:	buffer.h
init.o:	config.h
init.o:	fs.h
init.o:	fsP.h
init.o:	init.c
init.o:	msdos.h
init.o:	mtools.h
init.o:	plain_io.h
init.o:	stream.h
init.o:	sysincludes.h
init.o:	xdf_io.h

match.o:	config.h
match.o:	match.c
match.o:	msdos.h
match.o:	mtools.h
match.o:	stream.h
match.o:	sysincludes.h

mattrib.o:	config.h
mattrib.o:	mattrib.c
mattrib.o:	msdos.h
mattrib.o:	mtools.h
mattrib.o:	stream.h
mattrib.o:	streamcache.h
mattrib.o:	sysincludes.h
mattrib.o:	vfat.h

mbadblocks.o:	config.h
mbadblocks.o:	fs.h
mbadblocks.o:	fsP.h
mbadblocks.o:	mbadblocks.c
mbadblocks.o:	msdos.h
mbadblocks.o:	mtools.h
mbadblocks.o:	stream.h
mbadblocks.o:	streamcache.h
mbadblocks.o:	sysincludes.h
mbadblocks.o:	vfat.h

mcd.o:	config.h
mcd.o:	mcd.c
mcd.o:	msdos.h
mcd.o:	mtools.h
mcd.o:	stream.h
mcd.o:	streamcache.h
mcd.o:	sysincludes.h
mcd.o:	vfat.h

mcopy.o:	config.h
mcopy.o:	file.h
mcopy.o:	fs.h
mcopy.o:	mcopy.c
mcopy.o:	msdos.h
mcopy.o:	mtools.h
mcopy.o:	nameclash.h
mcopy.o:	plain_io.h
mcopy.o:	stream.h
mcopy.o:	streamcache.h
mcopy.o:	sysincludes.h
mcopy.o:	vfat.h

mdel.o:	config.h
mdel.o:	file.h
mdel.o:	fs.h
mdel.o:	mdel.c
mdel.o:	msdos.h
mdel.o:	mtools.h
mdel.o:	stream.h
mdel.o:	streamcache.h
mdel.o:	sysincludes.h
mdel.o:	vfat.h

mdir.o:	codepage.h
mdir.o:	config.h
mdir.o:	file.h
mdir.o:	fs.h
mdir.o:	mdir.c
mdir.o:	msdos.h
mdir.o:	mtools.h
mdir.o:	stream.h
mdir.o:	streamcache.h
mdir.o:	sysincludes.h
mdir.o:	vfat.h

mformat.o:	buffer.h
mformat.o:	config.h
mformat.o:	file.h
mformat.o:	fs.h
mformat.o:	fsP.h
mformat.o:	mformat.c
mformat.o:	msdos.h
mformat.o:	mtools.h
mformat.o:	nameclash.h
mformat.o:	plain_io.h
mformat.o:	stream.h
mformat.o:	streamcache.h
mformat.o:	sysincludes.h
mformat.o:	vfat.h

misc.o:	config.h
misc.o:	misc.c
misc.o:	msdos.h
misc.o:	mtools.h
misc.o:	stream.h
misc.o:	sysincludes.h
misc.o:	vfat.h

missing_functions.o:	config.h
missing_functions.o:	missing_functions.c
missing_functions.o:	sysincludes.h

mk_direntry.o:	config.h
mk_direntry.o:	fs.h
mk_direntry.o:	mk_direntry.c
mk_direntry.o:	msdos.h
mk_direntry.o:	mtools.h
mk_direntry.o:	nameclash.h
mk_direntry.o:	stream.h
mk_direntry.o:	sysincludes.h
mk_direntry.o:	vfat.h

mkmanifest.o:	config.h
mkmanifest.o:	mkmanifest.c
mkmanifest.o:	msdos.h
mkmanifest.o:	sysincludes.h

mlabel.o:	config.h
mlabel.o:	mlabel.c
mlabel.o:	msdos.h
mlabel.o:	mtools.h
mlabel.o:	nameclash.h
mlabel.o:	stream.h
mlabel.o:	streamcache.h
mlabel.o:	sysincludes.h
mlabel.o:	vfat.h

mmd.o:	config.h
mmd.o:	file.h
mmd.o:	fs.h
mmd.o:	mmd.c
mmd.o:	msdos.h
mmd.o:	mtools.h
mmd.o:	nameclash.h
mmd.o:	plain_io.h
mmd.o:	stream.h
mmd.o:	streamcache.h
mmd.o:	sysincludes.h
mmd.o:	vfat.h

mmount.o:	config.h
mmount.o:	mmount.c
mmount.o:	msdos.h
mmount.o:	mtools.h
mmount.o:	stream.h
mmount.o:	sysincludes.h

mmove.o:	config.h
mmove.o:	file.h
mmove.o:	fs.h
mmove.o:	mmove.c
mmove.o:	msdos.h
mmove.o:	mtools.h
mmove.o:	nameclash.h
mmove.o:	plain_io.h
mmove.o:	stream.h
mmove.o:	streamcache.h
mmove.o:	sysincludes.h
mmove.o:	vfat.h

mtools.o:	config.h
mtools.o:	msdos.h
mtools.o:	mtools.c
mtools.o:	mtools.h
mtools.o:	stream.h
mtools.o:	sysincludes.h

parse.o:	config.h
parse.o:	msdos.h
parse.o:	mtools.h
parse.o:	parse.c
parse.o:	stream.h
parse.o:	sysincludes.h
parse.o:	vfat.h

plain_io.o:	config.h
plain_io.o:	msdos.h
plain_io.o:	mtools.h
plain_io.o:	plain_io.c
plain_io.o:	plain_io.h
plain_io.o:	stream.h
plain_io.o:	sysincludes.h

signal.o:	config.h
signal.o:	msdos.h
signal.o:	mtools.h
signal.o:	signal.c
signal.o:	stream.h
signal.o:	sysincludes.h

stream.o:	config.h
stream.o:	msdos.h
stream.o:	mtools.h
stream.o:	stream.c
stream.o:	stream.h
stream.o:	sysincludes.h

streamcache.o:	config.h
streamcache.o:	fs.h
streamcache.o:	msdos.h
streamcache.o:	mtools.h
streamcache.o:	plain_io.h
streamcache.o:	stream.h
streamcache.o:	streamcache.c
streamcache.o:	streamcache.h
streamcache.o:	sysincludes.h
streamcache.o:	vfat.h

strerror.o:	config.h
strerror.o:	strerror.c
strerror.o:	sysincludes.h

subdir.o:	buffer.h
subdir.o:	config.h
subdir.o:	file.h
subdir.o:	msdos.h
subdir.o:	mtools.h
subdir.o:	stream.h
subdir.o:	subdir.c
subdir.o:	sysincludes.h
subdir.o:	vfat.h

toupper.o:	codepage.h
toupper.o:	toupper.c

vfat.o:	config.h
vfat.o:	file.h
vfat.o:	msdos.h
vfat.o:	mtools.h
vfat.o:	stream.h
vfat.o:	sysincludes.h
vfat.o:	vfat.c
vfat.o:	vfat.h

xdf_io.o:	config.h
xdf_io.o:	sysincludes.h
xdf_io.o:	xdf_io.c
