# $Id: Makefile.in,v 1.8 2021/09/28 13:05:08 nia Exp $


SHELL = /bin/sh


PACKAGE_NAME= nbsd-digest
PACKAGE_VERSION= 20220214

srcdir = .

prefix = /2024Q1
exec_prefix = ${prefix}

bindir = ${exec_prefix}/bin
mandir = /2024Q1/man
top_builddir = .

AUTOCONF = ./missing --run autoconf
AUTOHEADER = ./missing --run autoheader
mkinstalldirs = $(SHELL) $(srcdir)/mkinstalldirs
install_sh = $(SHELL) $(srcdir)/install-sh

INSTALL = /bin/install -c -o root -g root
INSTALL_PROGRAM = /bin/install -c -s -o root -g root -m 755
INSTALL_DATA = /bin/install -c -o root -g root -m 644
INSTALL_SCRIPT = /bin/install -c -o root -g root -m 755
INSTALL_HEADER = $(INSTALL_DATA)
transform = s,x,x,
host_alias = x86_64-unknown-linux
host_triplet = x86_64-unknown-linux-gnu
CANONICAL_HOST = x86_64-unknown-linux-gnu

CC = cc
CCLD= $(CC)
LIBS= 
CPPFLAGS= 
DEFS= -DHAVE_CONFIG_H -I. -I. -DHOST=\"$(CANONICAL_HOST)\" -DVERSION=\"$(PACKAGE_VERSION)\"
CFLAGS= -O2
LDFLAGS= -Wl,-zrelro -Wl,-R/2024Q1/lib

LINK= $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@
COMPILE= $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS)

digest_OBJS = digest.o keccak.o md5c.o md5hl.o rmd160.o \
rmd160hl.o sha1.o sha1hl.o sha2.o sha2hl.o sha3.o sha3hl.o \
tiger.o whirlpool.o blake2b.o blake2b-hl.o blake2s.o blake2s-hl.o

SRCS= digest.c keccak.c md5c.c md5hl.c rmd160.c \
rmd160hl.c sha1.c sha1hl.c sha2.c sha2hl.c sha3.c sha3hl.c \
tiger.c whirlpool.c blake2b.c blake2b-hl.c \
md5.h rmd160.h sha1.h sha2.h sha3.h tiger.h whirlpool.h blake2.h

DISTFILES= $(SRCS) AUTHORS COPYING DESCR INSTALL Makefile.in NEWS aclocal.m4 \
config.guess config.h.in config.sub configure configure.ac install-sh \
missing mkinstalldirs regress.sh

.c.o:
	$(COMPILE) -c $< -o $@

all: digest

digest: $(digest_OBJS)
	$(LINK) $(digest_OBJS) $(LIBS)

check: digest
	/bin/sh $(srcdir)/regress.sh

clean:
	rm -f *.o digest

distclean: clean
	rm -f Makefile config.h
	rm -f config.status config.cache config.log

maintainer-clean: distclean
	rm -f configure config.h.in

install: digest
	$(mkinstalldirs) $(DESTDIR)$(bindir)
	@f=`echo digest|sed '$(transform)'`; \
	echo "$(INSTALL_PROGRAM) digest $(DESTDIR)$(bindir)/$$f"; \
	$(INSTALL_PROGRAM) digest $(DESTDIR)$(bindir)/$$f
	$(mkinstalldirs) $(DESTDIR)$(mandir)/man1
	@f=`echo digest.1|sed '$(transform)'`; \
	echo "$(INSTALL_DATA) digest.1 $(DESTDIR)$(mandir)/man1/$$f"; \
	$(INSTALL_DATA) digest.1 $(DESTDIR)$(mandir)/man1/$$f

uninstall:
	@f=`echo digest|sed '$(transform)'`; \
	echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
	rm -f $(DESTDIR)$(bindir)/$$f

GZIP_ENV= --best
TAR= tar
distdir= $(PACKAGE_NAME)-$(PACKAGE_VERSION)

distdir: $(DISTFILES)
	-chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
	mkdir $(distdir)
	@for file in $(DISTFILES); do \
		if test -f $$file; then d=.; else d=$(srcdir); fi; \
		dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
		if test "$$dir" != "$$file" && test "$$dir" != "."; then \
			$(mkinstalldirs) "$(distdir)/$$dir"; \
		fi; \
		if test -d $$d/$$file; then \
			cp -pR $$d/$$file $(distdir) \
			|| exit 1; \
		else \
			test -f $(distdir)/$$file \
			|| cp -p $$d/$$file $(distdir)/$$file \
			|| exit 1; \
		fi; \
	done
	-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
	  ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
	|| chmod -R a+r $(distdir)

dist: distdir
	$(TAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
	-chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)

distcheck: dist
	-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
	GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(TAR) xf -
	chmod -R a-w $(distdir); chmod a+w $(distdir)
	mkdir $(distdir)/=build
	mkdir $(distdir)/=inst
	chmod a-w $(distdir)
	dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \
	  && cd $(distdir)/=build \
	  && ../configure --srcdir=.. --prefix=$$dc_install_base \
	  && $(MAKE) \
	  && $(MAKE) check \
	  && $(MAKE) install \
	  && $(MAKE) uninstall \
	  && (test `find $$dc_install_base -type f -print | wc -l` -le 1 \
	     || (echo "Error: files left after uninstall" 1>&2; \
	         exit 1) ) \
	  && $(MAKE) dist \
	  && $(MAKE) distclean \
	  && rm -f $(distdir).tar.gz \
	  && (test `find . -type f -print | wc -l` -eq 0 \
	     || (echo "Error: files left after distclean" 1>&2; \
	         exit 1) )
	-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
	@echo "$(distdir).tar.gz is ready for distribution" | \
	  sed 'h;s/./=/g;p;x;p;x'
