CC=		gcc
CFLAGS=		-g -O -Wall -I..
LDFLAGS=	-g -O
COMPILE_ET=../et/compile_et

ARCHIVE=ar r
RANLIB=ranlib
RM=rm -f
MV=mv
LN=ln -s

OBJS= ext2_err.o openfs.o bitmaps.o inode.o unix_io.o block.o namei.o \
	get_pathname.o bitops.o link.o alloc.o

DISTFILES= Makefile *.c *.h image

.c.o:
	$(CC) $(CFLAGS) -c $*.c
	$(CC) $(CFLAGS) -pg -o profiled/$*.o -c $*.c

all: libext2fs.a libext2fs_p.a

libext2fs.a: $(OBJS)
	$(RM) $@.bak
	-$(MV) $@ $@.bak
	$(ARCHIVE) $@ $(OBJS)
	$(RANLIB) $@
	$(RM) ../$@
	$(LN) ext2fs/$@ ../$@

libext2fs_p.a: $(OBJS)
	$(RM) $@.bak
	-$(MV) $@ $@.bak
	(cd profiled; $(ARCHIVE) ../$@ $(OBJS))
	$(RANLIB) $@
	$(RM) ../$@
	$(LN) ext2fs/$@ ../$@

ext2_err.c ext2_err.h: ext2_err.et
	$(COMPILE_ET) ext2_err.et

clean:
	rm -f \#* *.s *.o *.a *~ *.bak core profiled/*

really-clean: clean
	rm -f .depend ext2_err.c ext2_err.h

dep depend: ext2_err.h
	$(CC) -M $(CFLAGS) *.c >.depend

include .depend
