#
# Makefile for the Linux JFS fsck utility
#

# We will use the GNU C Compiler
CC = gcc

# The source code and its dependencies can be found in the following path
VPATH = .:../libfs:../../../../include/linux/jfs

# fsck.jfs is composed of the following objects and source files
OBJS = fsckbmap.o fsckconn.o fsckdire.o fsckdtre.o fsckea.o fsckimap.o fsckino.o fsckmeta.o fsckmsgs.o fsckpfs.o fsckwsp.o fsckxtre.o xchkdsk.o fsckruns.o

SRCS =  fsckbmap.c fsckconn.c fsckdire.c fsckdtre.c fsckea.c fsckimap.c fsckino.c fsckmeta.c fsckmsgs.c fsckpfs.c fsckwsp.c fsckxtre.c xchkdsk.c fsckruns.c

# The following paths should be searched for header files
INCLUDE = -I../../../../include/linux/jfs -I../libfs -I.

# Comment out the following line for retail (non-debug) level builds.
DEBUG = 1

# Compiler Flags to use
ifndef DEBUG
  CFLAGS = -O2 -c -static -Wall
else
  CFLAGS = -ggdb -Wall -c
endif

# Symbols that must be defined for proper compilation
SYMS = -D_REENTRANT -D_LINUX -D_GNU_SOURCE -D_JFS_UTILITY -DONE_FILESET_PER_AGGR -D_FILE_OFFSET_BITS=64

# Default compilation rule
.c.o:
	$(CC) $(CFLAGS) $(SYMS) $(INCLUDE) $< -o $@

# Rule for building everything
all: fsck.jfs

# Rule for cleaning up
clean:
	-rm -f *.o
	-rm -f fsck.jfs

# Rule for generating dependency information
dep:
	-rm -f .depend
	$(CC) -MM $(SYMS) $(INCLUDE) $(SRCS) >> .depend
	
# Rule for creating the fsck.jfs	
fsck.jfs : $(OBJS) makefile
	$(CC) -lpthread -o fsck.jfs $(OBJS) ../libfs/libfs.a

-include .depend

