#
# This file is part of John the Ripper password cracker,
# Copyright (c) 1996-2015,2019 by Solar Designer
#
# ...with changes in the jumbo patch, by various authors
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted.
#
# There's ABSOLUTELY NO WARRANTY, express or implied.
#

CC = gcc
CXX = g++
AS = $(CC)
LD = $(CC)
CPP = $(CC)
CP = cp
CP_PRESERVE = cp -p
LN = ln -f -s
MV = mv -f
RM = rm -f
MKDIR = mkdir -p
GREP = grep
TR = tr
SED = sed
NULL = /dev/null
CPPFLAGS = -E
SORT = sort
STRIP = strip
MAKE_ORIG = +$(MAKE) -f Makefile.legacy

JTR_GIT_COMMIT = \"-$(shell git rev-parse --short HEAD 2>/dev/null)\"
ifeq ($(JTR_GIT_COMMIT), \"-\")
F = "" # for tarballs or zip files not created using git archive
# this format string will be replaced by git archive:
JTR_ARCHIVE_VERSION_STRING = -8a72b12fe6e 2025-02-16 05:23:41 +0100
JTR_GIT_VERSION = JUMBO_VERSION "\"$(shell echo "$(JTR_ARCHIVE_VERSION_STRING)" | "$(SED)" 's/ormat:-%h %ci/-/g')\""
else
JTR_GIT_HEAD_TS = \" $(shell git show -s --format=%ci HEAD 2>/dev/null)\"
JTR_GIT_VERSION = JUMBO_VERSION "$(JTR_GIT_COMMIT) $(JTR_GIT_HEAD_TS)"
endif

## Uncomment the line below for MPI (can be used together with OMP as well)
#CC = mpicc -DHAVE_MPI

OMPFLAGS =
# gcc with OpenMP
#OMPFLAGS = -fopenmp
# gcc with OpenMP on 32-bit x86 with SSE2
#OMPFLAGS = -fopenmp -msse2
# Mac OS X (llvm-gcc) with OpenMP
#OMPFLAGS = -fopenmp -D_FORTIFY_SOURCE=0
# Sun Studio with OpenMP (set the OMP_NUM_THREADS env var at runtime)
#OMPFLAGS = -xopenmp
# icc with OpenMP (for make target linux-x86-64-icc)
#ICCOMPFLAGS = -openmp

# This should be commented out in Git but active in release tarballs
#RELEASE_BLD = -DJTR_RELEASE_BUILD

# Try to auto-detect GMP libs. The grep is needed in case some of the
# paths does not exist, because find will return false even though finding a
# file. If these hacks do not work, comment them out and see next sections.
ifndef RELEASE_BLD
# Comment this out when cross-compiling, such as with the linux-mic target
HAVE_LIBGMP = `find 2>&1 /usr/include /usr/local/include -name "gmp.h" | grep -q "gmp.h" && echo -DHAVE_LIBGMP`
GMP_LDFLAGS = `find 2>&1 /usr/include /usr/local/include -name "gmp.h" | grep -q "gmp.h" && echo -lgmp`
REXGEN_FLAGS = `find 2>&1 /usr/include/librexgen/c /usr/local/include/librexgen/c -name "librexgen.h" | grep -q "librexgen.h" && echo -DHAVE_LIBREXGEN=1`
REXGEN_LDFLAGS = `find 2>&1 /usr/lib/ /usr/local/lib/ -name "liblibrexgen*.a" | grep -q "liblibrexgen" && echo -llibrexgen`
REXGEN_LDFLAGS += `find 2>&1 /usr/lib/ /usr/local/lib/ -name "librexgen*.a" -o -name "librexgen*.so" -o -name "librexgen*.dylib" | grep -q "librexgen" && echo -lrexgen`
endif

# Uncomment the below if you have GMP library installed (faster wowsrp format)
# in case the auto-detection does not work.
#HAVE_LIBGMP = -DHAVE_LIBGMP
#GMP_LDFLAGS = -lgmp

# Comment these out to build without OpenSSL
CFLAGS_OPENSSL = -DHAVE_LIBSSL -DHAVE_LIBCRYPTO
LDFLAGS_OPENSSL = -L/usr/local/ssl/lib -lssl -lcrypto

ifdef NVIDIA_CUDA
OCLROOT = $(NVIDIA_CUDA)
else
OCLROOT = /usr/local/cuda
endif
ifdef AMDAPPSDKROOT
AMDAPP = -DAMDAPPSDK
OCLROOT = $(AMDAPPSDKROOT)
endif
ifdef ATISTREAMSDKROOT
AMDAPP = -DAMDAPPSDK
OCLROOT = $(ATISTREAMSDKROOT)
endif

CFLAGS = -c -Wall -O2 -fomit-frame-pointer -I/usr/local/include $(CFLAGS_OPENSSL) $(REXGEN_FLAGS) $(HAVE_LIBGMP) $(OMPFLAGS) $(AMDAPP) $(JOHN_CFLAGS) $(RELEASE_BLD)
# -DHAVE_SKEY
# CFLAGS for use on the main john.c file only
CFLAGS_MAIN = $(CFLAGS)
ASFLAGS = -c $(OMPFLAGS) $(JOHN_ASFLAGS)
LDFLAGS = -s -L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lz -lrt \
	$(OMPFLAGS) $(GMP_LDFLAGS) $(JOHN_LDFLAGS) $(REXGEN_LDFLAGS)
# -lskey
LDFLAGS_MIC = -s -L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lrt $(OMPFLAGS) $(JOHN_LDFLAGS)
LDFLAGS_SOLARIS = -lrt -lnsl -lsocket -lm -lz $(LDFLAGS_OPENSSL)
LDFLAGS_MKV = -s -lm $(OMPFLAGS)
OPT_NORMAL = -funroll-loops
# Remove the "-Os" if you're using an ancient version of gcc
OPT_INLINE = -Os -funroll-loops -finline-functions

# Works with Solaris make, and GNU make
PLUGFORMATS_SRCS: sh =echo *_plug.c
PLUGFORMATS_SRCS += $(sort $(wildcard *_plug.c))
PLUGFORMATS_OBJS = $(PLUGFORMATS_SRCS:.c=.o)

JOHN_OBJS = \
	jumbo.o john_mpi.o \
	DES_fmt.o DES_std.o DES_bs.o DES_bs_b.o \
	BSDI_fmt.o \
	MD5_fmt.o MD5_std.o md5crypt_common.o md5crypt_long_fmt.o \
	BF_fmt.o BF_std.o BF_common.o \
	scrypt_fmt.o \
	yescrypt/yescrypt-opt.o yescrypt/yescrypt-common.o \
	yescrypt/sha256.o \
	AFS_fmt.o \
	LM_fmt.o \
	trip_fmt.o \
	KeccakDuplex.o KeccakF-1600-opt64.o KeccakHash.o KeccakSponge.o \
	whirlpool.o haval.o skein.o md2.o panama.o \
	timer.o omp_autotune.o \
	md5.o \
	rc4.o \
	hmacmd5.o \
	base64_convert.o \
	md4.o sha1.o sha2.o \
	dynamic_fmt.o dynamic_parser.o dynamic_preloads.o dynamic_utils.o dynamic_big_crypt.o \
	dynamic_compiler.o dynamic_compiler_lib.o \
	ripemd.o tiger.o \
	unrarcmd.o unrarfilter.o unrarhlp.o unrar.o unrarppm.o unrarvm.o \
	rar2john.o \
	zip2john.o pkzip.o \
	$(PLUGFORMATS_OBJS) \
	dyna_salt.o dummy.o \
	gost.o \
	gpu_common.o \
	batch.o bench.o charset.o common.o compiler.o config.o cracker.o \
	crc32.o external.o formats.o getopt.o idle.o inc.o john.o list.o \
	loader.o logger.o mask.o mask_ext.o memory.o misc.o options.o \
	params.o path.o recovery.o rpp.o rules.o signals.o single.o status.o \
	suppressor.o tty.o wordlist.o \
	mkv.o mkvlib.o \
	subsets.o unicode_range.o \
	listconf.o \
	fake_salts.o \
	win32_memmap.o mmap-windows.o \
	uaf_encode.o \
	unicode.o \
	unshadow.o \
	unafs.o \
	undrop.o \
	regex.o pp.o \
	lzma/LzmaDec.o lzma/Lzma2Dec.o lzma/Bra.o lzma/Bra86.o lzma/BraIA64.o lzma/CpuArch.o lzma/Delta.o \
	unique.o gpg2john.o \
	showformats.o

OCL_OBJS = opencl_common.o opencl_autotune.o bt.o bt_hash_type_64.o bt_hash_type_128.o bt_hash_type_192.o bt_twister.o

BENCH_DES_OBJS_ORIG = \
	DES_fmt.o DES_std.o

BENCH_DES_OBJS_DEPEND = \
	$(BENCH_DES_OBJS_ORIG)

BENCH_DES_BS_OBJS_DEPEND = \
	DES_bs_b.o

BENCH_MD5_OBJS_DEPEND = \
	MD5_fmt.o MD5_std.o md5crypt_common.o

BENCH_BF_OBJS_DEPEND = \
	BF_fmt.o BF_std.o BF_common.o

BENCH_OBJS = \
	$(MPIOBJ) \
	$(BENCH_DES_OBJS_DEPEND) \
	DES_bsg.o $(BENCH_DES_BS_OBJS_DEPEND) \
	$(BENCH_MD5_OBJS_DEPEND) \
	$(BENCH_BF_OBJS_DEPEND) \
	bench-t.o best.o common_g.o config_g.o formats_g.o jumbo.o dyna_salt.o \
	memory.o miscnl.o params.o path.o signals_g.o tty-t.o

GENMKVPWD_OBJS = \
	genmkvpwd.o mkvlib.o memory.o miscnl.o path.o jumbo.o

PROJ = find_version ../run/john ../run/unshadow ../run/unafs ../run/unique ../run/undrop \
	../run/rar2john ../run/zip2john \
	../run/genmkvpwd ../run/mkvcalcproba ../run/calc_stat \
	../run/tgtsnarf ../run/racf2john ../run/hccap2john \
	../run/raw2dyna \
	../run/uaf2john \
	../run/wpapcap2john \
	../run/gpg2john ../run/cprepair ../run/base64conv
PROJ_DOS = find_version ../run/john.bin ../run/john.com \
	../run/unshadow.com ../run/unafs.com ../run/unique.com \
	../run/undrop.com \
	../run/rar2john.com ../run/zip2john \
	../run/racf2john.com ../run/hccap2john.com \
	../run/gpg2john.com
PROJ_WIN32 = find_version ../run/john.exe \
	../run/unshadow.exe ../run/unafs.exe ../run/unique.exe \
	../run/undrop.exe \
	../run/rar2john.exe ../run/zip2john.exe \
	../run/genmkvpwd.exe ../run/mkvcalcproba.exe ../run/calc_stat.exe \
	../run/raw2dyna.exe \
	../run/gpg2john.exe ../run/base64conv.exe
PROJ_WIN32_MINGW = find_version ../run/john-mingw.exe \
	../run/unshadow.exe ../run/unafs.exe ../run/unique.exe \
	../run/undrop.exe \
	../run/rar2john.exe ../run/zip2john.exe \
	../run/genmkvpwd.exe ../run/mkvcalcproba.exe ../run/calc_stat.exe \
	../run/raw2dyna.exe \
	../run/gpg2john.exe ../run/base64conv.exe
PROJ_PCAP = ../run/SIPdump ../run/vncpcap2john
default:
	@echo "===================================================="
	@echo "Makefile.legacy is unsupported. You are on your own!"
	@echo "===================================================="
	@echo ""
	@echo "To build John the Ripper, type:"
	@echo "	make -f Makefile.legacy clean SYSTEM"
	@echo "where SYSTEM can be one of the following:"
	@echo "linux-x86-64-native      Linux, x86-64 (enabling all CPU features you've got)"
	@echo "linux-X32-native         Linux, X32-ABI"
#	@echo "linux-X32                Linux, X32-ABI SSE2 (for testing)"
	@echo "linux-x86-64-opencl      Linux, x86-64 OpenCL"
	@echo "linux-x86-64-avx512      Linux, x86-64 with AVX-512 (some 2017+ Intel CPUs)"
	@echo "linux-x86-64-avx2        Linux, x86-64 with AVX2 (some 2013+ Intel CPUs)"
	@echo "linux-x86-64-xop         Linux, x86-64 with AVX and XOP (some AMD CPUs)"
	@echo "linux-x86-64-avx         Linux, x86-64 with AVX (some 2011+ Intel CPUs)"
	@echo "linux-x86-64             Linux, x86-64 with SSE2 (any x86-64 CPU)"
	@echo "linux-x86-64-icc         Linux, x86-64 compiled with icc"
	@echo "linux-x86-64-clang       Linux, x86-64 compiled with clang"
#	@echo "linux-x86-64-clang-debug Linux, x86-64 compiled with clang (with debugging options)
#	@echo "linux-x86-64-32-native   Linux, x86-64, 32-bit with everything (for regression tests)"
#	@echo "linux-x86-64-32-sse2asm  Linux, x86-64, 32-bit with asm SSE2 (for regression tests)"
#	@echo "linux-x86-64-32-sse2     Linux, x86-64, 32-bit with SSE2 (for regression tests)"
#	@echo "linux-x86-64-32-mmx      Linux, x86-64, 32-bit with MMX (for regression tests)"
#	@echo "linux-x86-64-32-any      Linux, x86-64, 32-bit (for regression tests)"
	@echo "linux-x86-opencl         Linux, x86 32-bit with SSE2 and OpenCL"
	@echo "linux-x86-avx512         Linux, x86 32-bit with AVX-512 (some 2017+ Intel CPUs)"
	@echo "linux-x86-avx2           Linux, x86 32-bit with AVX2 (some 2013+ Intel CPUs)"
	@echo "linux-x86-xop            Linux, x86 32-bit with AVX and XOP (some AMD CPUs)"
	@echo "linux-x86-avx            Linux, x86 32-bit with AVX (2011+ Intel CPUs)"
	@echo "linux-x86-sse2           Linux, x86 32-bit with SSE2 (most common, 32-bit)"
	@echo "linux-x86-native         Linux, x86 32-bit, with all CPU features you've got (not necessarily best)"
	@echo "linux-x86-mmx            Linux, x86 32-bit with MMX (for old computers)"
	@echo "linux-x86-any            Linux, x86 32-bit (for truly ancient computers)"
	@echo "linux-x86-clang          Linux, x86 32-bit with SSE2, compiled with clang"
#	@echo "linux-x86-clang-debug    Linux, x86 32-bit with SSE2, compiled with clang (with debugging options)
	@echo "linux-mic                Linux, Intel MIC (first generation Xeon Phi)"
	@echo "linux-arm64le            Linux, ARM 64-bit little-endian w/ASIMD (best)"
	@echo "linux-arm32le-neon       Linux, ARM 32-bit little-endian w/NEON (best 32-bit)"
	@echo "linux-arm32le            Linux, ARM 32-bit little-endian"
	@echo "linux-alpha              Linux, Alpha"
	@echo "linux-sparc64            Linux, SPARC 64-bit"
	@echo "linux-sparc              Linux, SPARC 32-bit"
	@echo "linux-ppc32-altivec      Linux, PowerPC w/AltiVec (best)"
	@echo "linux-ppc32              Linux, PowerPC 32-bit"
	@echo "linux-ppc64-altivec      Linux, PowerPC 64-bit w/AltiVec"
	@echo "linux-ppc64              Linux, PowerPC 64-bit"
	@echo "linux-ia64               Linux, IA-64"
	@echo "freebsd-x86-64           FreeBSD, x86-64 with SSE2 (best)"
	@echo "freebsd-x86-sse2         FreeBSD, x86 with SSE2 (best if 32-bit)"
	@echo "freebsd-x86-mmx          FreeBSD, x86 with MMX"
	@echo "freebsd-x86-any          FreeBSD, x86"
	@echo "freebsd-alpha            FreeBSD, Alpha"
	@echo "openbsd-x86-64           OpenBSD, x86-64 with SSE2 (best)"
	@echo "openbsd-x86-sse2         OpenBSD, x86 with SSE2 (best if 32-bit)"
	@echo "openbsd-x86-mmx          OpenBSD, x86 with MMX"
	@echo "openbsd-x86-any          OpenBSD, x86"
	@echo "openbsd-alpha            OpenBSD, Alpha"
	@echo "openbsd-sparc64          OpenBSD, SPARC 64-bit (best)"
	@echo "openbsd-sparc            OpenBSD, SPARC 32-bit"
	@echo "openbsd-ppc32            OpenBSD, PowerPC 32-bit"
	@echo "openbsd-ppc64            OpenBSD, PowerPC 64-bit"
	@echo "openbsd-pa-risc          OpenBSD, PA-RISC"
	@echo "openbsd-vax              OpenBSD, VAX"
	@echo "netbsd-sparc64           NetBSD, SPARC 64-bit"
	@echo "netbsd-vax               NetBSD, VAX"
	@echo "solaris-sparc64-cc       Solaris, SPARC V9 64-bit, cc (best)"
	@echo "solaris-sparc64-gcc      Solaris, SPARC V9 64-bit, gcc"
	@echo "solaris-sparcv9-cc       Solaris, SPARC V9 32-bit, cc"
	@echo "solaris-sparcv8-cc       Solaris, SPARC V8 32-bit, cc"
	@echo "solaris-sparc-gcc        Solaris, SPARC 32-bit, gcc"
	@echo "solaris-x86-64-cc        Solaris, x86-64 with SSE2, cc"
	@echo "solaris-x86-64-gcc       Solaris, x86-64 with SSE2, gcc"
	@echo "solaris-x86-sse2-cc      Solaris 9 4/04+, x86 with SSE2, cc"
	@echo "solaris-x86-sse2-gcc     Solaris 9 4/04+, x86 with SSE2, gcc"
	@echo "solaris-x86-mmx-cc       Solaris, x86 with MMX, cc"
	@echo "solaris-x86-mmx-gcc      Solaris, x86 with MMX, gcc"
	@echo "solaris-x86-any-cc       Solaris, x86, cc"
	@echo "solaris-x86-any-gcc      Solaris, x86, gcc"
	@echo "tru64-alpha              Tru64 (Digital UNIX, OSF/1), Alpha"
	@echo "aix-ppc32                AIX, PowerPC 32-bit"
	@echo "macosx-x86-64            Mac OS X 10.5+, Xcode 3.0+, x86-64 with SSE2"
	@echo "macosx-x86-64-native     Mac OS X 10.8+, real gcc, x86-64, see doc/INSTALL (best)"
#	@echo "macosx-x86-64-clang-debug Mac OS X 10.5+, Xcode 3.0+, x86-64 compiled with clang (with debugging options)
	@echo "macosx-x86-64-opencl     Mac OS X 10.6+, x86-64 with SSE2, OpenCL support"
	@echo "macosx-x86-sse2          Mac OS X, x86 with SSE2"
	@echo "macosx-x86-sse2-opencl   Mac OS X, x86 with SSE2 and OpenCL"
	@echo "macosx-ppc32-altivec     Mac OS X, PowerPC w/AltiVec (best)"
	@echo "macosx-ppc32             Mac OS X, PowerPC 32-bit"
#	@echo "macosx-ppc64-altivec     Mac OS X, PowerPC 64-bit w/AltiVec"
	@echo "macosx-ppc64             Mac OS X 10.4+, PowerPC 64-bit"
	@echo "macosx-universal         Mac OS X, Universal Binary (x86 + x86-64 + PPC)"
	@echo "hpux-pa-risc-gcc         HP-UX, PA-RISC, gcc"
	@echo "hpux-pa-risc-cc          HP-UX, PA-RISC, ANSI cc"
	@echo "irix-mips64-r10k         IRIX, MIPS 64-bit (R10K) (best)"
	@echo "irix-mips64              IRIX, MIPS 64-bit"
	@echo "irix-mips32              IRIX, MIPS 32-bit"
	@echo "dos-djgpp-x86-mmx        DOS, DJGPP, x86 with MMX"
	@echo "dos-djgpp-x86-any        DOS, DJGPP, x86"
	@echo "win64-cygwin-x86-64      Win64, Cygwin, x86_64 with SSE2 (best)"
	@echo "win64-cygwin-x86-64-opencl  Win64, Cygwin, x86_64 with OpenCL"
	@echo "win64-mingw-x86-64       Win64, MinGW, x86-64 with SSE2 (best)"
	@echo "win32-cygwin-x86-sse2[i] Win32, Cygwin, x86 with SSE2 (best if 32-bit)"
	@echo "win32-cygwin-x86-opencl  Win32, Cygwin, x86 with SSE2 and OpenCL"
	@echo "win32-cygwin-x86-mmx     Win32, Cygwin, x86 with MMX"
	@echo "win32-cygwin-x86-any     Win32, Cygwin, x86"
	@echo "win32-cygwin-x86-anyomp  Win32, Cygwin, x86 (OpenMP enabled)"
	@echo "win32-mingw-x86-sse2[i]  Win32, MinGW, x86 with SSE2 (best if 32-bit)"
	@echo "win32-mingw-x86-mmx      Win32, MinGW, x86 with MMX"
	@echo "win32-mingw-x86-any      Win32, MinGW, x86"
	@echo "beos-x86-sse2            BeOS, x86 with SSE2 (best)"
	@echo "beos-x86-mmx             BeOS, x86 with MMX"
	@echo "beos-x86-any             BeOS, x86"
	@echo "generic                  Any other Unix-like system with gcc"

unit-tests:
	$(CC) -o ../run/unit-tests -Wall -O2 -fomit-frame-pointer -DFORCE_GENERIC_SHA2 -D_JOHN_MISC_NO_LOG -DUNICODE_NO_OPTIONS -DNOT_JOHN tests/unit-tests.c misc.c common.c memory.c sha2.c unicode.c
	../run/unit-tests

linux-x86-64-avx512:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o" \
		CFLAGS_MAIN="$(CFLAGS) -DJOHN_AVX512F -DHAVE_CRYPT" \
		CFLAGS="$(CFLAGS) -mavx512f -maes -mpclmul -DHAVE_CRYPT" \
		ASFLAGS="$(ASFLAGS) -mavx512f" -maes -mpclmul \
		LDFLAGS="$(LDFLAGS) -lcrypt"

linux-x86-64-avx2:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o" \
		CFLAGS_MAIN="$(CFLAGS) -DJOHN_AVX2 -DHAVE_CRYPT" \
		CFLAGS="$(CFLAGS) -mavx2 -maes -mpclmul -DHAVE_CRYPT" \
		ASFLAGS="$(ASFLAGS) -mavx2" -maes -mpclmul \
		LDFLAGS="$(LDFLAGS) -lcrypt"

linux-x86-64-xop:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS_MAIN="$(CFLAGS) -DJOHN_XOP -DHAVE_CRYPT -DHAVE_LIBDL" \
		CFLAGS="$(CFLAGS) -mxop -DHAVE_CRYPT -DHAVE_LIBDL" \
		ASFLAGS="$(ASFLAGS) -mxop" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-64-avx:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS_MAIN="$(CFLAGS) -DJOHN_AVX -DHAVE_CRYPT -DHAVE_LIBDL" \
		CFLAGS="$(CFLAGS) -mavx -maes -mpclmul -DHAVE_CRYPT -DHAVE_LIBDL" \
		ASFLAGS="$(ASFLAGS) -mavx" -maes -mpclmul \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-64-opencl:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) $(OCL_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -I$(OCLROOT)/include -DHAVE_CRYPT -DHAVE_OPENCL -DHAVE_LIBDL -march=native" \
		ASFLAGS="$(ASFLAGS) -march=native" \
		LDFLAGS="$(LDFLAGS) -L$(OCLROOT)/lib/x86_64 -L$(OCLROOT)/lib64 -lcrypt -lOpenCL -ldl -march=native"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-64-native:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL -march=native" \
		ASFLAGS="$(ASFLAGS) -march=native" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl -march=native"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-X32-native:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL -march=native -mx32" \
		ASFLAGS="$(ASFLAGS) -march=native -mx32" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl -march=native -mx32"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-X32:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL -mx32" \
		ASFLAGS="$(ASFLAGS) -mx32" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl -mx32"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-64:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-64-clang:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="-Wall -c -O2 -I/usr/include -msse2 -DHAVE_CRYPT -DHAVE_LIBDL $(HAVE_LIBGMP) $(JOHN_CFLAGS)" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl" \
		CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++" \
		OPT_INLINE="$(OPT_NORMAL)"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CC="clang"
	@echo "All done"

linux-x86-64-clang-debug:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="-Wall -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_LIBDL $(HAVE_LIBGMP) $(JOHN_CFLAGS)" \
		LDFLAGS="-L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lz -lcrypt -ldl -faddress-sanitizer $(GMP_LDFLAGS) $(JOHN_LDFLAGS)" \
		CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) \
		CFLAGS="-Wall -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_LIBDL $(HAVE_LIBGMP) $(JOHN_CFLAGS)" \
		LDFLAGS="-L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lz -lcrypt -ldl -faddress-sanitizer $(GMP_LDFLAGS) $(JOHN_LDFLAGS)" \
		CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++"
	@echo "All done"

