#
#			VISUEL HEXDIFF
#			--------------
#
#	old site : http://tboudet.free.fr/hexdiff/
#
#	https://git.tetalab.org/tTh/KlugyTools/src/branch/main/Hexdiff
#

OU_LE_METTRE = /usr/local
VERSION=0.0.51

TARNAME="hexdiff-$(VERSION).tar.gz"

all:	hexdiff 

#
#	if you define TRACE to a non zero value, you get a 
#	lot of debugging trace on _stderr_
#

COMP=gcc
COPT=-g -DVERSION=\"$(VERSION)\" -DTRACE=0  -ansi
LOPT=-lncurses 

hexdiff.o:	hexdiff.c Makefile hexdiff.h
	$(COMP) $(COPT) -Wall -O2 -c hexdiff.c

fonctions.o:	fonctions.c Makefile hexdiff.h
	$(COMP) $(COPT) -Wall -O2 -c fonctions.c

parse_rc.o:	parse_rc.c Makefile hexdiff.h
	$(COMP) $(COPT) -Wall -O2 -c parse_rc.c

fileinfo.o:	fileinfo.c Makefile hexdiff.h
	$(COMP) $(COPT) -Wall -O2 -c fileinfo.c

sel_file.o:	sel_file.c Makefile hexdiff.h
	$(COMP) $(COPT) -Wall -O2 -c sel_file.c

asciiview.o:	asciiview.c Makefile hexdiff.h
	$(COMP) $(COPT) -Wall -O2 -c asciiview.c

OBJECTS=hexdiff.o fonctions.o fileinfo.o parse_rc.o sel_file.o \
	asciiview.o

hexdiff:	Makefile $(OBJECTS)
	$(COMP) $(OBJECTS) -o $@ $(LOPT)

#
#	this install procedure is very crude.
#
install:	
	cp hexdiff hexdiff.install
	strip hexdiff.install
	mv hexdiff.install $(OU_LE_METTRE)/bin/hexdiff
	cp hexdiff.1 $(OU_LE_METTRE)/man/man1/hexdiff.1
	@echo "you can copy hexdiff.rc in your HOME as .hexdiffrc"

FILES=hexdiff.c hexdiff.1 Makefile README TODO BUGS fonctions.c CHANGES \
	  hexdiff.h  parse_rc.c hexdiff.rc fileinfo.c sel_file.c \
	  asciiview.c memcheck.sh

tarball:  $(FILES)
	@echo $(TARNAME)
	ls $^ > MANIFEST ; \
	( cd .. ; \
	tar zcvf $(TARNAME) `sed 's/^/HexDiff\//' HexDiff/MANIFEST` )
	date >> tarball

lines:	$(FILES)
	wc $(FILES) | sort -n