CC_COMP = gcc
CC_OPTS = -Wall -O3 -static
GOAL = foremost

# You shouldn't need to change anything below this line
#---------------------------------------------------------------------

# Used when creating the foremost package. Don't forget to update!
VERSION = 0.62

# Where foremost gets installed
BIN = /usr/local/bin
MAN = /usr/local/man/man1

# This should be commented out when debugging is done
#CC_OPTS += -DDEBUG

# Generic "how to compile C files"
CC = $(CC_COMP) $(CC_OPTS)
.c.o: 
	$(CC) -c $<

# Definitions we'll need later (and that should never change)
HEADER_FILES = foremost.h
SRC =  helpers.c files.c foremost.c 
OBJS =  helpers.o foremost.o files.o


all: $(GOAL) 
	
foremost: $(OBJS) 
	$(CC) -o $(GOAL) $(OBJS)

install: all
	install -CDm 755 $(GOAL)   $(BIN)/$(GOAL)
	install -CDm 644 $(GOAL).1 $(MAN)/$(GOAL).1

uninstall:
	rm -f $(BIN)/$(GOAL) $(MAN)/$(GOAL).1

foremost.o: foremost.c $(HEADER_FILES)
helpers.o: helpers.c $(HEADER_FILES)
files.o: files.c $(HEADER_FILES)

# This is used for debugging
preflight:
	grep -n RBF *.h *.c

nice:
	rm -f *~

clean: nice
	rm -f $(OBJS) $(GOAL) core *.core

#-------------------------------------------------------------------------

DEST_DIR = $(GOAL)-$(VERSION)
TAR_FILE = $(DEST_DIR).tar
DOCS = CHANGES LICENSE TODO README
PKG_FILES = $(SRC) $(HEADER_FILES) foremost.conf foremost.1 Makefile $(DOCS)

# This packages me up to send to somebody else
package:
	rm -f $(TAR_FILE) $(TAR_FILE).gz
	mkdir $(DEST_DIR)
	cp $(PKG_FILES) $(DEST_DIR)
	tar cvf $(TAR_FILE) $(DEST_DIR)
	rm -rf $(DEST_DIR)
	gzip $(TAR_FILE)