linux-x86-64-newgcc-debug:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="-Wall -c -g -O1 -fsanitize=address -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_LIBDL $(HAVE_LIBGMP) $(JOHN_CFLAGS)" \
		LDFLAGS="-L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lz -lcrypt -ldl -fsanitize=address $(GMP_LDFLAGS) $(JOHN_LDFLAGS)"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) \
		CFLAGS="-Wall -c -g -O1 -fsanitize=address -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_LIBDL $(HAVE_LIBGMP) $(JOHN_CFLAGS)" \
		LDFLAGS="-L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lz -lcrypt -ldl -fsanitize=address $(GMP_LDFLAGS) $(JOHN_LDFLAGS)"
	@echo "All done"

linux-x86-64-icc:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="-c -fast -O2 -I/usr/include -static-intel -DHAVE_CRYPT -DHAVE_LIBDL $(ICCOMPFLAGS) $(HAVE_LIBGMP) $(JOHN_CFLAGS)" \
		ASFLAGS="-c -xHost $(JOHN_ASFLAGS)" \
		LDFLAGS="-lm $(LDFLAGS_OPENSSL) -ipo -static-intel -lcrypt -ldl -lz $(ICCOMPFLAGS) -s $(GMP_LDFLAGS) $(JOHN_LDFLAGS)" \
		CPP="icc" CC="icc" AS="icc" LD="icc"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CPP="icc" CC="icc" AS="icc" LD="icc"
	@echo "All done"

