# Makefile for edefrag, the Linux file system defragmenter
#
# Copyright (C) 1992, 1993 Stephen Tweedie (sct@dcs.ed.ac.uk)
# This file may be distributed under the terms of the GNU
# General Public License. 

CC = gcc
# For 486-specific optimisations:
#CC = gcc -m486

#For the brave...
#CFLAGS = -N -O6 -fomit-frame-pointer -Wall -DNODEBUG
#LDFLAGS = -N -s

#Defaultcompiler options
CFLAGS = -Wall -g
LDFLAGS = -g

PROGS = defrag edefrag

all:	$(PROGS)

defrag:		defrag.o minix.o misc.o buffers.o
	$(CC) $(LDFLAGS) -o $@ $^

edefrag:	edefrag.o ext.o misc.o ebuffers.o
	$(CC) $(LDFLAGS) -o $@ $^

defrag.o:	defrag.c
	$(CC) $(CFLAGS) -DMINIXFS -c -o $@ $<

edefrag.o:	defrag.c
	$(CC) $(CFLAGS) -DEXTFS -c -o $@ $<

buffers.o:	buffers.c
	$(CC) $(CFLAGS) -DMINIXFS -c -o $@ $<

ebuffers.o:	buffers.c
	$(CC) $(CFLAGS) -DEXTFS -c -o $@ $<

minix.o:	minix.c
	$(CC) $(CFLAGS) -DMINIXFS -c -o $@ $<

ext.o:	ext.c
	$(CC) $(CFLAGS) -DEXTFS -c -o $@ $<

clean:
	rm -f $(PROGS) *.o core

spotless: clean
	rm -f *~ .depend
	
tags:
	/usr/emacs/etc/etags *.[ch] README CHANGES INSTALL

PHONY: dep
dep .depend:
	rm -f .depend
# fudge for extfs dependencies
	$(CPP) -M defrag.c | sed "s/defrag.o/edefrag.o/" >> .depend
	$(CPP) -M buffers.c | sed "s/buffers.o/ebuffers.o/" >> .depend
	for i in *.c; do $(CPP) -M $$i; done >> .depend

include .depend
