Skip to content

Commit

Permalink
Bug 1243872: Refactor zlib support in Makefiles. r=mt,wtc
Browse files Browse the repository at this point in the history
  • Loading branch information
ekr committed Feb 1, 2016
1 parent 53ea9bc commit ed9c0be
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 48 deletions.
8 changes: 2 additions & 6 deletions cmd/modutil/Makefile
Expand Up @@ -23,13 +23,9 @@ include $(CORE_DEPTH)/coreconf/config.mk
#######################################################################
# (4) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
include ../platlibs.mk

ifdef USE_SYSTEM_ZLIB
OS_LIBS += $(ZLIB_LIBS)
else
EXTRA_LIBS += $(ZLIB_LIBS)
endif
include ../platlibs.mk
include $(CORE_DEPTH)/coreconf/zlib.mk

#######################################################################
# (5) Execute "global" rules. (OPTIONAL) #
Expand Down
7 changes: 0 additions & 7 deletions cmd/platlibs.mk
Expand Up @@ -259,11 +259,4 @@ FREEBL_LIBS = $(FREEBL_LIB_DIR)/$(LIB_PREFIX)freebl.$(LIB_SUFFIX)
EXTRA_LIBS += $(FREEBL_LIBS)
endif

# If a platform has a system zlib, set USE_SYSTEM_ZLIB to 1 and
# ZLIB_LIBS to the linker command-line arguments for the system zlib
# (for example, -lz) in the platform's config file in coreconf.
ifndef USE_SYSTEM_ZLIB
ZLIB_LIBS = $(DIST)/lib/$(LIB_PREFIX)zlib.$(LIB_SUFFIX)
endif

JAR_LIBS = $(DIST)/lib/$(LIB_PREFIX)jar.$(LIB_SUFFIX)
7 changes: 1 addition & 6 deletions cmd/signtool/Makefile
Expand Up @@ -25,12 +25,7 @@ include $(CORE_DEPTH)/coreconf/config.mk
#######################################################################

include ../platlibs.mk

ifdef USE_SYSTEM_ZLIB
OS_LIBS += $(ZLIB_LIBS)
else
EXTRA_LIBS += $(ZLIB_LIBS)
endif
include $(CORE_DEPTH)/coreconf/zlib.mk

#######################################################################
# (5) Execute "global" rules. (OPTIONAL) #
Expand Down
7 changes: 6 additions & 1 deletion coreconf/config.mk
Expand Up @@ -149,7 +149,7 @@ endif
ifdef NSS_DISABLE_ECC
DEFINES += -DNSS_DISABLE_ECC
endif

ifdef NSS_ECC_MORE_THAN_SUITE_B
DEFINES += -DNSS_ECC_MORE_THAN_SUITE_B
endif
Expand Down Expand Up @@ -188,3 +188,8 @@ DEFINES += -DNO_NSPR_10_SUPPORT

# Hide old, deprecated, TLS cipher suite names when building NSS
DEFINES += -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES

# Mozilla's mozilla/modules/zlib/src/zconf.h adds the MOZ_Z_ prefix to zlib
# exported symbols, which causes problem when NSS is built as part of Mozilla.
# So we add a NSS_ENABLE_SSL_ZLIB variable to allow Mozilla to turn this off.
NSS_ENABLE_SSL_ZLIB = 1
17 changes: 17 additions & 0 deletions coreconf/zlib.mk
@@ -0,0 +1,17 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Configuration information for linking against zlib.

# If a platform has a system zlib, set USE_SYSTEM_ZLIB to 1 and
# ZLIB_LIBS to the linker command-line arguments for the system zlib
# (for example, -lz) in the platform's config file in coreconf.
ifdef USE_SYSTEM_ZLIB
OS_LIBS += $(ZLIB_LIBS)
else
ZLIB_LIBS = $(DIST)/lib/$(LIB_PREFIX)zlib.$(LIB_SUFFIX)
EXTRA_LIBS += $(ZLIB_LIBS)
endif

8 changes: 6 additions & 2 deletions external_tests/ssl_gtest/Makefile
Expand Up @@ -27,6 +27,12 @@ include $(CORE_DEPTH)/coreconf/config.mk

include ../common/gtest.mk

CFLAGS += -I$(CORE_DEPTH)/lib/ssl

ifdef NSS_ENABLE_SSL_ZLIB
include $(CORE_DEPTH)/coreconf/zlib.mk
endif

#######################################################################
# (5) Execute "global" rules. (OPTIONAL) #
#######################################################################
Expand All @@ -41,5 +47,3 @@ include $(CORE_DEPTH)/coreconf/rules.mk
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

CFLAGS += -I$(CORE_DEPTH)/lib/ssl
20 changes: 3 additions & 17 deletions lib/ssl/config.mk
Expand Up @@ -72,22 +72,8 @@ endif

endif

# Mozilla's mozilla/modules/zlib/src/zconf.h adds the MOZ_Z_ prefix to zlib
# exported symbols, which causes problem when NSS is built as part of Mozilla.
# So we add a NSS_ENABLE_ZLIB variable to allow Mozilla to turn this off.
NSS_ENABLE_ZLIB = 1
ifdef NSS_ENABLE_ZLIB

DEFINES += -DNSS_ENABLE_ZLIB

# If a platform has a system zlib, set USE_SYSTEM_ZLIB to 1 and
# ZLIB_LIBS to the linker command-line arguments for the system zlib
# (for example, -lz) in the platform's config file in coreconf.
ifdef USE_SYSTEM_ZLIB
OS_LIBS += $(ZLIB_LIBS)
else
ZLIB_LIBS = $(DIST)/lib/$(LIB_PREFIX)zlib.$(LIB_SUFFIX)
EXTRA_LIBS += $(ZLIB_LIBS)
ifdef NSS_ENABLE_SSL_ZLIB
DEFINES += -DNSS_ENABLE_SSL_ZLIB
include $(CORE_DEPTH)/coreconf/zlib.mk
endif

endif
14 changes: 7 additions & 7 deletions lib/ssl/ssl3con.c
Expand Up @@ -34,7 +34,7 @@
#endif

#include <stdio.h>
#ifdef NSS_ENABLE_ZLIB
#ifdef NSS_ENABLE_SSL_ZLIB
#include "zlib.h"
#endif

Expand Down Expand Up @@ -221,7 +221,7 @@ void ssl3_CheckCipherSuiteOrderConsistency()
* implement.
*/
static const /*SSLCompressionMethod*/ PRUint8 compressions [] = {
#ifdef NSS_ENABLE_ZLIB
#ifdef NSS_ENABLE_SSL_ZLIB
ssl_compression_deflate,
#endif
ssl_compression_null
Expand All @@ -238,7 +238,7 @@ compressionEnabled(sslSocket *ss, SSLCompressionMethod compression)
switch (compression) {
case ssl_compression_null:
return PR_TRUE; /* Always enabled */
#ifdef NSS_ENABLE_ZLIB
#ifdef NSS_ENABLE_SSL_ZLIB
case ssl_compression_deflate:
if (ss->version < SSL_LIBRARY_VERSION_TLS_1_3) {
return ss->opt.enableDeflate;
Expand Down Expand Up @@ -1491,7 +1491,7 @@ ssl3_SetupPendingCipherSpec(sslSocket *ss)
return SECSuccess;
}

#ifdef NSS_ENABLE_ZLIB
#ifdef NSS_ENABLE_SSL_ZLIB
#define SSL3_DEFLATE_CONTEXT_SIZE sizeof(z_stream)

static SECStatus
Expand Down Expand Up @@ -1598,7 +1598,7 @@ ssl3_DestroyDecompressContext(void *void_context, PRBool unused)
return SECSuccess;
}

#endif /* NSS_ENABLE_ZLIB */
#endif /* NSS_ENABLE_SSL_ZLIB */

/* Initialize the compression functions and contexts for the given
* CipherSpec. */
Expand All @@ -1615,7 +1615,7 @@ ssl3_InitCompressionContext(ssl3CipherSpec *pwSpec)
pwSpec->destroyCompressContext = NULL;
pwSpec->destroyDecompressContext = NULL;
break;
#ifdef NSS_ENABLE_ZLIB
#ifdef NSS_ENABLE_SSL_ZLIB
case ssl_compression_deflate:
pwSpec->compressor = ssl3_DeflateCompress;
pwSpec->decompressor = ssl3_DeflateDecompress;
Expand All @@ -1626,7 +1626,7 @@ ssl3_InitCompressionContext(ssl3CipherSpec *pwSpec)
ssl3_DeflateInit(pwSpec->compressContext);
ssl3_InflateInit(pwSpec->decompressContext);
break;
#endif /* NSS_ENABLE_ZLIB */
#endif /* NSS_ENABLE_SSL_ZLIB */
default:
PORT_Assert(0);
PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
Expand Down
4 changes: 2 additions & 2 deletions lib/ssl/sslimpl.h
Expand Up @@ -1514,13 +1514,13 @@ extern PRInt32 ssl3_SendRecord(sslSocket *ss, DTLSEpoch epoch,
const SSL3Opaque* pIn, PRInt32 nIn,
PRInt32 flags);

#ifdef NSS_ENABLE_ZLIB
#ifdef NSS_ENABLE_SSL_ZLIB
/*
* The DEFLATE algorithm can result in an expansion of 0.1% + 12 bytes. For a
* maximum TLS record payload of 2**14 bytes, that's 29 bytes.
*/
#define SSL3_COMPRESSION_MAX_EXPANSION 29
#else /* !NSS_ENABLE_ZLIB */
#else /* !NSS_ENABLE_SSL_ZLIB */
#define SSL3_COMPRESSION_MAX_EXPANSION 0
#endif

Expand Down

0 comments on commit ed9c0be

Please sign in to comment.