linux-x86-64-32-native:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -m32 -msse2 -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE -march=native" \
		ASFLAGS="$(ASFLAGS) -m32 -msse2 -march=native" \
		LDFLAGS="$(LDFLAGS) -m32 -lcrypt -ldl -march=native"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32" LDFLAGS="$(LDFLAGS) -m32"
	@echo "All done"

linux-x86-64-32-sse2:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -m32 -msse2 -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		ASFLAGS="$(ASFLAGS) -m32 -msse2" \
		LDFLAGS="$(LDFLAGS) -m32 -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32" LDFLAGS="$(LDFLAGS) -m32"
	@echo "All done"

linux-x86-64-32-sse2asm:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o" \
		CFLAGS="$(CFLAGS) -m32 -msse2 -DHAVE_CRYPT -DHAVE_LIBDL -DJOHN_DISABLE_INTRINSICS -D_LARGEFILE64_SOURCE" \
		ASFLAGS="$(ASFLAGS) -m32 -msse2" \
		LDFLAGS="$(LDFLAGS) -m32 -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32" LDFLAGS="$(LDFLAGS) -m32"
	@echo "All done"

linux-x86-64-32-mmx:
	$(LN) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-mmx.o" \
		CFLAGS="$(CFLAGS) -m32 -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		ASFLAGS="$(ASFLAGS) -m32" \
		LDFLAGS="$(LDFLAGS) -m32 -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32" LDFLAGS="$(LDFLAGS) -m32"
	@echo "All done"

linux-x86-64-32-any:
	$(LN) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o" \
		CFLAGS="$(CFLAGS) -m32 -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		ASFLAGS="$(ASFLAGS) -m32" \
		LDFLAGS="$(LDFLAGS) -m32 -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32" LDFLAGS="$(LDFLAGS) -m32"
	@echo "All done"

linux-x86-avx512:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o" \
		CFLAGS_MAIN="$(CFLAGS) -m32 -DJOHN_AVX512F -DHAVE_CRYPT" \
		CFLAGS="$(CFLAGS) -m32 -mavx512f -maes -mpclmul -DHAVE_CRYPT" \
		ASFLAGS="$(ASFLAGS) -m32 -mavx512f" -maes -mpclmul \
		LDFLAGS="$(LDFLAGS) -m32 -lcrypt"

linux-x86-avx2:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o" \
		CFLAGS_MAIN="$(CFLAGS) -m32 -DJOHN_AVX2 -DHAVE_CRYPT" \
		CFLAGS="$(CFLAGS) -m32 -mavx2 -maes -mpclmul -DHAVE_CRYPT" \
		ASFLAGS="$(ASFLAGS) -m32 -mavx2" -maes -mpclmul \
		LDFLAGS="$(LDFLAGS) -m32 -lcrypt"

linux-x86-xop:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS_MAIN="$(CFLAGS) -m32 -DJOHN_XOP -DHAVE_CRYPT" \
		CFLAGS="$(CFLAGS) -m32 -mxop -DHAVE_CRYPT -D_LARGEFILE64_SOURCE" \
		ASFLAGS="$(ASFLAGS) -m32 -mxop" \
		LDFLAGS="$(LDFLAGS) -m32 -lcrypt"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32"
	@echo "All done"

linux-x86-avx:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS_MAIN="$(CFLAGS) -m32 -DJOHN_AVX -DHAVE_CRYPT -D_LARGEFILE64_SOURCE" \
		CFLAGS="$(CFLAGS) -m32 -mavx -maes -mpclmul -DHAVE_CRYPT" \
		ASFLAGS="$(ASFLAGS) -m32 -mavx" -maes -mpclmul \
		LDFLAGS="$(LDFLAGS) -m32 -lcrypt"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32"
	@echo "All done"

