Skip to content

Commit 4738ecd

Browse files
committed
Work around OpenSSL's weird build targets.
1 parent d0ece3d commit 4738ecd

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Makefile

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ OPENSSL_DIR-$(target)=build/$(os)/openssl-$(OPENSSL_VERSION)-$(target)
354354
OPENSSL_SSL_LIB-$(target)=$$(OPENSSL_DIR-$(target))/_install/lib/libssl.a
355355
OPENSSL_CRYPTO_LIB-$(target)=$$(OPENSSL_DIR-$(target))/_install/lib/libcrypto.a
356356

357-
$$(OPENSSL_DIR-$(target))/Makefile: downloads/openssl-$(OPENSSL_VERSION).tgz
357+
$$(OPENSSL_DIR-$(target))/is_configured: downloads/openssl-$(OPENSSL_VERSION).tgz
358358
@echo ">>> Unpack and configure OpenSSL sources for $(target)"
359359
mkdir -p $$(OPENSSL_DIR-$(target))
360360
tar zxf downloads/openssl-$(OPENSSL_VERSION).tgz --strip-components 1 -C $$(OPENSSL_DIR-$(target))
@@ -390,16 +390,23 @@ else
390390
--prefix="$(PROJECT_DIR)/$$(OPENSSL_DIR-$(target))/_install" \
391391
--openssldir=/etc/ssl \
392392
2>&1 | tee -a ../openssl-$(target).config.log
393-
394393
endif
395-
396-
$$(OPENSSL_DIR-$(target))/libssl.a: $$(OPENSSL_DIR-$(target))/Makefile
394+
# The OpenSSL Makefile is... interesting. Invoking `make all` or `make
395+
# install` *modifies the Makefile*. Therefore, we can't use the Makefile as
396+
# a build dependency, because building/installing dirties the target that
397+
# was a dependency. To compensate, create a dummy file as a marker for
398+
# whether OpenSSL has been configured, and use *that* as a reference.
399+
date > $$(OPENSSL_DIR-$(target))/is_configured
400+
401+
$$(OPENSSL_DIR-$(target))/libssl.a: $$(OPENSSL_DIR-$(target))/is_configured
397402
@echo ">>> Build OpenSSL for $(target)"
403+
# OpenSSL's `all` target modifies the Makefile;
404+
# use the raw targets that make up all and it's dependencies
398405
cd $$(OPENSSL_DIR-$(target)) && \
399406
CC="$$(CC-$(target))" \
400407
CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \
401408
CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \
402-
make depend _all \
409+
make all \
403410
2>&1 | tee -a ../openssl-$(target).build.log
404411

405412
$$(OPENSSL_SSL_LIB-$(target)): $$(OPENSSL_DIR-$(target))/libssl.a
@@ -718,11 +725,6 @@ OPENSSL_XCFRAMEWORK-$(os)=build/$(os)/Support/OpenSSL.xcframework
718725

719726
$$(OPENSSL_XCFRAMEWORK-$(os)): $$(foreach sdk,$$(SDKS-$(os)),$$(OPENSSL_FATLIB-$$(sdk)))
720727
@echo ">>> Create OpenSSL.XCFramework on $(os)"
721-
# The OpenSSL Makefile leaves the build in a "dirty" state; running the same build
722-
# twice in a row results in parts of the build being repeated, which then causes
723-
# other targets in *this* Makefile to trigger. To avoid problems, delete the
724-
# XCFramework every time and rebuild it.
725-
rm -rf $$(OPENSSL_XCFRAMEWORK-$(os))
726728
mkdir -p $$(OPENSSL_XCFRAMEWORK-$(os))
727729
xcodebuild -create-xcframework \
728730
-output $$@ $$(foreach sdk,$$(SDKS-$(os)),-library $$(OPENSSL_FATLIB-$$(sdk)) -headers build/$(os)/openssl/$$(sdk)/include) \

0 commit comments

Comments
 (0)