#              This file is part of the New World OS project
#                 Copyright (C) 2005, 2006  QRW Software
#            J. Scott Edwards - j.scott.edwards.nwos@gmail.com 
#                       http://www.qrwsoftware.com
#                       http://nwos.sourceforge.com
# 
#  NWOS 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, or (at your option) any later version.  This
#  software is distributed with 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 package;  see the file COPYING.  If not, write to:
# 
#       Free Software Foundation, Inc.
#       59 Temple Place - Suite 330
#       Boston, MA 02111-1307, USA.
# 
#  $Log: Makefile,v $
#  Revision 1.2  2006/12/28 01:11:46  jsedwards
#  Added new separate 'log' file.
#
#  Revision 1.1  2006/12/28 01:08:59  jsedwards
#  Initial version to build import_public_csv, big_bang, and special public
#  version of prep_disk.
#

ifeq ($(type),DEBUG)
CFLAGS=-Wall -g -DPUBLIC_MODE
else
CFLAGS=-Wall -O3 -DPUBLIC_MODE
endif

INCLUDES=../objectify.h ../objectify_private.h ../c_structs.h

OBJS=class_definition.o \
     crc32.o \
     date.o \
     language.o \
     log.o \
     name.o \
     number.o \
     objectify.o \
     phone.o \
     reference_list.o \
     spelling.o \
     time_stamp.o \
     us_state.o \
     word.o

#address.o \
#     file.o \
#     person.o \
#     security.o \

PROGS=big_bang \
      import_public_csv \
      prep_disk

all: $(PROGS)

md5c.o:
	$(MAKE) -C ../md5
	cp -p ../md5/md5c.o .

class_definition.o: ${INCLUDES} ../class_definition.c
	gcc ${CFLAGS} -c ../class_definition.c

crc32.o: ../crc32.h ../crc32.c
	gcc ${CFLAGS} -c ../crc32.c

date.o: ${INCLUDES} ../date.c
	gcc ${CFLAGS} -c ../date.c

language.o: ${INCLUDES} ../language.c
	gcc ${CFLAGS} -c ../language.c

log.o: ${INCLUDES} ../log.c
	gcc ${CFLAGS} -c ../log.c

name.o: ${INCLUDES} ../name.c
	gcc ${CFLAGS} -c ../name.c

number.o: ${INCLUDES} ../number.c
	gcc ${CFLAGS} -c ../number.c

objectify.o: ${INCLUDES} ../objectify.c
	gcc ${CFLAGS} -c ../objectify.c

phone.o: ${INCLUDES} ../phone.c
	gcc ${CFLAGS} -c ../phone.c

reference_list.o: ${INCLUDES} ../reference_list.c
	gcc ${CFLAGS} -c ../reference_list.c

spelling.o: ${INCLUDES} ../spelling.c
	gcc ${CFLAGS} -c ../spelling.c

time_stamp.o: ../time_stamp.h ../time_stamp.c
	gcc ${CFLAGS} -c ../time_stamp.c

us_state.o: ${INCLUDES} ../us_state.c
	gcc ${CFLAGS} -c ../us_state.c

word.o: ${INCLUDES} ../word.c
	gcc ${CFLAGS} -c ../word.c


libobjectify.a: $(OBJS) md5c.o
	ar rv libobjectify.a $?


big_bang: libobjectify.a ${INCLUDES} names.h big_bang.c
	gcc ${CFLAGS} -o $@ big_bang.c libobjectify.a -lrt -lcrypto

import_public_csv: libobjectify.a ${INCLUDES} import_public_csv.c
	gcc ${CFLAGS} -o $@ import_public_csv.c libobjectify.a -lrt -lcrypto

prep_disk: libobjectify.a ${INCLUDES} ../prep_disk.c
	gcc ${CFLAGS} -DDONT_COPY_PUBLIC_BLOCKS -o $@ ../prep_disk.c log.o time_stamp.o -lrt

clean:
	rm -f *.o *.a $(PROGS)

clean_all: clean
	$(MAKE) -C ../md5 clean