linux-x86-opencl:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) $(OCL_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -I$(OCLROOT)/include -DHAVE_CRYPT -DHAVE_OPENCL -DHAVE_LIBDL -D_LARGEFILE64_SOURCE -march=native" \
		ASFLAGS="$(ASFLAGS) -march=native" \
		LDFLAGS="$(LDFLAGS) -L$(OCLROOT)/lib/x86 -L$(OCLROOT)/lib -lcrypt -lOpenCL -ldl -march=native"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-native:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE -march=native" \
		ASFLAGS="$(ASFLAGS) -march=native" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl -march=native"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-sse2:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -msse2 -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		ASFLAGS="$(ASFLAGS) -msse2" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-mmx:
	$(LN) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-mmx.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-any:
	$(LN) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-x86-clang:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="-Wall -c -O2 -I/usr/include -msse2 -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE $(HAVE_LIBGMP) $(OMPFLAGS) $(JOHN_CFLAGS)" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl" \
		CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++" \
		OPT_INLINE="$(OPT_NORMAL)"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CC="clang"
	@echo "All done"

linux-x86-clang-debug:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="-Wall -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE $(HAVE_LIBGMP) $(OMPFLAGS) $(JOHN_CFLAGS)" \
		LDFLAGS="-L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lz -lcrypt -ldl -faddress-sanitizer $(GMP_LDFLAGS) $(JOHN_LDFLAGS)" \
		CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) \
		CFLAGS="-Wall -c -g -O1 -faddress-sanitizer -I/usr/include -msse2 -DDEBUG -DHAVE_CRYPT -DHAVE_LIBDL $(HAVE_LIBGMP) $(OMPFLAGS) $(JOHN_CFLAGS)" \
		LDFLAGS="-L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lz -lcrypt -ldl -faddress-sanitizer $(GMP_LDFLAGS) $(JOHN_LDFLAGS)" \
		CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++"
	@echo "All done"

linux-mic:
	$(LN) mic.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o simd-intrinsics.o" \
		CC=icc \
		CFLAGS="$(CFLAGS) -no-opt-prefetch -mmic -openmp -DHAVE_CRYPT" \
		LDFLAGS="$(LDFLAGS_MIC) -mmic -openmp -lcrypt" \
		OPT_INLINE="$(OPT_NORMAL) -finline-functions"
	@echo "You'll likely need to scp Intel's OpenMP runtime library such as /opt/intel/*/compiler/lib/mic/libiomp?.so over to the target MIC cards and set LD_LIBRARY_PATH in order to run the produced john binary"

linux-arm64le:
	$(LN) arm64le.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT" \
		LDFLAGS="$(LDFLAGS) -lcrypt" \
		OPT_INLINE="$(OPT_INLINE) -fno-strict-aliasing"

linux-arm32le-neon:
	$(LN) arm32le.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -mfpu=neon -DHAVE_CRYPT -D_LARGEFILE64_SOURCE" \
		LDFLAGS="$(LDFLAGS) -lcrypt" \
		OPT_INLINE="$(OPT_INLINE) -fno-strict-aliasing"

linux-arm32le:
	$(LN) arm32le.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT" \
		LDFLAGS="$(LDFLAGS) -lcrypt"

linux-alpha:
	$(LN) alpha.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o alpha.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

# This target is currently "undocumented" as ccc generates much slower
# code for the large unrolled loops in John; let's hope it gets fixed.
linux-alpha-ccc:
	$(LN) alpha.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o alpha.o" \
		CC=ccc \
		CFLAGS="-c -Wf,-switch,noil_schedule -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl" \
		OPT_NORMAL="-fast" \
		OPT_INLINE="-O2 -arch host"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CC=ccc
	@echo "All done"

linux-sparc64:
	$(LN) sparc64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -m64 -mcpu=ultrasparc -DHAVE_CRYPT" \
		LDFLAGS="$(LDFLAGS) -m64 -lcrypt"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-sparc:
	$(LN) sparc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-ppc32-altivec:
	$(LN) ppc32alt.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl" \
		OPT_INLINE="-finline-functions -finline-limit=4000 -fno-strict-aliasing -maltivec"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-ppc32:
	$(LN) ppc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL -D_LARGEFILE64_SOURCE" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

linux-ppc64-altivec:
	$(LN) ppc64alt.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -m64 -DHAVE_CRYPT -DHAVE_LIBDL" \
		LDFLAGS="$(LDFLAGS) -m64 -lcrypt -ldl" \
		OPT_INLINE="-finline-functions -finline-limit=4000 -fno-strict-aliasing -maltivec"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m64"
	@echo "All done"

linux-ppc64:
	$(LN) ppc64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -m64 -DHAVE_CRYPT -DHAVE_LIBDL" \
		LDFLAGS="$(LDFLAGS) -m64 -lcrypt -ldl" \
		OPT_INLINE="-finline-functions -finline-limit=4000"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m64"
	@echo "All done"

linux-ia64:
	$(LN) ia64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -DHAVE_LIBDL" \
		LDFLAGS="$(LDFLAGS) -lcrypt -ldl"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

freebsd-x86-64:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86-64.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -D__BSD_VISIBLE"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

freebsd-x86-sse2:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CC=cc \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -D__BSD_VISIBLE -msse2" \
		ASFLAGS="$(ASFLAGS) -DBSD -msse2"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

freebsd-x86-mmx:
	$(LN) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-mmx.o" \
		CFLAGS="$(CFLAGS) -D__BSD_VISIBLE" \
		ASFLAGS="$(ASFLAGS) -DBSD"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

freebsd-x86-any:
	$(LN) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o" \
		CFLAGS="$(CFLAGS) -D__BSD_VISIBLE" \
		ASFLAGS="$(ASFLAGS) -DBSD"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

freebsd-x86-any-a.out:
	$(LN) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o" \
		CFLAGS="$(CFLAGS) -D__BSD_VISIBLE" \
		ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG -DBSD"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

freebsd-alpha:
	$(LN) alpha.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) alpha.o"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-x86-64:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86-64.o simd-intrinsics.o"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-x86-sse2:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-sse.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -DBSD"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-x86-mmx:
	$(LN) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-mmx.o" \
		ASFLAGS="$(ASFLAGS) -DBSD"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-x86-any:
	$(LN) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o" \
		ASFLAGS="$(ASFLAGS) -DBSD"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-x86-any-a.out:
	$(LN) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o" \
		ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG -DBSD"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-alpha:
	$(LN) alpha.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) alpha.o"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-sparc64:
	$(LN) sparc64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CFLAGS="$(CFLAGS) -m64 -mcpu=ultrasparc" \
		LDFLAGS="$(LDFLAGS) -m64"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m64"
	@echo "All done"

openbsd-sparc:
	$(LN) sparc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ)
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-ppc32:
	$(LN) ppc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ)
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-ppc64:
	$(LN) ppc64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CFLAGS="$(CFLAGS) -m64" \
		LDFLAGS="$(LDFLAGS) -m64" \
		OPT_INLINE="-finline-functions -finline-limit=4000"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m64"
	@echo "All done"

openbsd-pa-risc:
	$(LN) pa-risc.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CFLAGS="-c -Wall -O3 -fomit-frame-pointer"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

openbsd-vax:
	$(LN) vax.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ)
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

netbsd-sparc64:
	$(LN) sparc64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CFLAGS="$(CFLAGS) -m64 -mcpu=ultrasparc" \
		LDFLAGS="$(LDFLAGS) -m64"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m64"
	@echo "All done"

netbsd-vax:
	$(LN) vax.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ)
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

solaris-sparc64-cc:
	$(RM) arch.h
	$(LN) sparc64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CC=cc \
		CFLAGS="-c -fast -xarch=native64 -DHAVE_CRYPT $(OMPFLAGS)" \
		LDFLAGS="-s -xarch=native64 $(OMPFLAGS) -lc $(LDFLAGS_SOLARIS) $(JOHN_LDFLAGS)" \
		OPT_NORMAL="" \
		OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"

solaris-sparc64-gcc:
	$(RM) arch.h
	$(LN) sparc64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -m64 -mcpu=ultrasparc -DHAVE_CRYPT" \
		LDFLAGS="$(LDFLAGS) -m64 $(LDFLAGS_SOLARIS) $(JOHN_LDFLAGS)"

solaris-sparcv9-cc:
	$(RM) arch.h
	$(LN) sparc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CC=cc \
		CFLAGS="-c -xO4 -xarch=v8plusa -xchip=ultra -DHAVE_CRYPT $(OMPFLAGS)" \
		LDFLAGS="-s $(OMPFLAGS) -lc $(LDFLAGS_SOLARIS) $(JOHN_LDFLAGS)" \
		OPT_NORMAL="" \
		OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"

solaris-sparcv8-cc:
	$(RM) arch.h
	$(LN) sparc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CC=cc \
		CFLAGS="-c -xO4 -xarch=v8 -DHAVE_CRYPT $(OMPFLAGS)" \
		LDFLAGS="-s $(OMPFLAGS) -lc $(LDFLAGS_SOLARIS) $(JOHN_LDFLAGS)" \
		OPT_NORMAL="" \
		OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"

solaris-sparc-gcc:
	$(RM) arch.h
	$(LN) sparc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT" \
		LDFLAGS="$(LDFLAGS) $(LDFLAGS_SOLARIS)"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) LDFLAGS="$(LDFLAGS) $(LDFLAGS_SOLARIS)"
	@echo "All done"

solaris-x86-64-cc:
	$(RM) arch.h
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CC=cc \
		CFLAGS="-c -fast -xarch=native64 -DHAVE_CRYPT $(OMPFLAGS)" \
		ASFLAGS="-c -xarch=native64 $(OMPFLAGS) $(JOHN_ASFLAGS)" \
		LDFLAGS="-s -xarch=native64 $(OMPFLAGS) $(LDFLAGS_SOLARIS) $(JOHN_LDFLAGS)" \
		OPT_NORMAL="" \
		OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"

solaris-x86-64-gcc:
	$(RM) arch.h
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -m64 -DHAVE_CRYPT" \
		ASFLAGS="$(ASFLAGS) -m64" \
		LDFLAGS="$(LDFLAGS) -m64 $(LDFLAGS_SOLARIS)"

solaris-x86-sse2-cc:
	$(RM) arch.h
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o solaris-x86.o x86-sse.o" \
		CC=cc \
		CFLAGS="-c -fast -xarch=native -DHAVE_CRYPT $(OMPFLAGS) -DJOHN_DISABLE_INTRINSICS" \
		ASFLAGS="-c -xarch=native $(OMPFLAGS) $(JOHN_ASFLAGS)" \
		LDFLAGS="-s -xarch=native $(OMPFLAGS) $(LDFLAGS_SOLARIS) $(JOHN_LDFLAGS)" \
		OPT_NORMAL="" \
		OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"

