Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1629553 Rework the LIBRARY_NAME ruleset r=rrelyea
* Drop the WIN% "32" default DLL suffix
* Add default resource file handling => drop default RES
* Generate IMPORT_LIBRARY based on IMPORT_LIB_SUFFIX and
  SHARED_LIBRARY, so we can drop all the explicit empty
  IMPORT_LIBRARY lines

Originally this patch also tried to add a default MAPFILE rule,
but this fails, because the ARCH makefiles set linker flags
based on an existing MAPFILE variable.

Differential Revision: https://phabricator.services.mozilla.com/D70369

--HG--
extra : moz-landing-system : lando
  • Loading branch information
jmglogow committed May 5, 2020
1 parent 2cef8ee commit 147d3fe
Show file tree
Hide file tree
Showing 34 changed files with 62 additions and 154 deletions.
9 changes: 1 addition & 8 deletions cmd/libpkix/testutil/config.mk
Expand Up @@ -5,11 +5,4 @@

# don't build the static library
LIBRARY =

ifeq (,$(filter-out WIN%,$(OS_TARGET)))

# don't want the 32 in the shared library name
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
IMPORT_LIBRARY = $(OBJDIR)/$(IMPORT_LIB_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(IMPORT_LIB_SUFFIX)

endif
RES =
9 changes: 4 additions & 5 deletions coreconf/OS2.mk
Expand Up @@ -140,15 +140,14 @@ ifndef DLL_PREFIX
DLL_PREFIX = $(NULL)
endif

ifndef IMPORT_LIB_SUFFIX
IMPORT_LIB_SUFFIX = .$(LIB_SUFFIX)
endif

#
# override the TARGETS defined in ruleset.mk, adding IMPORT_LIBRARY
#
ifndef TARGETS
TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(PROGRAM)
endif


ifdef LIBRARY_NAME
IMPORT_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)$(JDK_DEBUG_SUFFIX).lib
endif

9 changes: 0 additions & 9 deletions coreconf/WIN32.mk
Expand Up @@ -364,15 +364,6 @@ ifneq ($(CPU_ARCH),x386)
CPU_TAG = _$(CPU_ARCH)
endif

#
# override ruleset.mk, removing the "lib" prefix for library names, and
# adding the "32" after the LIBRARY_VERSION.
#
ifdef LIBRARY_NAME
SHARED_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)32$(JDK_DEBUG_SUFFIX).dll
IMPORT_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)32$(JDK_DEBUG_SUFFIX).lib
endif

#
# override the TARGETS defined in ruleset.mk, adding IMPORT_LIBRARY
#
Expand Down
46 changes: 40 additions & 6 deletions coreconf/ruleset.mk
Expand Up @@ -79,20 +79,54 @@ endif
# - (3) IMPORT_LIBRARY: an import library, defined in $(OS_TARGET).mk
# - (4) PROGRAM: an executable binary
#
# NOTE: The names of libraries can be generated by simply specifying
# LIBRARY_NAME (and LIBRARY_VERSION in the case of non-static libraries).
# LIBRARY and SHARED_LIBRARY may be defined differently in $(OS_TARGET).mk
# A library is build by specifying the LIBRARY_NAME variable.
# If you want to build only a static library, set SHARED_LIBRARY = $(NULL)
# If you want to build only a shared library, set LIBRARY = $(NULL)
# You can specify the shared library major version via LIBRARY_VERSION.
#
# Normally you want to link to the shared library. In this case you must
# provide an export script, like:
# MAPFILE = $(OBJDIR)/$(LIBRARY_NAME).def.
# Unfortunatly this variable is needed by the ARCH setup, so you have to set
# it explicitly in the manifest.mn.
#
# Per default, it's assumed the shared library provides resource specification
# in the file RES. You can set it to $(NULL), if that is not true.
#
# If you have an unversioned SHARED_LIBRARY, you must explicitly change or
# disable the static LIBRARY, as these normally clash on Windows.

ifdef LIBRARY_NAME
ifndef LIBRARY
LIBRARY = $(OBJDIR)/$(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX)
LIBRARY := $(OBJDIR)/$(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX)
endif
ifndef SHARED_LIBRARY
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(JDK_DEBUG_SUFFIX).$(DLL_SUFFIX)
SHARED_LIBRARY := $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(JDK_DEBUG_SUFFIX).$(DLL_SUFFIX)
endif

ifneq ($(SHARED_LIBRARY),)

