Makefile 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. #
  2. # OpenSSL/crypto/Makefile
  3. #
  4. DIR= fips
  5. TOP= ..
  6. CC= cc
  7. INCLUDE= -I. -I$(TOP) -I../include
  8. # INCLUDES targets sudbirs!
  9. INCLUDES= -I.. -I../.. -I../../include
  10. CFLAG= -g
  11. MAKEDEPPROG= makedepend
  12. MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
  13. MAKEFILE= Makefile
  14. RM= rm -f
  15. AR= ar r
  16. ARD= ar d
  17. TEST= fips_test_suite.c
  18. FIPS_TVDIR= testvectors
  19. FIPS_TVOK= $$HOME/fips/tv.ok
  20. FIPSCANLOC= $(FIPSLIBDIR)fipscanister.o
  21. RECURSIVE_MAKE= [ -n "$(FDIRS)" ] && for i in $(FDIRS) ; do \
  22. (cd $$i && echo "making $$target in $(DIR)/$$i..." && \
  23. $(MAKE) -e TOP=../.. DIR=$$i INCLUDES='${INCLUDES}' $$target ) || exit 1; \
  24. done;
  25. PEX_LIBS=
  26. EX_LIBS=
  27. CFLAGS= $(INCLUDE) $(CFLAG) -DHMAC_EXT=\"$${HMAC_EXT:-sha1}\"
  28. ASFLAGS= $(INCLUDE) $(ASFLAG)
  29. AFLAGS=$(ASFLAGS)
  30. LIBS=
  31. FDIRS=sha rand des aes dsa ecdh ecdsa rsa dh cmac hmac utl
  32. GENERAL=Makefile README fips-lib.com install.com
  33. LIB= $(TOP)/libcrypto.a
  34. SHARED_LIB= $(FIPSCANLIB)$(SHLIB_EXT)
  35. LIBSRC=fips.c fips_post.c
  36. LIBOBJ=fips.o fips_post.o
  37. FIPS_OBJ_LISTS=sha/lib hmac/lib rand/lib des/lib aes/lib dsa/lib rsa/lib \
  38. dh/lib utl/lib ecdsa/lib cmac/lib
  39. SRC= $(LIBSRC)
  40. EXHEADER=fips.h fipssyms.h
  41. HEADER=$(EXHEADER) fips_utl.h fips_locl.h
  42. EXE=fipsld
  43. ALL= $(GENERAL) $(SRC) $(HEADER)
  44. top:
  45. @(cd ..; $(MAKE) DIRS=$(DIR) all)
  46. testapps:
  47. @if [ -z "$(THIS)" ]; then $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; fi
  48. all:
  49. @if [ -n "$(FIPSCANISTERONLY)" ]; then \
  50. $(MAKE) -e subdirs lib ; \
  51. elif [ -z "$(FIPSLIBDIR)" ]; then \
  52. $(MAKE) -e subdirs lib fips_premain_dso$(EXE_EXT); \
  53. else \
  54. $(MAKE) -e lib fips_premain_dso$(EXE_EXT) fips_standalone_sha1$(EXE_EXT); \
  55. fi
  56. # Idea behind fipscanister.o is to "seize" the sequestered code between
  57. # known symbols for fingerprinting purposes, which would be commonly
  58. # done with ld -r start.o ... end.o. The latter however presents a minor
  59. # challenge on multi-ABI platforms. As just implied, we'd rather use ld,
  60. # but the trouble is that we don't generally know how ABI-selection
  61. # compiler flag is translated to corresponding linker flag. All compiler
  62. # drivers seem to recognize -r flag and pass it down to linker, but some
  63. # of them, including gcc, erroneously add -lc, as well as run-time
  64. # components, such as crt1.o and alike. Fortunately among those vendor
  65. # compilers which were observed to misinterpret -r flag multi-ABI ones
  66. # are equipped with smart linkers, which don't require any ABI-selection
  67. # flag and simply assume that all objects are of the same type as first
  68. # one in command line. So the idea is to identify gcc and deficient
  69. # vendor compiler drivers...
  70. fipscanister.o: fips_start.o $(LIBOBJ) $(FIPS_OBJ_LISTS) fips_end.o
  71. FIPS_ASM=""; \
  72. list="$(BN_ASM)"; for i in $$list; do FIPS_ASM="$$FIPS_ASM ../crypto/bn/$$i" ; done; \
  73. list="$(AES_ENC)"; for i in $$list; do FIPS_ASM="$$FIPS_ASM ../crypto/aes/$$i" ; done; \
  74. list="$(DES_ENC)"; for i in $$list; do FIPS_ASM="$$FIPS_ASM ../crypto/des/$$i" ; done; \
  75. list="$(SHA1_ASM_OBJ)"; for i in $$list; do FIPS_ASM="$$FIPS_ASM ../crypto/sha/$$i" ; done; \
  76. list="$(MODES_ASM_OBJ)"; for i in $$list; do FIPS_ASM="$$FIPS_ASM ../crypto/modes/$$i" ; done; \
  77. if [ -n "$(CPUID_OBJ)" ]; then \
  78. CPUID=../crypto/$(CPUID_OBJ) ; \
  79. else \
  80. CPUID="" ; \
  81. fi ; \
  82. objs="fips_start.o $(LIBOBJ) $(FIPS_EX_OBJ) $$CPUID $$FIPS_ASM"; \
  83. for i in $(FIPS_OBJ_LISTS); do \
  84. dir=`dirname $$i`; script="s|^|$$dir/|;s| | $$dir/|g"; \
  85. objs="$$objs `sed "$$script" $$i`"; \
  86. done; \
  87. objs="$$objs fips_end.o" ; \
  88. os="`(uname -s) 2>/dev/null`"; cflags="$(CFLAGS)"; \
  89. [ "$$os" = "AIX" ] && cflags="$$cflags -Wl,-bnoobjreorder"; \
  90. if [ -n "${FIPS_SITE_LD}" ]; then \
  91. set -x; ${FIPS_SITE_LD} -r -o $@ $$objs; \
  92. elif $(CC) -dumpversion >/dev/null 2>&1; then \
  93. set -x; $(CC) $$cflags -r -nostdlib -o $@ $$objs ; \
  94. else case "$$os" in \
  95. HP-UX|OSF1|SunOS) set -x; /usr/ccs/bin/ld -r -o $@ $$objs ;; \
  96. *) set -x; $(CC) $$cflags -r -o $@ $$objs ;; \
  97. esac fi
  98. ./fips_standalone_sha1$(EXE_EXT) fipscanister.o > fipscanister.o.sha1
  99. # If another exception is immediately required, assign approprite
  100. # site-specific ld command to FIPS_SITE_LD environment variable.
  101. fips_start.o: fips_canister.c
  102. $(CC) $(CFLAGS) -DFIPS_START -c -o $@ fips_canister.c
  103. fips_end.o: fips_canister.c
  104. $(CC) $(CFLAGS) -DFIPS_END -c -o $@ fips_canister.c
  105. fips_premain_dso$(EXE_EXT): fips_premain.c
  106. $(CC) $(CFLAGS) -DFINGERPRINT_PREMAIN_DSO_LOAD -o $@ fips_premain.c \
  107. $(FIPSLIBDIR)fipscanister.o ../libcrypto.a $(EX_LIBS)
  108. # this is executed only when linking with external fipscanister.o
  109. fips_standalone_sha1$(EXE_EXT): sha/fips_standalone_sha1.c
  110. if [ -z "$(HOSTCC)" ] ; then \
  111. $(CC) $(CFLAGS) -DFIPSCANISTER_O -o $@ sha/fips_standalone_sha1.c $(FIPSLIBDIR)fipscanister.o $(EX_LIBS) ; \
  112. else \
  113. $(HOSTCC) $(HOSTCFLAGS) -o $ $@ -I../include -I../crypto sha/fips_standalone_sha1.c ../crypto/sha/sha1dgst.c ; \
  114. fi
  115. subdirs:
  116. @target=all; $(RECURSIVE_MAKE)
  117. files:
  118. $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
  119. @target=files; $(RECURSIVE_MAKE)
  120. links:
  121. @$(PERL) $(TOP)/util/mklink.pl ../include/openssl $(EXHEADER)
  122. @$(PERL) $(TOP)/util/mklink.pl ../test $(TEST)
  123. @target=links; $(RECURSIVE_MAKE)
  124. # lib: and $(LIB): are splitted to avoid end-less loop
  125. lib: $(LIB)
  126. if [ "$(FIPSCANISTERINTERNAL)" = "n" -a -n "$(FIPSCANLOC)" ]; then $(AR) ../$(FIPSCANLIB).a $(FIPSCANLOC); fi
  127. @touch lib
  128. $(LIB): $(FIPSLIBDIR)fipscanister.o
  129. $(AR) $(LIB) $(FIPSLIBDIR)fipscanister.o
  130. $(RANLIB) $(LIB) || echo Never mind.
  131. $(FIPSCANLIB): $(FIPSCANLOC)
  132. $(AR) ../$(FIPSCANLIB).a $(FIPSCANLOC)
  133. if [ "$(FIPSCANLIB)" = "libfips" ]; then \
  134. $(AR) $(LIB) $(FIPSCANLOC) ; \
  135. $(RANLIB) $(LIB) || echo Never Mind. ; \
  136. fi
  137. $(RANLIB) ../$(FIPSCANLIB).a || echo Never mind.
  138. @touch lib
  139. shared: lib subdirs fips_premain_dso$(EXE_EXT)
  140. libs:
  141. @target=lib; $(RECURSIVE_MAKE)
  142. fips_test: top
  143. @target=fips_test; $(RECURSIVE_MAKE)
  144. fips_test_diff:
  145. @if diff -b -B -I '^\#' -cr -X fips-nodiff.txt $(FIPS_TVDIR) $(FIPS_TVOK) ; then \
  146. echo "FIPS diff OK" ; \
  147. else \
  148. echo "***FIPS DIFF ERROR***" ; exit 1 ; \
  149. fi
  150. install:
  151. @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
  152. @headerlist="$(EXHEADER)"; for i in $$headerlist ;\
  153. do \
  154. (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
  155. chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
  156. done;
  157. @target=install; $(RECURSIVE_MAKE)
  158. for i in $(EXE) ; \
  159. do \
  160. echo "installing $$i"; \
  161. cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
  162. chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
  163. mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i; \
  164. done
  165. cp -p -f $(FIPSLIBDIR)fipscanister.o $(FIPSLIBDIR)fipscanister.o.sha1 \
  166. $(FIPSLIBDIR)fips_premain.c $(FIPSLIBDIR)fips_premain.c.sha1 \
  167. $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/; \
  168. chmod 0444 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/fips*
  169. lint:
  170. @target=lint; $(RECURSIVE_MAKE)
  171. depend:
  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
  175. clean:
  176. rm -f fipscanister.o.sha1 fips_premain_dso$(EXE_EXT) fips_standalone_sha1$(EXE_EXT) \
  177. *.s *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
  178. @target=clean; $(RECURSIVE_MAKE)
  179. dclean:
  180. $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
  181. mv -f Makefile.new $(MAKEFILE)
  182. @target=dclean; $(RECURSIVE_MAKE)
  183. # DO NOT DELETE THIS LINE -- make depend depends on it.
  184. fips.o: ../include/openssl/asn1.h ../include/openssl/bio.h
  185. fips.o: ../include/openssl/crypto.h ../include/openssl/des.h
  186. fips.o: ../include/openssl/des_old.h ../include/openssl/dsa.h
  187. fips.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
  188. fips.o: ../include/openssl/ecdsa.h ../include/openssl/err.h
  189. fips.o: ../include/openssl/evp.h ../include/openssl/fips.h
  190. fips.o: ../include/openssl/fips_rand.h ../include/openssl/hmac.h
  191. fips.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
  192. fips.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
  193. fips.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
  194. fips.o: ../include/openssl/rand.h ../include/openssl/rsa.h
  195. fips.o: ../include/openssl/safestack.h ../include/openssl/stack.h
  196. fips.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
  197. fips.o: ../include/openssl/ui_compat.h fips.c fips_locl.h