solaris-x86-sse2-gcc:
	$(RM) arch.h
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o solaris-x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT" \
		LDFLAGS="$(LDFLAGS) $(LDFLAGS_SOLARIS)"

solaris-x86-mmx-cc:
	$(RM) arch.h
	$(LN) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o solaris-x86.o x86-mmx.o" \
		CC=cc \
		CFLAGS="-c -fast -xarch=native -DHAVE_CRYPT $(OMPFLAGS)" \
		ASFLAGS="-c -xarch=native $(OMPFLAGS) $(JOHN_ASFLAGS)" \
		LDFLAGS="-s -xarch=native $(OMPFLAGS) $(LDFLAGS_SOLARIS) $(JOHN_LDFLAGS)" \
		OPT_NORMAL="" \
		OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"

solaris-x86-mmx-gcc:
	$(RM) arch.h
	$(LN) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o solaris-x86.o x86-mmx.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT" \
		LDFLAGS="$(LDFLAGS) $(LDFLAGS_SOLARIS)"

solaris-x86-any-cc:
	$(RM) arch.h
	ln -s x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		SHELL=/bin/sh \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o solaris-x86.o" \
		CC=cc \
		CFLAGS="-c -xO4 -DHAVE_CRYPT $(OMPFLAGS)" \
		ASFLAGS="-c $(OMPFLAGS) $(JOHN_ASFLAGS)" \
		LDFLAGS="-s $(OMPFLAGS) -lc $(LDFLAGS_SOLARIS) $(JOHN_LDFLAGS)" \
		OPT_NORMAL="" \
		OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"

solaris-x86-any-gcc:
	$(RM) arch.h
	ln -s x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		SHELL=/bin/sh \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o solaris-x86.o" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT" \
		LDFLAGS="$(LDFLAGS) -lc $(LDFLAGS_SOLARIS)"

# Older versions of Sun's assembler had a line length restriction (and some
# other problems, which affect newer versions as well and which are worked
# around in x86.S).
solaris-x86.o: x86.S
	$(CPP) $(CPPFLAGS) -P -DDUMBAS x86.S | $(TR) \; \\n > tmp.s
	$(AS) $(ASFLAGS) tmp.s -o solaris-x86.o
	$(RM) tmp.s

tru64-alpha:
	$(LN) alpha.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) digipaq-alpha.o" \
		CC=cc \
		CFLAGS="-c -O4 -arch host" \
		OPT_NORMAL="" \
		OPT_INLINE="-inline all"

# Digital/Compaq's cc and make use the .S suffix for a different purpose...
digipaq-alpha.o: alpha.S
	$(CPP) $(CPPFLAGS) alpha.S > tmp.s
	$(AS) $(ASFLAGS) tmp.s -o digipaq-alpha.o
	$(RM) tmp.s

aix-ppc32:
	$(LN) ppc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CC=cc \
		CFLAGS="-c -qunroll=2 -qarch=ppc -qchars=signed" \
		LDFLAGS="$(LDFLAGS) -lbsd" \
		OPT_NORMAL="-O2" \
		OPT_INLINE="-O3 -Q=99 -w"

# This target needs a real gcc and a wrapper for using clang's assembler:
# Copy osx_as_wrapper.sh to /usr/local/bin/as or some other directory at your
# choice (but the file MUST be named 'as') and be sure this directory is
# first in your $PATH.
macosx-x86-64-native:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -march=native -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -march=native -Wno-deprecated-declarations" \
		LDFLAGS="$(LDFLAGS) -march=native"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -march=native"
	@echo "All done"

macosx-x86-64:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -m64 -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="$(CFLAGS) -DHAVE_CRYPT -m64 -Wno-deprecated-declarations" \
		LDFLAGS="$(LDFLAGS) -m64"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m64"
	@echo "All done"

# This target needs a real gcc and a wrapper for using clang's assembler:
# Copy osx_as_wrapper.sh to /usr/local/bin/as or some other directory at your
# choice (but the file MUST be named 'as') and be sure this directory is
# first in your $PATH.
macosx-x86-64-native-opencl:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) $(OCL_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -march=native -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="$(CFLAGS) -march=native -I$(OCLROOT)/include -DHAVE_CRYPT -DHAVE_OPENCL -Wno-deprecated-declarations" \
		LDFLAGS="$(LDFLAGS) -march=native -framework OpenCL"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -march=native"
	@echo "All done"

macosx-x86-64-opencl:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) $(OCL_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -m64 -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="$(CFLAGS) -m64 -I$(OCLROOT)/include -DBSD -DHAVE_CRYPT -DHAVE_OPENCL -Wno-deprecated-declarations" \
		LDFLAGS="$(LDFLAGS) -m64 -framework OpenCL"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

macosx-x86-64-clang-debug:
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) c3_fmt.o x86-64.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -m64 -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="-Wall -c -g -O1 -I/usr/include -I/usr/local/include -Wno-deprecated-declarations -DDEBUG -DHAVE_CRYPT -DBSD $(HAVE_LIBGMP) $(JOHN_CFLAGS)" \
		LDFLAGS="-L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lz $(GMP_LDFLAGS) $(JOHN_LDFLAGS)" \
		CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) \
		ASFLAGS="$(ASFLAGS) -m64 -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="-Wall -c -g -O1 -I/usr/include -I/usr/local/include -Wno-deprecated-declarations -DDEBUG -DHAVE_CRYPT -DBSD $(HAVE_LIBGMP) $(JOHN_CFLAGS)" \
		LDFLAGS="-L/usr/local/lib $(LDFLAGS_OPENSSL) -lm -lz $(GMP_LDFLAGS) $(JOHN_LDFLAGS)" \
		CPP="clang" CC="clang" AS="clang" LD="clang" CXX="clang++"
	@echo "All done"

macosx-x86-sse2:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-sse.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -m32 -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="$(CFLAGS) -m32 -Wno-deprecated-declarations -D_DARWIN_C_SOURCE" \
		LDFLAGS="$(LDFLAGS) -m32"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32" LDFLAGS="$(LDFLAGS) -m32"
	@echo "All done"

macosx-x86-sse2-opencl:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) $(OCL_OBJS) c3_fmt.o x86.o x86-sse.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -m32 -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="$(CFLAGS) -m32 -I$(OCLROOT)/include -DBSD -DHAVE_CRYPT -DHAVE_OPENCL -D_DARWIN_C_SOURCE -Wno-deprecated-declarations" \
		LDFLAGS="$(LDFLAGS) -m32 -framework OpenCL"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32" LDFLAGS="$(LDFLAGS) -m32"
	@echo "All done"

macosx-x86-mmx:
	$(LN) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-mmx.o" \
		ASFLAGS="$(ASFLAGS) -m32 -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="$(CFLAGS) -m32 -Wno-deprecated-declarations -D_DARWIN_C_SOURCE" \
		LDFLAGS="$(LDFLAGS) -m32"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32" LDFLAGS="$(LDFLAGS) -m32"
	@echo "All done"

macosx-ppc32-altivec:
	$(LN) ppc32alt.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CFLAGS="-c -Wall -fomit-frame-pointer -D_DARWIN_C_SOURCE" \
		OPT_NORMAL="-fast -mcpu=7450" \
		OPT_INLINE="-fast -mcpu=7450 -finline-limit=4000 -faltivec -maltivec"

# The -cross targets can be used to compile PowerPC binaries on x86.
macosx-ppc32-altivec-cross:
	$(LN) ppc32alt.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		ASFLAGS="$(ASFLAGS) -arch ppc" \
		CFLAGS="-c -Wall -arch ppc -fomit-frame-pointer -D_DARWIN_C_SOURCE" \
		LDFLAGS="$(LDFLAGS) -arch ppc" \
		OPT_NORMAL="-fast -mcpu=7450" \
		OPT_INLINE="-fast -mcpu=7450 -finline-limit=4000 -faltivec -maltivec"

# "cc -traditional-cpp" was needed on older versions of Mac OS X; it might
# actually be problematic on current ones, but those will hopefully use other
# make targets anyway (e.g., macosx-ppc32-altivec above).
macosx-ppc32:
	$(LN) ppc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CC=cc \
		CFLAGS="-c -traditional-cpp -D_DARWIN_C_SOURCE" \
		OPT_NORMAL="-O2" \
		OPT_INLINE="-O3"

macosx-ppc32-cross:
	$(LN) ppc32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		ASFLAGS="$(ASFLAGS) -arch ppc" \
		CFLAGS="-c -Wall -arch ppc -fomit-frame-pointer -D_DARWIN_C_SOURCE" \
		LDFLAGS="$(LDFLAGS) -arch ppc" \
		OPT_NORMAL="-O2" \
		OPT_INLINE="-O3 -finline-limit=4000"

# This is slightly slower than macosx-ppc32-altivec for most hash types.
macosx-ppc64-altivec:
	$(LN) ppc64alt.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CFLAGS="-c -m64 -Wall -fomit-frame-pointer" \
		LDFLAGS="$(LDFLAGS) -m64" \
		OPT_NORMAL="-fast" \
		OPT_INLINE="-fast -finline-limit=4000 -faltivec -maltivec"

macosx-ppc64-altivec-cross:
	$(LN) ppc64alt.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		ASFLAGS="$(ASFLAGS) -arch ppc" \
		CFLAGS="-c -arch ppc -m64 -Wall -fomit-frame-pointer" \
		LDFLAGS="$(LDFLAGS) -arch ppc -m64" \
		OPT_NORMAL="-fast" \
		OPT_INLINE="-fast -finline-limit=4000 -faltivec -maltivec"

macosx-ppc64:
	$(LN) ppc64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CFLAGS="-c -m64 -Wall -fomit-frame-pointer" \
		LDFLAGS="$(LDFLAGS) -m64" \
		OPT_NORMAL="-fast" \
		OPT_INLINE="-fast -finline-limit=4000"

macosx-ppc64-cross:
	$(LN) ppc64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		ASFLAGS="$(ASFLAGS) -arch ppc" \
		CFLAGS="-c -arch ppc -m64 -Wall -fomit-frame-pointer" \
		LDFLAGS="$(LDFLAGS) -arch ppc -m64" \
		OPT_NORMAL="-fast" \
		OPT_INLINE="-fast -finline-limit=4000"