ifdef IMPORT_LIB_SUFFIX
ifdef MAPFILE
ifndef IMPORT_LIBRARY
IMPORT_LIBRARY := $(OBJDIR)/$(IMPORT_LIB_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(JDK_DEBUG_SUFFIX)$(IMPORT_LIB_SUFFIX)
endif
endif
endif

ifndef MAPFILE_SOURCE
MAPFILE_SOURCE = $(LIBRARY_NAME).def
MAPFILE_SOURCE := $(LIBRARY_NAME).def
endif

ifeq (,$(filter-out WIN%,$(OS_TARGET)))
ifndef RES
RES := $(OBJDIR)/$(LIBRARY_NAME).res
endif
ifndef RESNAME
RESNAME := $(LIBRARY_NAME).rc
endif
endif

endif
endif

Expand Down
5 changes: 0 additions & 5 deletions coreconf/suffix.mk
Expand Up @@ -40,11 +40,6 @@ ifndef DYNAMIC_LIB_SUFFIX
DYNAMIC_LIB_SUFFIX = .$(DLL_SUFFIX)
endif

# WIN% overridese this
ifndef IMPORT_LIB_SUFFIX
IMPORT_LIB_SUFFIX =
endif


ifndef STATIC_LIB_SUFFIX_FOR_LINKING
STATIC_LIB_SUFFIX_FOR_LINKING = $(STATIC_LIB_SUFFIX)
Expand Down
2 changes: 0 additions & 2 deletions gtests/common/Makefile
Expand Up @@ -20,8 +20,6 @@ include $(CORE_DEPTH)/coreconf/config.mk
# (3) Include "component" configuration information. (OPTIONAL) #
#######################################################################

SHARED_LIBRARY = $(NULL)
IMPORT_LIBRARY = $(NULL)

#######################################################################
# (4) Include "local" platform-dependent assignments (OPTIONAL). #
Expand Down
1 change: 1 addition & 0 deletions gtests/common/manifest.mn
Expand Up @@ -7,6 +7,7 @@ DEPTH = ../..
MODULE = nss

LIBRARY_NAME = gtestutil
SHARED_LIBRARY = $(NULL)

ifeq ($(NSS_BUILD_UTIL_ONLY),1)
CPPSRCS = gtests-util.cc
Expand Down
2 changes: 0 additions & 2 deletions gtests/google_test/Makefile
Expand Up @@ -20,8 +20,6 @@ include $(CORE_DEPTH)/coreconf/config.mk
# (3) Include "component" configuration information. (OPTIONAL) #
#######################################################################

SHARED_LIBRARY = $(NULL)
IMPORT_LIBRARY = $(NULL)

#######################################################################
# (4) Include "local" platform-dependent assignments (OPTIONAL). #
Expand Down
1 change: 1 addition & 0 deletions gtests/google_test/manifest.mn
Expand Up @@ -8,6 +8,7 @@ DEPTH = ../..
MODULE = gtest

LIBRARY_NAME = gtest
SHARED_LIBRARY = $(NULL)

INCLUDES += -Igtest/include/ -Igtest

Expand Down
3 changes: 0 additions & 3 deletions gtests/pkcs11testmodule/Makefile
Expand Up @@ -20,14 +20,11 @@ include $(CORE_DEPTH)/coreconf/config.mk
# (3) Include "component" configuration information. (OPTIONAL) #
#######################################################################

LIBRARY = $(NULL)
IMPORT_LIBRARY = $(NULL)

#######################################################################
# (4) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################

include config.mk

#######################################################################
# (5) Execute "global" rules. (OPTIONAL) #
Expand Down
16 changes: 0 additions & 16 deletions gtests/pkcs11testmodule/config.mk

This file was deleted.

5 changes: 3 additions & 2 deletions gtests/pkcs11testmodule/manifest.mn
Expand Up @@ -14,9 +14,10 @@ INCLUDES += -I$(CORE_DEPTH)/cpputil

REQUIRES = cpputil

MAPFILE = $(OBJDIR)/pkcs11testmodule.def

LIBRARY_NAME = pkcs11testmodule
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME).def
LIBRARY = $(NULL)
IMPORT_LIBRARY = $(NULL)

EXTRA_LIBS = $(DIST)/lib/$(LIB_PREFIX)cpputil.$(LIB_SUFFIX) \
$(NULL)
6 changes: 0 additions & 6 deletions lib/ckfw/builtins/config.mk
Expand Up @@ -13,12 +13,6 @@ LIBRARY =
IMPORT_LIBRARY =
PROGRAM =

