#############################################################################
#
# Module :: Makefile
#
# Author :: Vlad S
#
#   Date :: 2002-04-24
#
# Description :: This Makefile is used for the pure-sfv.
#
# possible targets:
# ''              (compile everything)
# 'test'          (compile and run tests if any)
# 'src'           (build zip with source and support files)
# 'help'          (print some help)
# 'clean'         (removes everything  that was build but the source's and the "Readme"-files)
#
#
#############################################################################
# Revision History ::
#
# YYYY-MM-DD   Developer                  Notes
# ----------   ------------------------   -----------------------------------
# 2002-04-24   VladS@sympatico.ca         Initial template
#
#############################################################################
#
# cvs -dvlads@cvs1:/cvsroot/pure-sfv import -m "Imported sources" pure-sfv psfv start
# cvs -dvlads@cvs1:/cvsroot/pure-sfv co pure-sfv
#

VERSION = 0.3
# for Unix
SEP=/
# for Windows
#SEP=\\

PROG    =   pure-sfv

SRC_TAR_FILE=$(PROG)_$(VERSION)_src.tar

SFV_SRCS  =	crc32.c crc32_file.c crc_struct.c \
            pure-sfv_params.c dir_utils.c \
            sfv_read.c sfv_create.c sfv_test.c \
            sfv_par_interface.c process.c pure-sfv_main.c

PAR_SRCS   = backend.c fileops.c md5.c rs.c \
             checkpar.c makepar.c readoldpar.c rwpar.c

PARS_PATH  =   par-cmdline

SRCS = ${PAR_SRCS:%.c=${PARS_PATH}${SEP}%.c} \
       ${SFV_SRCS}

VC_CRAP = pure-sfv.ncb pure-sfv.plg

CFLAGS +=	-Wall -Werror -O2 -g -Wno-unused
INSTALL_PREFIX = /usr/local
INSTALL_PROGRAM = /usr/bin/install -c

all: pure-sfv

CC = gcc

OBJ = ${SRCS:%.c=%.o}

pure-sfv: $(OBJ)
	$(CC) -lm -DVERSION=\"$(VERSION)\" $(CFLAGS) -o $(PROG) $(OBJ)

PURIFY_OPTIONS=-follow-child-processes=yes -always-use-cache-dir=yes
PURIFY=purify

purify:  $(OBJ)
	${PURIFY} ${PURIFY_OPTIONS} -best-effort $(CC) -lm -DVERSION=\"$(VERSION)\" $(CFLAGS) -o $(PROG) $(OBJ)

install:
	${INSTALL_PROGRAM} $(PROG) ${INSTALL_PREFIX}${SEP}bin

clean:
	rm -f *.o *~ *.core core $(PARS_PATH)${SEP}*.o $(PARS_PATH)${SEP}par $(PROG) $(PROG).exe $(VC_CRAP)
	rm -fr objd
	rm -fr obj

PAR_EXTRA= AUTHORS COPYING Makefile NEWS README rs.doc
PAR_EXTRA_P = ${PAR_EXTRA:%=${PARS_PATH}${SEP}%}

src: clean
	rm -f $(SRC_TAR_FILE).gz
	tar -cvf $(SRC_TAR_FILE) *.c *.h *.sh Makefile
	tar -rvf $(SRC_TAR_FILE) par-cmdline/*.c par-cmdline/*.h
	tar -rvf $(SRC_TAR_FILE) ${PAR_EXTRA_P}
	tar -rvf $(SRC_TAR_FILE) *.bat *.win32 *.dep *.dsp *.dsw *.mak *.txt
	gzip -f $(SRC_TAR_FILE)	


test: pure-sfv
	chmod u+x ./test_pure-sfv.sh
	./test_pure-sfv.sh