john-macosx-x86-64:
	$(RM) *.o
	$(LN) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86-64.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -arch x86_64 -m64 -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="$(CFLAGS) -arch x86_64 -m64" \
		LDFLAGS="$(LDFLAGS) -arch x86_64 -m64"
	$(MV) ../run/john john-macosx-x86-64

john-macosx-x86:
	$(RM) *.o
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-sse.o simd-intrinsics.o" \
		ASFLAGS="$(ASFLAGS) -arch i386 -m32 -DUNDERSCORES -DBSD -DALIGN_LOG" \
		CFLAGS="$(CFLAGS) -arch i386 -m32 -D_DARWIN_C_SOURCE" \
		LDFLAGS="$(LDFLAGS) -arch i386 -m32"
	$(MV) ../run/john john-macosx-x86

john-macosx-ppc:
	$(RM) *.o
	$(LN) ppc32alt.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		ASFLAGS="$(ASFLAGS) -arch ppc" \
		CFLAGS="-c -Wall -arch ppc -fomit-frame-pointer -D_DARWIN_C_SOURCE" \
		LDFLAGS="$(LDFLAGS) -arch ppc" \
		OPT_NORMAL="-fast -mcpu=7450" \
		OPT_INLINE="-fast -mcpu=7450 -finline-limit=4000 -faltivec -maltivec"
	$(MV) ../run/john john-macosx-ppc

macosx-universal: john-macosx-x86-64 john-macosx-x86 john-macosx-ppc
	lipo -create john-macosx-x86-64 john-macosx-x86 john-macosx-ppc \
		-output ../run/john

hpux-pa-risc-gcc:
	$(LN) pa-risc.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CFLAGS="-c -Wall -O3 -fomit-frame-pointer"

hpux-pa-risc-cc:
	$(LN) pa-risc.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CC=cc \
		CFLAGS="-c -Aa -D_HPUX_SOURCE -DANSI_CPP" \
		OPT_NORMAL="+O2" \
		OPT_INLINE="+O3 +Oinline"

irix-mips64-r10k:
	$(LN) mips64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CC=cc \
		CFLAGS="-c -O2 -64 -mips4 -r10000 -signed" \
		LDFLAGS="$(LDFLAGS) -64 -mips4 -r10000" \
		OPT_NORMAL="-LNO:opt=1 -OPT:Olimit=2194" \
		OPT_INLINE="-INLINE:all"

irix-mips64:
	$(LN) mips64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CC=cc \
		CFLAGS="-c -O2 -64 -mips3 -signed" \
		LDFLAGS="$(LDFLAGS) -64 -mips3" \
		OPT_NORMAL="-LNO:opt=1 -OPT:Olimit=2194" \
		OPT_INLINE="-INLINE:all"

irix-mips32:
	$(LN) mips32.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		CC=cc \
		CFLAGS="-c -O2 -32 -signed" \
		LDFLAGS="$(LDFLAGS) -32" \
		OPT_NORMAL="-LNO:opt=1 -OPT:Olimit=2194" \
		OPT_INLINE="-INLINE:all"

#	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
# Not sure we can do the above.  Thus we set the 'no build' rule

dos-djgpp-x86-mmx:
	copy x86-mmx.h arch.h
	$(MAKE_ORIG) $(PROJ_DOS) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-mmx.o" \
		CFLAGS="$(CFLAGS) -DNO_JOHN_BLD -mpreferred-stack-boundary=2" \
		ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG"

dos-djgpp-x86-any:
	copy x86-any.h arch.h
	$(MAKE_ORIG) $(PROJ_DOS) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o" \
		CFLAGS="$(CFLAGS) -DNO_JOHN_BLD -mpreferred-stack-boundary=2" \
		ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG"

win64-cygwin-x86-64:
	$(CP) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32) \
		JOHN_OBJS="$(JOHN_OBJS) x86-64.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -D__CYGWIN64__ -D__CYGWIN32__ -mpreferred-stack-boundary=4" \
		ASFLAGS="$(ASFLAGS) -D__CYGWIN64__ -D__CYGWIN32__" \
		CPP=$(GCC) CC=$(GCC) LD=$(GCC) CXX=$(CXX)
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) \
	    CFLAGS="$(CFLAGS) -D__CYGWIN64__ -D__CYGWIN32__ -mpreferred-stack-boundary=4" \
	    CPP=$(GCC) CC=$(GCC) LD=$(GCC) CXX=$(CXX)
	@echo "All done"

win64-cygwin-x86-64-opencl:
	$(CP) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32) \
		JOHN_OBJS="$(JOHN_OBJS) $(OCL_OBJS) x86-64.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -I'$(OCLROOT)/include' -DHAVE_OPENCL -D__CYGWIN64__ -D__CYGWIN32__ -mpreferred-stack-boundary=4" \
		ASFLAGS="$(ASFLAGS) -D__CYGWIN64__ -D__CYGWIN32__ " \
		LDFLAGS="$(LDFLAGS) -L'$(OCLROOT)/lib/x86_64' -lOpenCL "
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) \
	    CFLAGS="$(CFLAGS) -D__CYGWIN64__ -D__CYGWIN32__ -mpreferred-stack-boundary=4" \
	    CPP=$(GCC) CC=$(GCC) LD=$(GCC) CXX=$(CXX)
	@echo "All done"

win64-mingw-x86-64:
	$(CP) x86-64.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32_MINGW) \
		JOHN_OBJS="$(JOHN_OBJS) x86-64.o simd-intrinsics.o" \
		CFLAGS="-c -static -Wall -O2 -fomit-frame-pointer -I/usr/local/include $(OMPFLAGS) $(AMDAPP) $(JOHN_CFLAGS) -mpreferred-stack-boundary=4" \
		LDFLAGS="-static $(LDFLAGS_OPENSSL) -lwsock32 -lws2_32 -lgdi32 -lm -lpthread -lz $(OMPFLAGS)" \
		ASFLAGS="$(ASFLAGS)" \
		CPP=$(GCC) CC=$(GCC) LD=$(GCC) CXX=$(CXX)
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) \
	    CFLAGS="-c -static -Wall -O2 -fomit-frame-pointer -I/usr/local/include $(HAVE_LIBGMP) $(OMPFLAGS) $(AMDAPP) $(JOHN_CFLAGS) -Wall -mpreferred-stack-boundary=4" \
	    CPP=$(GCC) CC=$(GCC) LD=$(GCC) CXX=$(CXX)
	@echo "All done"

win32-cygwin-x86-sse2:
	$(CP) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -mpreferred-stack-boundary=4 -msse2 -m32" \
		ASFLAGS="$(ASFLAGS) -msse2 -m32 -DUNDERSCORES"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32"
	@echo "All done"

win32-cygwin-x86-sse4:
	$(CP) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -mpreferred-stack-boundary=4 -msse4 -m32" \
		ASFLAGS="$(ASFLAGS) -msse4 -m32 -DUNDERSCORES"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_CXX) CFLAGS="$(CFLAGS) -m32"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32"
	@echo "All done"

win32-cygwin-x86-ssse3:
	$(CP) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -mpreferred-stack-boundary=4 -mssse3 -m32" \
		ASFLAGS="$(ASFLAGS) -mssse3 -m32 -DUNDERSCORES"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_CXX) CFLAGS="$(CFLAGS) -m32"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32"
	@echo "All done"

win32-cygwin-x86-opencl:
	$(CP) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32) \
		JOHN_OBJS="$(JOHN_OBJS) $(OCL_OBJS) x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="$(CFLAGS) -I'$(OCLROOT)/include' -DHAVE_OPENCL -mpreferred-stack-boundary=4 -msse2 -m32" \
		ASFLAGS="$(ASFLAGS) -msse2 -m32 -DUNDERSCORES" \
		LDFLAGS="$(LDFLAGS) -L'$(OCLROOT)/lib/x86' -lOpenCL "
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32"
	@echo "All done"

win32-cygwin-x86-mmx:
	$(CP) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-mmx.o" \
		CFLAGS="$(CFLAGS) -mpreferred-stack-boundary=3" \
		ASFLAGS="$(ASFLAGS) -DUNDERSCORES"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

win32-cygwin-x86-any:
	$(CP) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o" \
		CFLAGS="$(CFLAGS) -mpreferred-stack-boundary=2" \
		CFLAGS_MAIN="$(CFLAGS) -O1" \
		ASFLAGS="$(ASFLAGS) -DUNDERSCORES"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

win32-cygwin-x86-anyomp:
	$(CP) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o" \
		CFLAGS="$(CFLAGS) -mpreferred-stack-boundary=2 -fopenmp" \
		CFLAGS_MAIN="$(CFLAGS) -O1 -fopenmp" \
		ASFLAGS="$(ASFLAGS) -DUNDERSCORES -fopenmp" \
		LDFLAGS="$(LDFLAGS) -fopenmp"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP)
	@echo "All done"

win32-mingw-x86-sse2:
	$(CP) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32_MINGW) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-sse.o simd-intrinsics.o" \
		CFLAGS="-c -static -Wall -O2 -fomit-frame-pointer -I/usr/local/include $(OMPFLAGS) $(AMDAPP) $(JOHN_CFLAGS) -Wall -mpreferred-stack-boundary=4 -msse2 -m32" \
		LDFLAGS="-static $(LDFLAGS_OPENSSL) -lwsock32 -lwst -lws2_32 -lgdi32 -lm -lpthread.dll -lz.dll $(OMPFLAGS)" \
		ASFLAGS="$(ASFLAGS) -msse2 -m32 -DUNDERSCORES" \
		CPP=$(GCC) CC=$(GCC) LD=$(GCC) CXX=$(CXX)
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) \
	    CFLAGS="-c -static -Wall -O2 -fomit-frame-pointer -I/usr/local/include $(HAVE_LIBGMP) $(OMPFLAGS) $(AMDAPP) $(JOHN_CFLAGS) -Wall -mpreferred-stack-boundary=4 -msse2 -m32" \
	    CPP=$(GCC) CC=$(GCC) LD=$(GCC) CXX=$(CXX)
	@echo "All done"

win32-mingw-x86-mmx:
	$(CP) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32_MINGW) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-mmx.o" \
		CFLAGS="$(CFLAGS) -mpreferred-stack-boundary=3 -mmmx -m32" \
		LDFLAGS="$(LDFLAGS) -lpthread" \
		ASFLAGS="$(ASFLAGS) -DUNDERSCORES"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32"
	@echo "All done"

