diff --git a/.gitignore b/.gitignore index 449ba71..cc9b7e4 100644 --- a/.gitignore +++ b/.gitignore @@ -192,3 +192,4 @@ config.h config.nice *.la Makefile* +!Makefile.am diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..113e859 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,21 @@ +[submodule "aws-c-common"] + path = crt/aws-c-common + url = https://github.com/awslabs/aws-c-common.git +[submodule "aws-c-io"] + path = crt/aws-c-io + url = https://github.com/awslabs/aws-c-io.git +[submodule "aws-c-http"] + path = crt/aws-c-http + url = https://github.com/awslabs/aws-c-http.git +[submodule "aws-c-compression"] + path = crt/aws-c-compression + url = https://github.com/awslabs/aws-c-compression.git +[submodule "aws-c-auth"] + path = crt/aws-c-auth + url = https://github.com/awslabs/aws-c-auth.git +[submodule "aws-c-cal"] + path = crt/aws-c-cal + url = https://github.com/awslabs/aws-c-cal.git +[submodule "s2n"] + path = crt/s2n + url = https://github.com/awslabs/s2n.git diff --git a/Makefile.frag b/Makefile.frag new file mode 100644 index 0000000..bf9e3b2 --- /dev/null +++ b/Makefile.frag @@ -0,0 +1,77 @@ + +INSTALL_DIR=$(shell pwd)/build/install + +crt_libs=$(INSTALL_DIR)/lib/libaws-c-common.a \ + $(INSTALL_DIR)/lib/libaws-c-cal.a \ + $(INSTALL_DIR)/lib/libaws-c-io.a \ + $(INSTALL_DIR)/lib/libaws-c-compression.a \ + $(INSTALL_DIR)/lib/libaws-c-http.a \ + $(INSTALL_DIR)/lib/libaws-c-auth.a \ + $(INSTALL_DIR)/lib/libs2n.a + +crt-static: $(crt_libs) $(INSTALL_DIR)/lib/libcrypto.a + +build/deps/openssl: + @echo Fetching libcrypto source + git clone --depth=1 --single-branch --branch OpenSSL_1_1_1-stable https://github.com/openssl/openssl.git build/deps/openssl + +$(INSTALL_DIR)/lib/libcrypto.a: build/deps/openssl + @echo Building libcrypto + cd build/deps/openssl && \ + ./config -fPIC no-md2 no-rc5 no-rfc3779 no-sctp no-ssl-trace no-zlib no-hw no-mdc2 no-seed no-idea \ + no-camellia no-bf no-dsa no-ssl3 no-capieng \ + -DSSL_FORBID_ENULL -DOPENSSL_NO_DTLS1 -DOPENSSL_NO_HEARTBEATS \ + --prefix=$(INSTALL_DIR) --openssldir=$(INSTALL_DIR) && \ + make -j && \ + make install_sw + + +CMAKE_CONFIGURE = cmake -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCMAKE_PREFIX_PATH=$(INSTALL_DIR) -DBUILD_TESTING=OFF +CMAKE_BUILD = cmake --build +CMAKE_BUILD_TYPE ?= RelWithDebInfo +CMAKE_TARGET = --config $CMAKE_BUILD_TYPE --target install + +build/aws-c-common/CMakeCache.txt: $(INSTALL_DIR)/lib/libcrypto.a + $(CMAKE_CONFIGURE) -Hcrt/aws-c-common -Bbuild/aws-c-common + +$(INSTALL_DIR)/lib/libaws-c-common.a: build/aws-c-common/CMakeCache.txt + $(CMAKE_BUILD) build/aws-c-common $(CMAKE_TARGET) + +build/s2n/CMakeCache.txt: $(INSTALL_DIR)/lib/libcrypto.a + $(CMAKE_CONFIGURE) -Hcrt/s2n -Bbuild/s2n + +$(INSTALL_DIR)/lib/libs2n.a: build/s2n/CMakeCache.txt + $(CMAKE_BUILD) build/s2n $(CMAKE_TARGET) + +build/aws-c-io/CMakeCache.txt: $(INSTALL_DIR)/lib/libaws-c-common.a $(INSTALL_DIR)/lib/libcrypto.a $(INSTALL_DIR)/lib/libs2n.a + $(CMAKE_CONFIGURE) -Hcrt/aws-c-io -Bbuild/aws-c-io + +$(INSTALL_DIR)/lib/libaws-c-io.a: build/aws-c-io/CMakeCache.txt + $(CMAKE_BUILD) build/aws-c-io $(CMAKE_TARGET) + +build/aws-c-cal/CMakeCache.txt: $(INSTALL_DIR)/lib/libaws-c-common.a + $(CMAKE_CONFIGURE) -Hcrt/aws-c-cal -Bbuild/aws-c-cal + +$(INSTALL_DIR)/lib/libaws-c-cal.a: build/aws-c-cal/CMakeCache.txt + $(CMAKE_BUILD) build/aws-c-cal $(CMAKE_TARGET) + +build/aws-c-compression/CMakeCache.txt: $(INSTALL_DIR)/lib/libaws-c-common.a + $(CMAKE_CONFIGURE) -Hcrt/aws-c-compression -Bbuild/aws-c-compression + +$(INSTALL_DIR)/lib/libaws-c-compression.a: build/aws-c-compression/CMakeCache.txt + $(CMAKE_BUILD) build/aws-c-compression $(CMAKE_TARGET) + +build/aws-c-http/CMakeCache.txt: $(INSTALL_DIR)/lib/libaws-c-compression.a $(INSTALL_DIR)/lib/libaws-c-io.a + $(CMAKE_CONFIGURE) -Hcrt/aws-c-http -Bbuild/aws-c-http + +$(INSTALL_DIR)/lib/libaws-c-http.a: build/aws-c-http/CMakeCache.txt + $(CMAKE_BUILD) build/aws-c-http $(CMAKE_TARGET) + +build/aws-c-auth/CMakeCache.txt: $(INSTALL_DIR)/lib/libaws-c-http.a + $(CMAKE_CONFIGURE) -Hcrt/aws-c-auth -Bbuild/aws-c-auth + +$(INSTALL_DIR)/lib/libaws-c-auth.a: build/aws-c-auth/CMakeCache.txt + $(CMAKE_BUILD) build/aws-c-auth $(CMAKE_TARGET) + +# Force the crt object target to depend on all of the libraries above +src/crt.lo: crt-static diff --git a/config.m4 b/config.m4 index b0ff2a4..c087559 100644 --- a/config.m4 +++ b/config.m4 @@ -6,25 +6,18 @@ dnl PHP_ARG_WITH(awscrt) if test "$PHP_AWSCRT" != "no"; then - AC_MSG_CHECKING([for libcrypto]) - for search_path in "$AWS_LIBCRYTO_INSTALL" "$PHP_AWSCRT/build/deps/openssl" /opt/openssl /usr/local /usr; do - if test -f "$search_path/include/openssl/crypto.h"; then - LIBCRYPTO_PATH=$search_path - break - fi - done - if test -z "$LIBCRYPTO_PATH"; then - AC_MSG_ERROR([not found]) - fi + # force lib paths to be absolute, or PHP will mangle them + cwd=`pwd` + CRT_LIBPATHS="-L${cwd}/build/install/lib64 -L${cwd}/build/install/lib" + CRT_LIBS="-laws-c-auth -laws-c-http -laws-c-cal -laws-c-io -laws-c-compression -laws-c-common -ls2n -l:libcrypto.a" + PHP_EVAL_LIBLINE([$CRT_LIBPATHS $CRT_LIBS], AWSCRT_SHARED_LIBADD) - AC_MSG_RESULT([found at $LIBCRYPTO_PATH]) - - PHP_ADD_INCLUDE($LIBCRYPTO_PATH/include) - dnl PHP_ADD_LIBPATH($LIBCRYPTO_PATH/lib) - PHP_ADD_LIBRARY_WITH_PATH(:libcrypto.a, $LIBCRYPTO_PATH/lib, AWSCRT_SHARED_LIBADD) - - AWSCRT_SOURCES=src/*.c - - PHP_NEW_EXTENSION(awscrt, $AWSCRT_SOURCES, $ext_shared) + # Shoves the linker line into the Makefile PHP_SUBST(AWSCRT_SHARED_LIBADD) + + # Sources for the PHP extension itself + AWSCRT_SOURCES=src/*.c + PHP_NEW_EXTENSION(awscrt, $AWSCRT_SOURCES, $ext_shared) fi + +PHP_ADD_MAKEFILE_FRAGMENT diff --git a/crt/aws-c-auth b/crt/aws-c-auth new file mode 160000 index 0000000..a492570 --- /dev/null +++ b/crt/aws-c-auth @@ -0,0 +1 @@ +Subproject commit a492570cfd0708b56df9efdbf85dfa64ee16579d diff --git a/crt/aws-c-cal b/crt/aws-c-cal new file mode 160000 index 0000000..df5da3a --- /dev/null +++ b/crt/aws-c-cal @@ -0,0 +1 @@ +Subproject commit df5da3af5b8cb2ad70cb591504bb25d6a74f3ab4 diff --git a/crt/aws-c-common b/crt/aws-c-common new file mode 160000 index 0000000..1efe886 --- /dev/null +++ b/crt/aws-c-common @@ -0,0 +1 @@ +Subproject commit 1efe886005caa9568b132f34ba93cce8c4a4bc1e diff --git a/crt/aws-c-compression b/crt/aws-c-compression new file mode 160000 index 0000000..826d92c --- /dev/null +++ b/crt/aws-c-compression @@ -0,0 +1 @@ +Subproject commit 826d92cc39ea4c4a1a2a0ca5dccfdf9397c9a9f4 diff --git a/crt/aws-c-http b/crt/aws-c-http new file mode 160000 index 0000000..cad6279 --- /dev/null +++ b/crt/aws-c-http @@ -0,0 +1 @@ +Subproject commit cad62791f14396479e683122ce0ddb7be6967d54 diff --git a/crt/aws-c-io b/crt/aws-c-io new file mode 160000 index 0000000..7012798 --- /dev/null +++ b/crt/aws-c-io @@ -0,0 +1 @@ +Subproject commit 701279844ae43f9d275171bbdc80fcb1ba5a0065 diff --git a/crt/s2n b/crt/s2n new file mode 160000 index 0000000..2a7cebb --- /dev/null +++ b/crt/s2n @@ -0,0 +1 @@ +Subproject commit 2a7cebb0d7c00f5577629c9372cc1e4688cbb774