|
| 1 | +PERL = perl |
| 2 | +CONFIGURE = ./Configure |
| 3 | +COPT = no-shared no-symlinks |
| 4 | + |
| 5 | +ARCHS = BSD-x86 BSD-x86_64 VC-WIN32 VC-WIN64A darwin64-x86_64-cc \ |
| 6 | +darwin-i386-cc linux-armv4 linux-elf linux-x86_64 solaris-x86-gcc \ |
| 7 | +solaris64-x86_64-gcc |
| 8 | + |
| 9 | +CFG = opensslconf.h |
| 10 | +SRC_CFG = ../openssl/crypto/$(CFG) |
| 11 | +BACKUP_FILES = ../openssl/Makefile ../openssl/Makefile.bak $(SRC_CFG) |
| 12 | +BACKUP_EXT = iojsbackup |
| 13 | + |
| 14 | +# OPENSSL_CPUID_OBJ is defined in openssl.gypi for use --openssl-no-asm |
| 15 | +CPUIDFIX = 's/\#define OPENSSL_CPUID_OBJ$$//;' |
| 16 | + |
| 17 | +X32FIX = 's/\#define OPENSSL_CPUID_OBJ$$//;\ |
| 18 | +s/RC4_CHUNK unsigned long$$/RC4_CHUNK unsigned long long/;\ |
| 19 | +s/define SIXTY_FOUR_BIT_LONG$$/undef SIXTY_FOUR_BIT_LONG/;\ |
| 20 | +s/undef SIXTY_FOUR_BIT$$/define SIXTY_FOUR_BIT/;' |
| 21 | + |
| 22 | +MACFIX ='s/define RC4_INT unsigned char$$/define RC4_INT unsigned int/;' |
| 23 | + |
| 24 | +WINFIX = 'if(/ifndef OPENSSL_DOING_MAKEDEPEND$$/){\ |
| 25 | +print "\n\#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n";\ |
| 26 | +print "\# define OPENSSL_NO_DYNAMIC_ENGINE\n";\ |
| 27 | +print "\#endif\n";\ |
| 28 | +print "\#ifndef OPENSSL_NO_CAPIENG\n";\ |
| 29 | +print "\# define OPENSSL_NO_CAPIENG\n";\ |
| 30 | +print "\#endif\n\n";}' |
| 31 | + |
| 32 | +PHONY = all clean backup restore |
| 33 | +.PHONY: $(PHONY) |
| 34 | + |
| 35 | +all: backup $(ARCHS) linux-x32 cleanconf fixdarwin64 fixwin restore |
| 36 | + |
| 37 | +$(ARCHS): |
| 38 | + cd ../openssl; $(PERL) $(CONFIGURE) $(COPT) $@ > /dev/null |
| 39 | + $(PERL) -p -e $(CPUIDFIX) $(SRC_CFG) > ./archs/$@/$(CFG) |
| 40 | + |
| 41 | +# linux-x32 was made by comparing define values of opensslconf.h which |
| 42 | +# was generated `Configure linux-x32' in openssl-1.0.2a |
| 43 | +linux-x32: |
| 44 | + cd ../openssl; $(PERL) $(CONFIGURE) $(COPT) linux-x86_64 > /dev/null; |
| 45 | + $(PERL) -p -e $(X32FIX) $(SRC_CFG) > ./archs/$@/$(CFG) |
| 46 | + |
| 47 | +# The current openssl release does not use RC4 asm since it explicitly |
| 48 | +# specified as `$asm=~s/rc4\-[^:]+//;` in |
| 49 | +# https://github.com/openssl/openssl/blob/OpenSSL_1_0_1-stable/Configure#L584 |
| 50 | +# But iojs has used RC4 asm on MacOS for long time. Fix type of RC4_INT |
| 51 | +# into `unsigned int` in opensslconf.h of darwin64-x86_64-cc to work on |
| 52 | +# the RC4 asm. |
| 53 | +fixdarwin64: |
| 54 | + $(PERL) -pi -e $(MACFIX) ./archs/darwin64-x86_64-cc/$(CFG) |
| 55 | + |
| 56 | + |
| 57 | +# OPENSSL_NO_DYNAMIC_ENGINE is needed for building static |
| 58 | +# library. OPENSSL_NO_CAPIENG is needed to avoid build errors on |
| 59 | +# Win. See the comments in `deps/openssl/openssl/engines/e_capi.c` for |
| 60 | +# detail. |
| 61 | +fixwin: |
| 62 | + $(PERL) -pi -e $(WINFIX) ./archs/VC-WIN32/$(CFG) ./archs/VC-WIN64A/$(CFG) |
| 63 | + |
| 64 | +# backup files to avoid to be overwritten |
| 65 | +backup: |
| 66 | + @for f in $(BACKUP_FILES); do \ |
| 67 | + mv $$f $$f.$(BACKUP_EXT); \ |
| 68 | + done |
| 69 | + |
| 70 | +restore: |
| 71 | + @for f in $(BACKUP_FILES); do \ |
| 72 | + mv $$f.$(BACKUP_EXT) $$f ; \ |
| 73 | + done |
| 74 | + |
| 75 | +# remove unnecessary files create by Configure |
| 76 | +cleanconf: |
| 77 | + @rm ../openssl/crypto/$(CFG) |
| 78 | + @rm ../openssl/Makefile |
| 79 | + @rm ../openssl/apps/CA.pl.bak |
| 80 | + @rm ../openssl/crypto/buildinf.h |
| 81 | + @rm ../openssl/crypto/$(CFG).bak |
| 82 | + @rm ../openssl/ms/version32.rc |
| 83 | + @rm ../openssl/tools/c_rehash.bak |
| 84 | + |
| 85 | +clean: |
| 86 | + find archs -name $(CFG) -exec rm "{}" \; |
0 commit comments