win32-mingw-x86-any:
	$(CP) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ_WIN32_MINGW) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o" \
		CFLAGS="$(CFLAGS) -Wall -mpreferred-stack-boundary=2 -m32" \
		LDFLAGS="$(LDFLAGS) -lpthread" \
		ASFLAGS="$(ASFLAGS) -DUNDERSCORES"
	@echo "Failing after this point just means some helper tools did not build:"
	$(MAKE_ORIG) $(PROJ_PCAP) CFLAGS="$(CFLAGS) -m32"
	@echo "All done"

beos-x86-sse2:
	$(LN) x86-sse.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-sse.o"

beos-x86-mmx:
	$(LN) x86-mmx.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o x86-mmx.o"

beos-x86-any:
	$(LN) x86-any.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ) \
		JOHN_OBJS="$(JOHN_OBJS) x86.o"

generic: generic.h
	$(RM) arch.h
	ln -s generic.h arch.h
	@echo "#define JOHN_BLD" '"'$@'"' > john_build_rule.h
	$(MAKE_ORIG) $(PROJ)

generic.h:
	$(RM) arch.h
	$(CC) $(CFLAGS) detect.c
	$(LD) detect.o $(LDFLAGS) -o detect
	./best.sh "$(MAKE) -f Makefile.legacy" \
		"$(BENCH_DES_OBJS_DEPEND)" \
		"$(BENCH_DES_BS_OBJS_DEPEND)" \
		"$(BENCH_MD5_OBJS_DEPEND)" \
		"$(BENCH_BF_OBJS_DEPEND)"

bench: $(BENCH_OBJS)
	$(LD) $(BENCH_OBJS) $(LDFLAGS) -o bench

listconf.o: version.h listconf.h listconf.c timer.h

dynamic_big_crypt.c: dynamic_big_crypt_hash.cin dynamic_big_crypt_header.cin dynamic_big_crypt_generator.sh dynamic_big_crypt_chopper.pl dynamic_big_crypt_generated.c
	$(shell ./dynamic_big_crypt_generator.sh)
	@if [ ! -f dynamic_big_crypt.c ] ; then $(CP_PRESERVE) dynamic_big_crypt_generated.c dynamic_big_crypt.c ; fi

dynamic_big_crypt.o:	dynamic_big_crypt.c arch.h misc.h common.h formats.h sha.h sha2.h md5.h md4.h gost.h sph_haval.h sph_ripemd.h sph_tiger.h sph_whirlpool.h dynamic.h johnswap.h simd-intrinsics.h dynamic_types.h


options.o: version.h options.c

version.h: find_version

find_version:
	echo "#define JTR_GIT_VERSION $(JTR_GIT_VERSION)" > version.h.new
	diff >/dev/null 2>/dev/null version.h.new version.h && $(RM) version.h.new || $(MV) version.h.new version.h

SUBDIRS = mbedtls secp256k1 ed25519-donna poly1305-donna

.PHONY: subdirs $(SUBDIRS) find_version

subdirs: $(SUBDIRS)

$(SUBDIRS):
	$(MAKE_ORIG) -C $@ all CC=$(CC)

../run/john: $(JOHN_OBJS) $(SUBDIRS)
	$(LD) $(JOHN_OBJS) $(LDFLAGS) mbedtls/aes.a secp256k1/secp256k1.a ed25519-donna/ed25519-donna.o poly1305-donna/poly1305-donna.o -o ../run/john

../run/unshadow: ../run/john
	$(RM) ../run/unshadow
	ln -s john ../run/unshadow

../run/unafs: ../run/john
	$(RM) ../run/unafs
	ln -s john ../run/unafs

../run/undrop: ../run/john
	$(RM) ../run/undrop
	ln -s john ../run/undrop

../run/zip2john: ../run/john
	$(RM) ../run/zip2john
	ln -s john ../run/zip2john

../run/gpg2john: ../run/john
	$(RM) ../run/gpg2john
	ln -s john ../run/gpg2john

../run/rar2john: ../run/john
	$(RM) ../run/rar2john
	ln -s john ../run/rar2john

../run/base64conv: ../run/john
	$(RM) ../run/base64conv
	ln -s john ../run/base64conv

../run/unique: ../run/john
	$(RM) ../run/unique
	ln -s john ../run/unique

../run/john.bin: $(JOHN_OBJS)
	$(LD) $(JOHN_OBJS) $(LDFLAGS) -o ../run/john.exe
	if exist ..\run\john.bin del ..\run\john.bin
	ren ..\run\john.exe john.bin

../run/john.com: john.com
	copy john.com ..\run\john.com

../run/unshadow.com: john.com
	copy john.com ..\run\unshadow.com

../run/unafs.com: john.com
	copy john.com ..\run\unafs.com

../run/undrop.com: john.com
	copy john.com ..\run\undrop.com

../run/rar2john.com: john.com
	copy john.com ..\run\rar2john.com

../run/zip2john.com: john.com
	copy john.com ..\run\zip2john.com

../run/gpg2john.com: john.com
	copy john.com ..\run\gpg2john.com

../run/unique.com: john.com
	copy john.com ..\run\unique.com

john.com: john.asm
	@echo Use Borland TASM/TLINK to make JOHN.COM

../run/oui.txt:
	cd ../run && wget http://standards-oui.ieee.org/oui.txt

# this LD line removed from the ../run/john.exe rule (Cygwin builds)
# this change needed for full openssl linking, in 1.7.7-jumbo-6
# this comment should stay for a jumbo or 2, to make sure this does not break
# other peoples cygwin builds.
#	$(LD) $(JOHN_OBJS) -lkernel32 -lcrypto -o ../run/john.exe

../run/john.exe: $(JOHN_OBJS) $(SUBDIRS)
	$(LD) $(JOHN_OBJS) $(LDFLAGS) mbedtls/aes.a secp256k1/secp256k1.a ed25519-donna/ed25519-donna.a poly1305-donna/poly1305-donna.a -lkernel32 -o ../run/john.exe
	$(STRIP) ../run/john.exe

# this LD line removed from the ../run/john-mingw.exe rule (MinGW32 builds)
# this change needed for full openssl linking, in 1.7.7-jumbo-6
#	$(LD) $(JOHN_OBJS) -lkernel32 -leay32 -o ../run/john-mingw.exe
#	$(LD) $(JOHN_OBJS) $(LDFLAGS) -lkernel32 -o ../run/john-mingw.exe

../run/john-mingw.exe: $(JOHN_OBJS)
	$(LD) $(JOHN_OBJS) $(LDFLAGS) mbedtls/aes.a secp256k1/secp256k1.a ed25519-donna/ed25519-donna.a poly1305-donna/poly1305-donna.a -lkernel32 -o ../run/john-mingw.exe
	$(STRIP) ../run/john-mingw.exe
	cp ../run/john-mingw.exe ../run/john.exe

../run/unshadow.exe: symlink.c
	$(CC) symlink.c -o ../run/unshadow.exe
	$(STRIP) ../run/unshadow.exe

../run/unafs.exe: symlink.c
	$(CC) symlink.c -o ../run/unafs.exe
	$(STRIP) ../run/unafs.exe

../run/undrop.exe: symlink.c
	$(CC) symlink.c -o ../run/undrop.exe
	$(STRIP) ../run/undrop.exe

../run/rar2john.exe: symlink.c
	$(CC) symlink.c -o ../run/rar2john.exe
	$(STRIP) ../run/rar2john.exe

../run/zip2john.exe: symlink.c
	$(CC) symlink.c -o ../run/zip2john.exe
	$(STRIP) ../run/zip2john.exe

../run/gpg2john.exe: symlink.c
	$(CC) symlink.c -o ../run/gpg2john.exe
	$(STRIP) ../run/gpg2john.exe

../run/base64conv.exe: symlink.c
	$(CC) symlink.c -o ../run/base64conv.exe
	$(STRIP) ../run/base64conv.exe

../run/unique.exe: symlink.c
	$(CC) symlink.c -o ../run/unique.exe
	$(STRIP) ../run/unique.exe

../run/genmkvpwd: $(GENMKVPWD_OBJS)
	$(LD) $(GENMKVPWD_OBJS) $(LDFLAGS) -o ../run/genmkvpwd

../run/genmkvpwd.exe: $(GENMKVPWD_OBJS)
	$(LD) $(GENMKVPWD_OBJS) $(LDFLAGS_MKV) -o ../run/genmkvpwd.exe

../run/mkvcalcproba: mkvcalcproba.o
	$(LD) mkvcalcproba.o $(LDFLAGS) $(OMPFLAGS) -o ../run/mkvcalcproba

../run/mkvcalcproba.exe: mkvcalcproba.o
	$(LD) mkvcalcproba.o $(LDFLAGS_MKV) $(OMPFLAGS) -o ../run/mkvcalcproba.exe

../run/calc_stat: calc_stat.o
	$(LD) calc_stat.o $(LDFLAGS) $(OMPFLAGS) -o ../run/calc_stat

../run/calc_stat.exe: calc_stat.o
	$(LD) calc_stat.o $(LDFLAGS_MKV) $(OMPFLAGS) -o ../run/calc_stat.exe

../run/raw2dyna: raw2dyna.o
	$(LD) raw2dyna.o $(LDFLAGS) $(OMPFLAGS) -o ../run/raw2dyna

../run/raw2dyna.exe: raw2dyna.o
	$(LD) raw2dyna.o $(LDFLAGS) $(OMPFLAGS) -o ../run/raw2dyna.exe

../run/SIPdump: SIPdump.o
	$(LD) SIPdump.o $(LDFLAGS) -lpcap $(OMPFLAGS) -o ../run/SIPdump

../run/vncpcap2john: vncpcap2john.o
	$(LD) vncpcap2john.o $(LDFLAGS) -lpcap $(OMPFLAGS) -o ../run/vncpcap2john

../run/uaf2john: uaf2john.o uaf_encode.o
	$(LD) $(LDFLAGS) uaf2john.o uaf_encode.o $(OMPFLAGS) -o ../run/uaf2john

../run/wpapcap2john: wpapcap2john.o jumbo.o
	$(LD) $(LDFLAGS) wpapcap2john.o jumbo.o $(OMPFLAGS) -o ../run/wpapcap2john

