#
# Makefile for project fdf
#
# Written by Tormod Tjaberg 
# 
CC=gcc
CFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 
DEFS=							    
LD=gcc 
EXE=fdf

OBJS = fdf.o fdf_core.o fdf_rm.o rmdir.o arg_func.o crc32.o fsa.o scandir.o rb_funcs.o rbtree.o pacifier.o lltoa.o gmatch.o gmatch_i.o pagesize.o

$(EXE): $(OBJS)
	$(LD) $(OBJS) -o $@ 

fdf.o: fdf.c arg_func.h rbtree.h scandir.h fsa.h fdf.h
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@

fdf_core.o: fdf_core.c rbtree.h fdf.h
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@

fdf_rm.o: fdf_rm.c fdf.h
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@

rmdir.o: rmdir.c 
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@

scandir.o: scandir.c scandir.h
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@

fsa.o: fsa.c fsa.h
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@

arg_func.o: arg_func.c arg_func.h
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@

rb_funcs.o: rb_funcs.c  rbtree.h fsa.h fdf.h
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@

crc32.o: crc32.c fsa.h fdf.h
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@

rbtree.o: rbtree.c rbtree.h
	$(CC) $(DEFS) $(CFLAGS) $< -c -o $@
       
pacifier.o: pacifier.c
	$(CC) $(CFLAGS) $< -c -o $@

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

gmatch.o: gmatch.c
	$(CC) $(CFLAGS) $< -c -o $@
        
gmatch_i.o: gmatch.c 
	$(CC) -DGLOBMATCH_I $(CFLAGS) $< -c -o $@
	
pagesize.o: pagesize.c 
	$(CC) -DGLOBMATCH_I $(CFLAGS) $< -c -o $@

clean:
	rm *.o || rm fdf.exe || rm fdf

strip:
	strip fdf.exe || strip fdf

