#
# Makefile for the Linux JFS Utilities Library
#

# We will use the GNU C Compiler
CC = gcc

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

# libfs.a is composed of the following objects and source files
OBJS = fssubs.o unicode_to_utf8.o devices.o logform.o utilsubs.o super.o inode.o diskmap.o message.o logredo.o log_work.o log_read.o log_map.o log_dump.o

SRCS = fssubs.c unicode_to_utf8.c devices.c logform.c utilsubs.c super.c inode.c diskmap.c message.c logredo.c log_work.c log_read.c log_map.c log_dump.c

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

# 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_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: libfs.a

# Rule for generating dependency information
dep:
	-rm -f .depend
	$(CC) -MM $(SYMS) $(INCLUDE) $(SRCS) >> .depend

# Rule to delete objects and executables and prepare for a clean build	
clean:
	-rm -f *.o
	-rm -f libfs.a	
	
# Rule for creating the libfs.a archive	
libfs.a : $(OBJS) makefile
	ar crv libfs.a $(OBJS)

-include .depend