ifeq (,$(filter-out WIN%,$(OS_TARGET)))
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
RES = $(OBJDIR)/$(LIBRARY_NAME).res
RESNAME = $(LIBRARY_NAME).rc
endif

ifdef BUILD_IDG
DEFINES += -DNSSDEBUG
endif
Expand Down
2 changes: 1 addition & 1 deletion lib/ckfw/builtins/manifest.mn
Expand Up @@ -8,7 +8,6 @@ CORE_DEPTH = ../../..
DIRS = testlib

MODULE = nss
MAPFILE = $(OBJDIR)/nssckbi.def

EXPORTS = \
nssckbi.h \
Expand All @@ -30,3 +29,4 @@ CSRCS = \
REQUIRES = nspr

LIBRARY_NAME = nssckbi
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME).def
6 changes: 0 additions & 6 deletions lib/ckfw/builtins/testlib/config.mk
Expand Up @@ -13,12 +13,6 @@ LIBRARY =
IMPORT_LIBRARY =
PROGRAM =

ifeq (,$(filter-out WIN%,$(OS_TARGET)))
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
RES = $(OBJDIR)/$(LIBRARY_NAME).res
RESNAME = $(LIBRARY_NAME).rc
endif

ifdef BUILD_IDG
DEFINES += -DNSSDEBUG
endif
Expand Down
6 changes: 0 additions & 6 deletions lib/ckfw/capi/config.mk
Expand Up @@ -13,12 +13,6 @@ LIBRARY =
IMPORT_LIBRARY =
PROGRAM =

ifeq (,$(filter-out WIN%,$(OS_TARGET)))
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
RES = $(OBJDIR)/$(LIBRARY_NAME).res
RESNAME = $(LIBRARY_NAME).rc
endif

ifdef BUILD_IDG
DEFINES += -DNSSDEBUG
endif
Expand Down
2 changes: 1 addition & 1 deletion lib/ckfw/capi/manifest.mn
Expand Up @@ -6,7 +6,6 @@
CORE_DEPTH = ../../../..

MODULE = nss
MAPFILE = $(OBJDIR)/nsscapi.def

EXPORTS = \
nsscapi.h \
Expand All @@ -29,5 +28,6 @@ CSRCS = \
REQUIRES = nspr

LIBRARY_NAME = nsscapi
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME).def

#EXTRA_SHARED_LIBS = -L$(DIST)/lib -lnssckfw -lnssb -lplc4 -lplds4
4 changes: 0 additions & 4 deletions lib/freebl/config.mk
Expand Up @@ -47,10 +47,6 @@ endif

ifeq (,$(filter-out WIN%,$(OS_TARGET)))

# don't want the 32 in the shared library name
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)

RES = $(OBJDIR)/$(LIBRARY_NAME).res
RESNAME = freebl.rc

ifdef NS_USE_GCC
Expand Down
7 changes: 0 additions & 7 deletions lib/nss/config.mk
Expand Up @@ -6,13 +6,6 @@
# can't do this in manifest.mn because OS_TARGET isn't defined there.
ifeq (,$(filter-out WIN%,$(OS_TARGET)))

# don't want the 32 in the shared library name
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
IMPORT_LIBRARY = $(OBJDIR)/$(IMPORT_LIB_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(IMPORT_LIB_SUFFIX)

RES = $(OBJDIR)/$(LIBRARY_NAME).res
RESNAME = $(LIBRARY_NAME).rc

ifdef NS_USE_GCC
EXTRA_SHARED_LIBS += \
-L$(DIST)/lib \
Expand Down
3 changes: 1 addition & 2 deletions lib/nss/manifest.mn
Expand Up @@ -22,10 +22,9 @@ CSRCS = \
utilwrap.c \
$(NULL)

MAPFILE = $(OBJDIR)/nss.def

LIBRARY_NAME = nss
LIBRARY_VERSION = 3
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME).def

# This part of the code, including all sub-dirs, can be optimized for size
export ALLOW_OPT_CODE_SIZE = 1
7 changes: 0 additions & 7 deletions lib/smime/config.mk
Expand Up @@ -7,13 +7,6 @@ RELEASE_LIBS = $(TARGETS)

ifeq (,$(filter-out WIN%,$(OS_TARGET)))

