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