../run/cprepair: cprepair.c unicode.c unicode.h options.h misc.h misc.c \

	$(CC) -Wall -O3 -s -DNOT_JOHN -D_JOHN_MISC_NO_LOG cprepair.c unicode.c \
	misc.c memory.c -o ../run/cprepair

../run/tgtsnarf: tgtsnarf.o
	$(LD) tgtsnarf.o $(LDFLAGS) $(OMPFLAGS) -o ../run/tgtsnarf

../run/racf2john: racf2john.o jumbo.o
	$(LD) $(LDFLAGS) racf2john.o jumbo.o -o ../run/racf2john

../run/hccap2john: common.o hccap2john.o jumbo.o
	$(LD) $(LDFLAGS) common.o hccap2john.o jumbo.o -o ../run/hccap2john

unicode_range.o: unicode_range.c unicode_range.h
	$(CC) $(CFLAGS) $(OPT_NORMAL) -O0 unicode_range.c

# Inlining the S-boxes produces faster code as long as they fit in the cache.
DES_bs_b.o: DES_bs_b.c sboxes.c nonstd.c sboxes-s.c sboxes-t.c
	$(CC) $(CFLAGS) $(OPT_INLINE) DES_bs_b.c

# This is for the BENCH build (to not depend upon unicode.o)
DES_bsg.o: DES_bs.c
	$(CC) $(CFLAGS) -DBENCH_BUILD DES_bs.c -o DES_bsg.o

config_g.o: config.c
	$(CC) $(CFLAGS) -DBENCH_BUILD config.c -o config_g.o

pp.o: pp.c
	$(CC) $(CFLAGS) $(OPT_NORMAL) -DJTR_MODE -Wno-declaration-after-statement -std=gnu99 pp.c -o pp.o

# This is for the BENCH build (to not depend upon options.o)
common_g.o: common.o
	$(CC) $(CFLAGS) -DBENCH_BUILD common.c -o common_g.o

formats_g.o: formats.o
	$(CC) $(CFLAGS) -DBENCH_BUILD formats.c -o formats_g.o

signals_g.o: signals.o
	$(CC) $(CFLAGS) -DBENCH_BUILD signals.c -o signals_g.o

miscnl.o: misc.c
	$(CC) $(CFLAGS) $(OPT_NORMAL) -D_JOHN_MISC_NO_LOG misc.c -o miscnl.o

bench-t.o: bench.c
	$(CC) $(CFLAGS) $(OPT_NORMAL) -DBENCH_BUILD bench.c -o bench-t.o

tty-t.o: tty.c
	$(CC) $(CFLAGS) $(OPT_NORMAL) -DBENCH_BUILD tty.c -o tty-t.o

*_fmt_plug.c: Makefile.legacy john.c
	@

fmt_externs.h: $(PLUGFORMATS_SRCS) Makefile.legacy *_fmt_plug.c
	$(CC) -E -P $(CFLAGS) -DFMT_EXTERNS_H *_fmt_plug.c | LC_ALL=C $(GREP) "extern struct fmt_main" | LC_ALL=C $(SORT) -f > fmt_externs.h

fmt_registers.h: $(PLUGFORMATS_SRCS) Makefile.legacy *_fmt_plug.c
	$(CC) -E -P $(CFLAGS) -DFMT_REGISTERS_H *_fmt_plug.c | LC_ALL=C $(GREP) "john_register_one" | LC_ALL=C $(SORT) -f > fmt_registers.h

john.o: john.c fmt_externs.h fmt_registers.h
	$(CC) $(CFLAGS_MAIN) $(OPT_NORMAL) -O1 $*.c

path.o: path.c path.h arch.h params.h misc.h memory.h
	$(CC) $(CFLAGS_MAIN) $(OPT_NORMAL) -O1 $*.c

# Workaround for gcc 3.4.6 (seen on Sparc32) (do not use -funroll-loops)
unrarppm.o: unrarppm.c
	$(CC) $(CFLAGS) $< -o $@

.c.o:
	$(CC) $(CFLAGS) $(OPT_NORMAL) $< -o $@

.S.o:
	$(AS) $(ASFLAGS) $*.S

# We don't have any files with .s suffix, this is for compiling in DOS only
.s.o:
	$(AS) $(ASFLAGS) $*.S

# For jumbo, --make_check fails for the first thin format that is linked
# to a dynamic format in a config file, so we deviate from core here.
check:
	../run/john --test=0 --verbosity=2

depend:
	makedepend -fMakefile.dep -Y *.c 2>> /dev/null

test:
	cd ../test && perl jtrts.pl -q

test_full:
	cd ../test && perl jtrts.pl -q -type full

test_utf8:
	cd ../test && perl jtrts.pl -q -type utf-8

test_verbose:
	cd ../test && perl jtrts.pl

test_full_verbose:
	cd ../test && perl jtrts.pl -type full

test_utf8_verbose:
	cd ../test && perl jtrts.pl -type utf-8

bash-completion:
	@echo
	@echo NOTE: Administrative privileges required for this make target.
	[ -d $(DESTDIR)/etc/bash_completion.d ] && $(CP) ../run/john.bash_completion $(DESTDIR)/etc/bash_completion.d/ || true
	[ -d $(DESTDIR)/usr/local/etc/bash_completion.d ] && $(CP) ../run/john.bash_completion $(DESTDIR)/usr/local/etc/bash_completion.d/ || true
	[ -d $(DESTDIR)/opt/local/etc/bash_completion.d ] && $(CP) ../run/john.bash_completion $(DESTDIR)/opt/local/etc/bash_completion.d/ || true
	@echo
	@echo Bash-completion for JtR opportunistically installed.
	@echo Source \". ../run/john.bash_completion\" or logout/login to activate the changes

zsh-completion:
	@echo
	@echo NOTE: Administrative privileges required for this make target.
	[ -d $(DESTDIR)/usr/share/zsh/functions/Completion/Unix ] && $(CP) ../run/john.zsh_completion $(DESTDIR)/usr/share/zsh/functions/Completion/Unix/_john || true
	[ -d $(DESTDIR)/usr/share/zsh/site-functions ] && $(CP) ../run/john.zsh_completion $(DESTDIR)/usr/share/zsh/site-functions/_john || true
	[ -d $(DESTDIR)/usr/local/share/zsh/site-functions ] && $(CP) ../run/john.zsh_completion $(DESTDIR)/usr/local/share/zsh/site-functions/_john || true
	@echo
	@echo zsh-completion for JtR opportunistically installed.
	@echo Source \". ../run/john.zsh_completion\" or logout/login to activate the changes

shell-completion: bash-completion zsh-completion
	@echo
	@echo "You should have bash and zsh completion now"

kernel-cache-clean-nvidia:
	$(RM) -fr ~/.nv/ComputeCache

kernel-cache-clean-john:
	$(RM) -f ../run/opencl/*.bin ../run/opencl/*.config

kernel-cache-clean: kernel-cache-clean-nvidia kernel-cache-clean-john

clean:
	$(RM) $(PROJ) $(PROJ_DOS) $(PROJ_WIN32) $(PROJ_WIN32_MINGW)
	$(RM) $(PROJ_PCAP)
	$(RM) ../run/john.exe john-macosx-* *.o yescrypt/*.o *.bak core
	$(RM) lzma/*.o
	$(RM) detect bench generic.h arch.h tmp.s
	$(RM) *~
	$(RM) dynamic_big_crypt.c fmt_registers.h fmt_externs.h john_build_rule.h version.h version.h.new
	$(CP) $(NULL) Makefile.dep
	+$(MAKE_ORIG) -C mbedtls clean
	+$(MAKE_ORIG) -C secp256k1 clean
	+$(MAKE_ORIG) -C ed25519-donna clean
	+$(MAKE_ORIG) -C poly1305-donna clean


# These are mostly for internal use.
charsets: ../run/ascii.chr ../run/alpha.chr ../run/lowernum.chr ../run/uppernum.chr ../run/lowerspace.chr ../run/lower.chr ../run/upper.chr ../run/digits.chr ../run/alnum.chr ../run/lanman.chr ../run/lm_ascii.chr ../run/alnumspace.chr ../run/latin1.chr ../run/utf8.chr

../run/ascii.chr: charset.c params.h
	../run/john -make-charset=../run/ascii.chr -pot:rockyou.ansi.pot -ext:filter_ascii

../run/alpha.chr: charset.c params.h
	../run/john -make-charset=../run/alpha.chr -pot:rockyou.ansi.pot -ext:filter_alpha

../run/lowernum.chr: charset.c params.h
	../run/john -make-charset=../run/lowernum.chr -pot:rockyou.ansi.pot -ext:filter_lowernum

../run/uppernum.chr: charset.c params.h
	../run/john -make-charset=../run/uppernum.chr -pot:rockyou.ansi.pot -ext:filter_uppernum

../run/lowerspace.chr: charset.c params.h
	../run/john -make-charset=../run/lowerspace.chr -pot:rockyou.ansi.pot -ext:filter_lowerspace

../run/lower.chr: charset.c params.h
	../run/john -make-charset=../run/lower.chr -pot:rockyou.ansi.pot -ext:filter_lower

../run/upper.chr: charset.c params.h
	../run/john -make-charset=../run/upper.chr -pot:rockyou.ansi.pot -ext:filter_upper

../run/digits.chr: charset.c params.h
	../run/john -make-charset=../run/digits.chr -pot:rockyou.ansi.pot -ext:filter_digits

../run/alnum.chr: charset.c params.h
	../run/john -make-charset=../run/alnum.chr -pot:rockyou.ansi.pot -ext:filter_alnum

../run/lanman.chr: charset.c params.h
	../run/john -make-charset=../run/lanman.chr -pot:rockyou.lm850.pot -ext:filter_lanman

../run/lm_ascii.chr: charset.c params.h
	../run/john -make-charset=../run/lm_ascii.chr -pot:rockyou.lm850.pot -ext:filter_lm_ascii

../run/alnumspace.chr: charset.c params.h
	../run/john -make-charset=../run/alnumspace.chr -pot:rockyou.ansi.pot -ext:filter_alnumspace

../run/latin1.chr: charset.c params.h
	../run/john -make-charset=../run/latin1.chr -pot:rockyou.ansi.16.pot

../run/utf8.chr: charset.c params.h
	../run/john -make-charset=../run/utf8.chr -pot:rockyou.utf8.24.pot

include Makefile.dep
