# Makefile for the NT filesystem user part
#
# Copyright (C) 1999 Christophe GRENIER
# Copyright (C) 1997-99 Rgis Duchesne
#
# Note : Do 'make clean_makespace' each time you modify this Makefile.

# Does anybody know how to include dependancies in a portable way?

# Files
#  Programs to build
PRG = ../ntdir ../ntcp ../ntchange ../ntdump ../ntcat ../ntgrep ../ntmkdir
#  Programs
CC      = gcc
INSTALL = /bin/install -c

# Compilation flags
#  To reach config.h
CFLAGS  = -I..
#  To reach the common stuff
CFLAGS += -I../common -I../user -I../dos
#  Warnings
CFLAGS += -Wall -Wstrict-prototypes
#  Debug option
#CFLAGS += -g
CFLAGS += -s
#  Flags from 'configure'
CFLAGS += -O2 -fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DHAVE_CONFIG_H -fomit-frame-pointer
LFLAGS = -s
all: force $(PRG)

# Note : Solaris 'make' doesn't support the $^ variable
DEP_NTDIR = ntdir.o support.o ../common/util.o ../dos/readdisk.o ../dos/hdaccess.o nttools.o  ../common/dir.o ../common/inode.o ../common/super.o ../common/attr.o ../dos/fnctdsk.o
../ntdir: $(DEP_NTDIR)
	$(CC) $(LFLAGS) -o $@ $(DEP_NTDIR)

DEP_NTDUMP = ntdump.o dump.o support.o ../common/util.o ../dos/readdisk.o ../dos/hdaccess.o nttools.o ../common/dir.o ../common/inode.o ../common/super.o ../common/attr.o ../dos/fnctdsk.o
../ntdump: $(DEP_NTDUMP)
	$(CC) $(LFLAGS) -o $@ $(DEP_NTDUMP)

DEP_NTGREP = ntgrep.o dump.o support.o ../common/util.o ../dos/readdisk.o ../dos/hdaccess.o nttools.o ../common/dir.o ../common/inode.o ../common/super.o ../common/attr.o ../dos/fnctdsk.o
../ntgrep: $(DEP_NTGREP)
	$(CC) $(LFLAGS) -o $@ $(DEP_NTGREP)

DEP_NTCAT = ntcat.o support.o ../common/util.o ../dos/readdisk.o ../dos/hdaccess.o nttools.o ../common/dir.o ../common/inode.o ../common/super.o ../common/attr.o ../dos/fnctdsk.o
../ntcat: $(DEP_NTCAT)
	$(CC) $(LFLAGS) -o $@ $(DEP_NTCAT)

DEP_NTCHANGE = ntchange.o support.o ../common/util.o ../dos/readdisk.o ../dos/hdaccess.o nttools.o ../common/dir.o ../common/inode.o ../common/super.o ../common/attr.o ../dos/fnctdsk.o
../ntchange: $(DEP_NTCHANGE)
	$(CC) $(LFLAGS) -o $@ $(DEP_NTCHANGE)

DEP_NTCP = ntcp.o support.o ../common/util.o ../dos/readdisk.o ../dos/hdaccess.o nttools.o ../common/dir.o ../common/inode.o ../common/super.o ../common/attr.o ../dos/fnctdsk.o
../ntcp: $(DEP_NTCP)
	$(CC) $(LFLAGS) -o $@ $(DEP_NTCP)

DEP_NTMKDIR = ntmkdir.o support.o util.o nttools.o dir.o inode.o super.o attr.o ../dos/readdisk.o ../dos/hdaccess.o  ../dos/fnctdsk.o
../ntmkdir: $(DEP_NTMKDIR)
	$(CC) $(LFLAGS) -o $@ $(DEP_NTMKDIR)

attr.o:	../common/attr.c
	$(CC) $(CFLAGS) -c $< -o $@
dir.o:	../common/dir.c
	$(CC) $(CFLAGS) -c $< -o $@
inode.o:	../common/inode.c
	$(CC) $(CFLAGS) -c $< -o $@
super.o:	../common/super.c
	$(CC) $(CFLAGS) -c $< -o $@
util.o:		../common/util.c
	$(CC) $(CFLAGS) -c $< -o $@
readdisk.o: ../dos/readdisk.c
	$(CC) $(CFLAGS) -c $< -o $@

# Put the tree in its scratch state
clean: force clean_workspace clean_makespace

# Remove work files from the work space
clean_workspace: force
	@rm -f core *~; \
	echo User workspace is now clean

# Remove files created by this Makefile
clean_makespace: force
	@rm -rf $(DDIR) *.o $(PRG); \
	echo User makespace is now clean

# Install the binaries
install: force all
	$(INSTALL) -d /usr/local/bin; \
	$(INSTALL) $(PRG) /usr/local/bin

# This target doesn't generate a 'force' file. A target 'foo' depending on
# 'force' is therefore forced to be updated, even if a 'foo' file exists
force:
