# Copyright (C) 2008, Bertrand Mesot <http://www.objectif-securite.ch>
#	 	2008, Cedric Tissieres <http://www.objectif-securite.ch>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13, USA

#$Rev: 113 $
#$Date: 2008-04-28 14:52:01 +0200 (Mon, 28 Apr 2008) $

# General variables
SHELL = /bin/sh


top_srcdir = ..
srcdir = .
prefix = /usr/local
exec_prefix = ${prefix}
bindir = $(exec_prefix)/bin
infodir = $(prefix)/info
libdir = $(prefix)/lib/gnudl
mandir = $(prefix)/man/man1

CC = gcc
LIBS = -lm -lpthread  -lssl -lcrypto 
INSTALL = /usr/bin/install -c

CFLAGS  =  -Wall -pedantic -I.. -I/usr/include/openssl -O2 -DNDEBUG -std=gnu9x -I./samdump2
LDFLAGS = -lm -lpthread  -lssl -lcrypto 


all: libophcrack.a
#all: ophcrack

libophcrack.a: list.o misc.o scheduler.o table.o hash.o ophstat.o ophel.o \
	original.o ophtask.o message.o lmtable.o lmgerman.o ntextended.o arg.o \
	ophcrack.o ntdict.o fsm.o
	ar r $@ $^

ophcrack: main.o libophcrack.a samdump2/libsamdump2.a
	$(CC) $^ -o $@ $(LDFLAGS)

# Install target
install: all
	@echo "Creating directories..."
	$(INSTALL) -d $(bindir)
#	$(INSTALL) -d $(mandir)
	@echo "Copying binary..."
	$(INSTALL) ophcrack $(bindir)
#	@echo "Installing man page..."
#	$(INSTALL) ophcrack.1 $(DESTDIR)$(MANDIR)
	@echo ""

# Uninstall target
uninstall: 
	@echo "Deleting binary and manpages..."
	rm -f $(bindir)/ophcrack
#	rm -f $(mandir)/ophcrack.1
	@echo ""

clean:
	rm -f *.o *~
	rm -f ophcrack
	rm -f libophcrack.a

distclean: clean

list.o: list.h list.c
misc.o: misc.h misc.c
scheduler.o: list.h scheduler.h scheduler.c
table.o: misc.h table.h table.c
hash.o: misc.h table.h hash.h hash.c
ophstat.o: ophstat.h ophstat.c
ophel.o: ophstat.h ophel.h ophel.c
ophtask.o: ophtask.h ophtask.c
original.o: original.h original.c
message.o: list.h ophtask.h message.h message.c
lmtable.o: table.h hash.h ophel.h lmtable.h lmtable.c
lmgerman.o: table.h hash.h ophel.h lmgerman.h lmgerman.c
ntextended.o: table.h hash.h ophel.h ntextended.h ntextended.c
ntdict.o: table.h hash.h ophel.h ntdict.h ntdict.c
arg.o: arg.h arg.c
fsm.o: fsm.h fsm.c
ophcrack.o: misc.h list.h scheduler.h table.h hash.h lmtable.h ophel.h \
	ophtask.h message.h original.h ophcrack.h ophcrack.c
main.o: list.h table.h hash.h message.h ophcrack.h gui/main.cpp
	cp gui/main.cpp main.c
	$(CC) $(CFLAGS) -c -o $@ main.c
	rm main.c

