1# 2# This file and its contents are supplied under the terms of the 3# Common Development and Distribution License ("CDDL"), version 1.0. 4# You may only use this file in accordance with the terms of version 5# 1.0 of the CDDL. 6# 7# A full copy of the text of the CDDL should have accompanied this 8# source. A copy of the CDDL is also available via the Internet at 9# http://www.illumos.org/license/CDDL. 10# 11 12# 13# Copyright 2018, Joyent, Inc. 14# 15 16include $(SRC)/cmd/Makefile.cmd 17include $(SRC)/test/Makefile.com 18include $(SRC)/cmd/Makefile.ctf 19 20ALGS = sha1 sha256 sha384 sha512 sha512_224 sha512_256 md5 21CRYPTO = pkcs kcf 22 23PROGS_pkcs_32 = $(ALGS:%=%_32_pkcs) 24PROGS_pkcs_64 = $(ALGS:%=%_64_pkcs) 25PROGS_kcf_32 = $(ALGS:%=%_32_kcf) 26PROGS_kcf_64 = $(ALGS:%=%_64_kcf) 27PROGS_pkcs = $(PROGS_pkcs_32) $(PROGS_pkcs_64) 28PROGS_kcf = $(PROGS_kcf_32) $(PROGS_kcf_64) 29PROGS_32 = $(PROGS_pkcs_32) $(PROGS_kcf_32) 30PROGS_64 = $(PROGS_pkcs_64) $(PROGS_kcf_64) 31PROGS = $(PROGS_32) $(PROGS_64) 32 33ROOTOPTPKG = $(ROOT)/opt/crypto-tests 34TESTROOT = $(ROOTOPTPKG)/tests/digest 35TESTDIR_pkcs = $(TESTROOT)/pkcs 36TESTDIR_kcf = $(TESTROOT)/kcf 37 38COMMONDIR = ../common 39 40$(CRYPTO:%=sha1_32_%) := OBJS = sha1.32.o 41$(CRYPTO:%=sha256_32_%) := OBJS = sha256.32.o 42$(CRYPTO:%=sha384_32_%) := OBJS = sha384.32.o 43$(CRYPTO:%=sha512_32_%) := OBJS = sha512.32.o 44$(CRYPTO:%=sha512_224_32_%) := OBJS = sha512_224.32.o 45$(CRYPTO:%=sha512_256_32_%) := OBJS = sha512_256.32.o 46$(CRYPTO:%=md5_32_%) := OBJS = md5.32.o 47 48$(CRYPTO:%=sha1_64_%) := OBJS = sha1.64.o 49$(CRYPTO:%=sha256_64_%) := OBJS = sha256.64.o 50$(CRYPTO:%=sha384_64_%) := OBJS = sha384.64.o 51$(CRYPTO:%=sha512_64_%) := OBJS = sha512.64.o 52$(CRYPTO:%=sha512_224_64_%) := OBJS = sha512_224.64.o 53$(CRYPTO:%=sha512_256_64_%) := OBJS = sha512_256.64.o 54$(CRYPTO:%=md5_64_%) := OBJS = md5.64.o 55 56$(PROGS_32) := OBJS_COMMON = main.32.o $(COMMONDIR)/testfuncs.32.o 57$(PROGS_64) := OBJS_COMMON = main.64.o $(COMMONDIR)/testfuncs.64.o 58$(PROGS_pkcs_32) := OBJS_COMMON += $(COMMONDIR)/cryptotest_pkcs.32.o 59$(PROGS_pkcs_64) := OBJS_COMMON += $(COMMONDIR)/cryptotest_pkcs.64.o 60$(PROGS_kcf_32) := OBJS_COMMON += $(COMMONDIR)/cryptotest_kcf.32.o 61$(PROGS_kcf_64) := OBJS_COMMON += $(COMMONDIR)/cryptotest_kcf.64.o 62 63CSTD = $(CSTD_GNU99) 64 65CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 66CPPFLAGS += -I$(COMMONDIR) -I$(SRC)/common/crypto 67 68LINTFLAGS += -xerroff=E_NAME_USED_NOT_DEF2 69LINTFLAGS += -xerroff=E_NAME_DEF_NOT_USED2 70 71$(PROGS_pkcs) := LDLIBS += -lpkcs11 -lcryptoutil 72 73CMDS_pkcs = $(PROGS_pkcs:%_pkcs=$(TESTDIR_pkcs)/%) 74CMDS_kcf = $(PROGS_kcf:%_kcf=$(TESTDIR_kcf)/%) 75CMDS = $(CMDS_pkcs) $(CMDS_kcf) 76 77$(CMDS) := FILEMODE = 0555 78 79all: $(PROGS) 80 81$(PROGS): main.32.o main.64.o 82 83%_32_pkcs: %.32.o 84 $(LINK.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS) 85 $(POST_PROCESS) 86 87%_64_pkcs: %.64.o 88 $(LINK64.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS) 89 $(POST_PROCESS) 90 91%_32_kcf: %.32.o 92 $(LINK.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS) 93 $(POST_PROCESS) 94 95%_64_kcf: %.64.o 96 $(LINK64.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS) 97 $(POST_PROCESS) 98 99%.32.o: %.c 100 $(COMPILE.c) -o $@ $< 101 $(POST_PROCESS_O) 102 103%.64.o: %.c 104 $(COMPILE64.c) -o $@ $< 105 $(POST_PROCESS_O) 106 107 108install: all $(CMDS) 109 110lint: $(CRYPTO:%=lint_%) 111lint_pkcs: $(ALGS:%=lint_pkcs_%) 112lint_kcf: $(ALGS_kcf:%=lint_kcf_%) 113 114lint_pkcs_%: 115 $(LINT.c) main.c $(@:lint_pkcs_%=%.c) $(OBJS_COMMON:%.o=%.c) $(LDLIBS) 116 117lint_pcf_%: 118 $(LINT.c) main.c $(@:lint_kcf_%=%.c) $(OBJS_COMMON:%.o=%.c) $(LDLIBS) 119 120clobber: clean 121 -$(RM) $(PROGS) 122 123clean: 124 -$(RM) $(ALGS:%=%.32.o) $(ALGS:%=%.64.o) main.32.o main.64.o 125 126$(CMDS): $(TESTDIR_pkcs) $(TESTDIR_kcf) $(PROGS) 127 128$(TESTDIR_pkcs) $(TESTDIR_kcf): 129 $(INS.dir) 130 131$(TESTDIR_pkcs)/%_32: %_32_pkcs 132 $(INS.rename) 133 134$(TESTDIR_pkcs)/%_64: %_64_pkcs 135 $(INS.rename) 136 137$(TESTDIR_kcf)/%_32: %_32_kcf 138 $(INS.rename) 139 140$(TESTDIR_kcf)/%_64: %_64_kcf 141 $(INS.rename) 142