2 # OpenSSL/crypto/Makefile
8 INCLUDE= -I. -I$(TOP) -I../include
9 # INCLUDES targets sudbirs!
10 INCLUDES= -I.. -I../.. -I../../include
12 MAKEDEPPROG= makedepend
13 MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
18 TEST= fips_test_suite.c
19 FIPS_TVDIR= testvectors
20 FIPS_TVOK= $$HOME/fips/tv.ok
22 FIPSCANLOC= $(FIPSLIBDIR)fipscanister.o
24 RECURSIVE_MAKE= [ -n "$(FDIRS)" ] && for i in $(FDIRS) ; do \
25 (cd $$i && echo "making $$target in $(DIR)/$$i..." && \
26 $(MAKE) -e TOP=../.. DIR=$$i INCLUDES='${INCLUDES}' $$target ) || exit 1; \
32 CFLAGS= $(INCLUDE) $(CFLAG) -DHMAC_EXT=\"$${HMAC_EXT:-sha1}\"
33 ASFLAGS= $(INCLUDE) $(ASFLAG)
38 FDIRS=sha rand des aes dsa rsa dh hmac
40 GENERAL=Makefile README fips-lib.com install.com
42 LIB= $(TOP)/libcrypto.a
43 SHARED_LIB= $(FIPSCANLIB)$(SHLIB_EXT)
47 FIPS_OBJ_LISTS=sha/lib hmac/lib rand/lib des/lib aes/lib dsa/lib rsa/lib dh/lib
52 HEADER=$(EXHEADER) fips_utl.h
55 ALL= $(GENERAL) $(SRC) $(HEADER)
58 @(cd ..; $(MAKE) DIRS=$(DIR) all)
61 @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
64 @if [ -n "$(FIPSCANLIB)" ]; then \
65 $(MAKE) -e subdirs lib shared; \
68 # Idea behind fipscanister.o is to "seize" the sequestered code between
69 # known symbols for fingerprinting purposes, which would be commonly
70 # done with ld -r start.o ... end.o. The latter however presents a minor
71 # challenge on multi-ABI platforms. As just implied, we'd rather use ld,
72 # but the trouble is that we don't generally know how ABI-selection
73 # compiler flag is translated to corresponding linker flag. All compiler
74 # drivers seem to recognize -r flag and pass it down to linker, but some
75 # of them, including gcc, erroneously add -lc, as well as run-time
76 # components, such as crt1.o and alike. Fortunately among those vendor
77 # compilers which were observed to misinterpret -r flag multi-ABI ones
78 # are equipped with smart linkers, which don't require any ABI-selection
79 # flag and simply assume that all objects are of the same type as first
80 # one in command line. So the idea is to identify gcc and deficient
81 # vendor compiler drivers...
83 fipscanister.o: fips_start.o $(LIBOBJ) $(FIPS_OBJ_LISTS) fips_end.o
84 @FIPS_BN_ASM=""; for i in $(BN_ASM) ; do FIPS_BN_ASM="$$FIPS_BN_ASM ../crypto/bn/$$i" ; done; \
85 if [ -n "$(CPUID_OBJ)" ]; then \
86 CPUID=../crypto/$(CPUID_OBJ) ; \
90 objs="fips_start.o $(LIBOBJ) $(FIPS_EX_OBJ) $$CPUID $$FIPS_BN_ASM"; \
91 for i in $(FIPS_OBJ_LISTS); do \
92 dir=`dirname $$i`; script="s|^|$$dir/|;s| | $$dir/|g"; \
93 objs="$$objs `sed "$$script" $$i`"; \
95 objs="$$objs fips_end.o" ; \
96 if [ -n "${FIPS_SITE_LD}" ]; then \
97 set -x; ${FIPS_SITE_LD} -r -o $@ $$objs; \
98 elif $(CC) -dumpversion >/dev/null 2>&1; then \
99 set -x; $(CC) $(CFLAGS) -r -nostdlib -o $@ $$objs ; \
100 else case "`(uname -s) 2>/dev/null`" in \
101 HP-UX|OSF1|SunOS) set -x; /usr/ccs/bin/ld -r -o $@ $$objs ;; \
102 AIX) set -x; $(CC) $(CFLAGS) -Wl,-bnoobjreorder -r -o $@ $$objs ;; \
103 *) set -x; $(CC) $(CFLAGS) -r -o $@ $$objs ;; \
105 sha/fips_standalone_sha1 fipscanister.o > fipscanister.o.sha1
107 # If another exception is immediately required, assign approprite
108 # site-specific ld command to FIPS_SITE_LD environment variable.
110 fips_start.o: fips_canister.c
111 $(CC) $(CFLAGS) -DFIPS_START -c -o $@ fips_canister.c
112 fips_end.o: fips_canister.c
113 $(CC) $(CFLAGS) -DFIPS_END -c -o $@ fips_canister.c
114 fips_premain_dso$(EXE_EXT): fips_premain.c
115 $(CC) $(CFLAGS) -DFINGERPRINT_PREMAIN_DSO_LOAD -o $@ fips_premain.c \
116 ../libcrypto.a $(EX_LIBS)
119 @target=all; $(RECURSIVE_MAKE)
122 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
123 @target=files; $(RECURSIVE_MAKE)
126 @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER)
127 @$(PERL) $(TOP)/util/mklink.pl ../test $(TEST)
128 @target=links; $(RECURSIVE_MAKE)
130 # lib: and $(LIB): are splitted to avoid end-less loop
131 lib: $(FIPSCANLIB) $(FIPSCANLOC)
134 $(FIPSCANLIB): $(FIPSCANLOC)
135 $(AR) ../$(FIPSCANLIB).a $(FIPSCANLOC)
136 if [ "$(FIPSCANLIB)" = "libfips" ]; then \
137 $(AR) $(LIB) $(FIPSCANLOC) ; \
138 $(RANLIB) $(LIB) || echo Never Mind. ; \
140 $(RANLIB) ../$(FIPSCANLIB).a || echo Never mind.
143 shared: lib subdirs fips_premain_dso$(EXE_EXT)
146 @target=lib; $(RECURSIVE_MAKE)
149 @target=fips_test; $(RECURSIVE_MAKE)
152 @if diff -b -B -I '^\#' -cr -X fips-nodiff.txt $(FIPS_TVDIR) $(FIPS_TVOK) ; then \
153 echo "FIPS diff OK" ; \
155 echo "***FIPS DIFF ERROR***" ; exit 1 ; \
160 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
161 @headerlist="$(EXHEADER)"; for i in $$headerlist ;\
163 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
164 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
166 @target=install; $(RECURSIVE_MAKE)
169 @target=lint; $(RECURSIVE_MAKE)
172 @[ -z "$(THIS)" ] || $(MAKEDEPEND) -- $(CFLAG) $(INCLUDE) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
173 @[ -z "$(THIS)" ] || (set -e; target=depend; $(RECURSIVE_MAKE) )
174 @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
177 rm -f fipscanister.o.sha1 fips_premain_dso$(EXE_EXT) \
178 *.s *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
179 @target=clean; $(RECURSIVE_MAKE)
182 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
183 mv -f Makefile.new $(MAKEFILE)
184 @target=dclean; $(RECURSIVE_MAKE)
186 # DO NOT DELETE THIS LINE -- make depend depends on it.
188 fips.o: ../include/openssl/asn1.h ../include/openssl/bio.h
189 fips.o: ../include/openssl/crypto.h ../include/openssl/des.h
190 fips.o: ../include/openssl/des_old.h ../include/openssl/e_os2.h
191 fips.o: ../include/openssl/err.h ../include/openssl/evp.h
192 fips.o: ../include/openssl/fips.h ../include/openssl/fips_rand.h
193 fips.o: ../include/openssl/hmac.h ../include/openssl/lhash.h
194 fips.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
195 fips.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
196 fips.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
197 fips.o: ../include/openssl/safestack.h ../include/openssl/stack.h
198 fips.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
199 fips.o: ../include/openssl/ui_compat.h fips.c fips_locl.h