# don't want the 32 in the shared library name
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
IMPORT_LIBRARY = $(OBJDIR)/$(IMPORT_LIB_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(IMPORT_LIB_SUFFIX)

RES = $(OBJDIR)/smime.res
RESNAME = smime.rc

ifdef NS_USE_GCC
EXTRA_SHARED_LIBS += \
-L$(DIST)/lib \
Expand Down
2 changes: 1 addition & 1 deletion lib/smime/manifest.mn
Expand Up @@ -17,7 +17,6 @@ PRIVATE_EXPORTS = \
$(NULL)

MODULE = nss
MAPFILE = $(OBJDIR)/smime.def

CSRCS = \
cmsarray.c \
Expand Down Expand Up @@ -46,6 +45,7 @@ CSRCS = \

LIBRARY_NAME = smime
LIBRARY_VERSION = 3
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME).def

# This part of the code, including all sub-dirs, can be optimized for size
export ALLOW_OPT_CODE_SIZE = 1
7 changes: 0 additions & 7 deletions lib/softoken/config.mk
Expand Up @@ -13,13 +13,6 @@ EXTRA_LIBS += \
# can't do this in manifest.mn because OS_TARGET isn't defined there.
ifeq (,$(filter-out WIN%,$(OS_TARGET)))

# don't want the 32 in the shared library name
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
IMPORT_LIBRARY = $(OBJDIR)/$(IMPORT_LIB_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(IMPORT_LIB_SUFFIX)

RES = $(OBJDIR)/$(LIBRARY_NAME).res
RESNAME = $(LIBRARY_NAME).rc

ifdef NS_USE_GCC
EXTRA_SHARED_LIBS += \
-L$(SQLITE_LIB_DIR) \
Expand Down
7 changes: 0 additions & 7 deletions lib/softoken/legacydb/config.mk
Expand Up @@ -14,13 +14,6 @@ EXTRA_LIBS += \
# can't do this in manifest.mn because OS_TARGET isn't defined there.
ifeq (,$(filter-out WIN%,$(OS_TARGET)))

# don't want the 32 in the shared library name
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
IMPORT_LIBRARY = $(OBJDIR)/$(IMPORT_LIB_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(IMPORT_LIB_SUFFIX)

RES = $(OBJDIR)/$(LIBRARY_NAME).res
RESNAME = $(LIBRARY_NAME).rc

ifdef NS_USE_GCC
EXTRA_SHARED_LIBS += \
-L$(DIST)/lib \
Expand Down
2 changes: 1 addition & 1 deletion lib/softoken/legacydb/manifest.mn
Expand Up @@ -10,7 +10,7 @@ REQUIRES = dbm

LIBRARY_NAME = nssdbm
LIBRARY_VERSION = 3
MAPFILE = $(OBJDIR)/nssdbm.def
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME).def

DEFINES += -DSHLIB_SUFFIX=\"$(DLL_SUFFIX)\" -DSHLIB_PREFIX=\"$(DLL_PREFIX)\" -DLG_LIB_NAME=\"$(notdir $(SHARED_LIBRARY))\"

Expand Down
2 changes: 1 addition & 1 deletion lib/softoken/manifest.mn
Expand Up @@ -9,7 +9,7 @@ DIRS = legacydb

LIBRARY_NAME = softokn
LIBRARY_VERSION = 3
MAPFILE = $(OBJDIR)/softokn.def
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME).def

DEFINES += -DSHLIB_SUFFIX=\"$(DLL_SUFFIX)\" -DSHLIB_PREFIX=\"$(DLL_PREFIX)\" -DSOFTOKEN_LIB_NAME=\"$(notdir $(SHARED_LIBRARY))\" -DSHLIB_VERSION=\"$(LIBRARY_VERSION)\"

Expand Down
12 changes: 0 additions & 12 deletions lib/sqlite/config.mk
Expand Up @@ -3,18 +3,6 @@
# 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/.


# can't do this in manifest.mn because OS_TARGET isn't defined there.
ifeq (,$(filter-out WIN%,$(OS_TARGET)))

# don't want the 32 in the shared library name
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
IMPORT_LIBRARY = $(OBJDIR)/$(IMPORT_LIB_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(IMPORT_LIB_SUFFIX)

#RES = $(OBJDIR)/$(LIBRARY_NAME).res
#RESNAME = $(LIBRARY_NAME).rc
endif

ifeq ($(OS_TARGET),AIX)
EXTRA_LIBS += -lpthreads
ifdef BUILD_OPT
Expand Down

0 comments on commit 147d3fe

Please sign in to comment.