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 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 47$(CRYPTO:%=sha1_64_%) := OBJS = sha1.64.o 48$(CRYPTO:%=sha256_64_%) := OBJS = sha256.64.o 49$(CRYPTO:%=sha384_64_%) := OBJS = sha384.64.o 50$(CRYPTO:%=sha512_64_%) := OBJS = sha512.64.o 51$(CRYPTO:%=sha512_224_64_%) := OBJS = sha512_224.64.o 52$(CRYPTO:%=sha512_256_64_%) := OBJS = sha512_256.64.o 53 54$(PROGS_32) := OBJS_COMMON = main.32.o $(COMMONDIR)/testfuncs.32.o 55$(PROGS_64) := OBJS_COMMON = main.64.o $(COMMONDIR)/testfuncs.64.o 56$(PROGS_pkcs_32) := OBJS_COMMON += $(COMMONDIR)/cryptotest_pkcs.32.o 57$(PROGS_pkcs_64) := OBJS_COMMON += $(COMMONDIR)/cryptotest_pkcs.64.o 58$(PROGS_kcf_32) := OBJS_COMMON += $(COMMONDIR)/cryptotest_kcf.32.o 59$(PROGS_kcf_64) := OBJS_COMMON += $(COMMONDIR)/cryptotest_kcf.64.o 60 61CSTD = $(CSTD_GNU99) 62 63CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 64CPPFLAGS += -I$(COMMONDIR) -I$(SRC)/common/crypto 65 66LINTFLAGS += -xerroff=E_NAME_USED_NOT_DEF2 67LINTFLAGS += -xerroff=E_NAME_DEF_NOT_USED2 68 69$(PROGS_pkcs) := LDLIBS += -lpkcs11 -lcryptoutil 70 71CMDS_pkcs = $(PROGS_pkcs:%_pkcs=$(TESTDIR_pkcs)/%) 72CMDS_kcf = $(PROGS_kcf:%_kcf=$(TESTDIR_kcf)/%) 73CMDS = $(CMDS_pkcs) $(CMDS_kcf) 74 75$(CMDS) := FILEMODE = 0555 76 77all: $(PROGS) 78 79$(PROGS): main.32.o main.64.o 80 81%_32_pkcs: %.32.o 82 $(LINK.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS) 83 $(POST_PROCESS) 84 85%_64_pkcs: %.64.o 86 $(LINK64.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS) 87 $(POST_PROCESS) 88 89%_32_kcf: %.32.o 90 $(LINK.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS) 91 $(POST_PROCESS) 92 93%_64_kcf: %.64.o 94 $(LINK64.c) -o $@ $(OBJS) $(OBJS_COMMON) $(LDLIBS) 95 $(POST_PROCESS) 96 97%.32.o: %.c 98 $(COMPILE.c) -o $@ $< 99 $(POST_PROCESS_O) 100 101%.64.o: %.c 102 $(COMPILE64.c) -o $@ $< 103 $(POST_PROCESS_O) 104 105 106install: all $(CMDS) 107 108lint: $(CRYPTO:%=lint_%) 109lint_pkcs: $(ALGS:%=lint_pkcs_%) 110lint_kcf: $(ALGS_kcf:%=lint_kcf_%) 111 112lint_pkcs_%: 113 $(LINT.c) main.c $(@:lint_pkcs_%=%.c) $(OBJS_COMMON:%.o=%.c) $(LDLIBS) 114 115lint_pcf_%: 116 $(LINT.c) main.c $(@:lint_kcf_%=%.c) $(OBJS_COMMON:%.o=%.c) $(LDLIBS) 117 118clobber: clean 119 -$(RM) $(PROGS) 120 121clean: 122 -$(RM) $(ALGS:%=%.32.o) $(ALGS:%=%.64.o) main.32.o main.64.o 123 124$(CMDS): $(TESTDIR_pkcs) $(TESTDIR_kcf) $(PROGS) 125 126$(TESTDIR_pkcs) $(TESTDIR_kcf): 127 $(INS.dir) 128 129$(TESTDIR_pkcs)/%_32: %_32_pkcs 130 $(INS.rename) 131 132$(TESTDIR_pkcs)/%_64: %_64_pkcs 133 $(INS.rename) 134 135$(TESTDIR_kcf)/%_32: %_32_kcf 136 $(INS.rename) 137 138$(TESTDIR_kcf)/%_64: %_64_kcf 139 $(INS.rename) 140