Automatic building of .def files in a general way BOB_WORK_BRANCH
authorrelyea%netscape.com
Wed, 07 Nov 2001 01:33:17 +0000
branchBOB_WORK_BRANCH
changeset 2280 4813ea633a4204224d2efb5ecb2fc04b0d0f69ba
parent 2270 ff58df2ee4c21e70aad6f445307f44f290064db6
child 13841 cb57efb5387c91b95a6b6b8936399be6954c3255
push idunknown
push userunknown
push dateunknown
Automatic building of .def files in a general way
security/coreconf/AIX.mk
security/coreconf/AIX4.2.mk
security/coreconf/AIX4.3.mk
security/coreconf/BSD_OS.mk
security/coreconf/FreeBSD.mk
security/coreconf/HP-UX.mk
security/coreconf/IRIX.mk
security/coreconf/Linux.mk
security/coreconf/NCR3.0.mk
security/coreconf/NEC4.2.mk
security/coreconf/NetBSD.mk
security/coreconf/OS2.mk
security/coreconf/OSF1.mk
security/coreconf/OpenVMS.mk
security/coreconf/ReliantUNIX.mk
security/coreconf/SCO_SV3.2.mk
security/coreconf/SunOS5.mk
security/coreconf/UNIXWARE2.1.mk
security/coreconf/WIN16.mk
security/coreconf/WIN32.mk
security/coreconf/rules.mk
--- a/security/coreconf/AIX.mk
+++ b/security/coreconf/AIX.mk
@@ -67,8 +67,14 @@ RANLIB		= ranlib
 OS_CFLAGS	= -DAIX -DSYSV
 ifeq ($(CC),xlC_r)
 	OS_CFLAGS += -qarch=com
 endif
 
 AIX_WRAP	= $(DIST)/lib/aixwrap.o
 AIX_TMP		= $(OBJDIR)/_aix_tmp.o
 OS_LIBS		+= -lsvld
+ifdef MAPFILE
+EXPORT_RULES = -bexport:$(MAPFILE)
+endif
+PROCESS_MAP_FILE = grep -v ';+' $(LIBRARY_NAME).def | grep -v ';-' | \
+                sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' > $@
+
--- a/security/coreconf/AIX4.2.mk
+++ b/security/coreconf/AIX4.2.mk
@@ -32,14 +32,19 @@
 
 #
 # Config stuff for AIX4.2
 #
 
 include $(CORE_DEPTH)/coreconf/AIX.mk
 
 OS_CFLAGS	+= -DAIX4_2
-DSO_LDOPTS	= -brtl -bM:SRE -bnoentry $(EXPORT_RULES)
+DSO_LDOPTS	= -brtl -bM:SRE -bnoentry
 MKSHLIB		= $(LD) $(DSO_LDOPTS) -lsvld -L/usr/lpp/xlC/lib -lc -lm
 
 OS_LIBS		+= -L/usr/lpp/xlC/lib -lc -lm
-EXPORT_RULES = -bexpall
+ifdef MAPFILE
+DSO_LDOPTS	+= -bexport:$(MAPFILE)
+else
+DSO_LDOPTS	+= -bexpall
+endif
 
+
--- a/security/coreconf/AIX4.3.mk
+++ b/security/coreconf/AIX4.3.mk
@@ -39,14 +39,17 @@ include $(CORE_DEPTH)/coreconf/AIX.mk
 ifeq ($(USE_64), 1)
 # Next line replaced by generic name handling in arch.mk
 #	COMPILER_TAG    = _64
 	OS_CFLAGS	+= -DAIX_64BIT
 	OBJECT_MODE=64
 	export OBJECT_MODE
 endif
 OS_CFLAGS	+= -DAIX4_3
-DSO_LDOPTS	= -brtl -bM:SRE -bnoentry $(EXPORT_RULES)
+DSO_LDOPTS	= -brtl -bM:SRE -bnoentry
 MKSHLIB		= $(LD) $(DSO_LDOPTS) -lsvld -L/usr/lpp/xlC/lib -lc -lm
 
 OS_LIBS		+= -L/usr/lpp/xlC/lib -lc -lm
-EXPORT_RULES	= -bexpall
-
+ifdef MAPFILE
+DSO_LDOPTS      += -bexport:$(MAPFILE)
+else
+DSO_LDOPTS      += -bexpall
+endif
--- a/security/coreconf/BSD_OS.mk
+++ b/security/coreconf/BSD_OS.mk
@@ -72,12 +72,17 @@ DSO_LDOPTS		= -shared
 DSO_LDFLAGS		=
 DSO_LDOPTS		+= -Wl,-soname,lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
 
 ifdef LIBRUNPATH
 DSO_LDOPTS		+= -Wl,-R$(LIBRUNPATH)
 endif
 
 MKSHLIB			= $(CC) $(DSO_LDOPTS)
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = cp $(LIBRARY_NAME).def $@
 
 G++INCLUDES		= -I/usr/include/g++
 
 INCLUDES		+= -I/usr/X11R6/include
--- a/security/coreconf/FreeBSD.mk
+++ b/security/coreconf/FreeBSD.mk
@@ -68,12 +68,17 @@ else
 DLL_SUFFIX		= so.1.0
 endif
 
 DSO_CFLAGS		= -fPIC
 DSO_LDOPTS		= -Bshareable
 DSO_LDFLAGS		=
 
 MKSHLIB			= $(LD) $(DSO_LDOPTS)
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = cp $(LIBRARY_NAME).def $@
 
 G++INCLUDES		= -I/usr/include/g++
 
 INCLUDES		+= -I/usr/X11R6/include
--- a/security/coreconf/HP-UX.mk
+++ b/security/coreconf/HP-UX.mk
@@ -58,14 +58,19 @@ endif
 
 ifdef PTHREADS_USER
 	OS_CFLAGS	+= -D_POSIX_C_SOURCE=199506L
 endif
 
 LDFLAGS			= -z -Wl,+s
 
 MKSHLIB			= $(LD) $(DSO_LDOPTS)
+ifdef MAPFILE
+MKSHLIB += -c $(MAPFILE)
+endif
+PROCESS_MAP_FILE = grep -v ';+' $(LIBRARY_NAME).def | grep -v ';-' | \
+         sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,^,+e ,' > $@
 
 DSO_LDOPTS		= -b +h $(notdir $@)
 DSO_LDFLAGS		=
 
 # +Z generates position independent code for use in shared libraries.
 DSO_CFLAGS = +Z
--- a/security/coreconf/IRIX.mk
+++ b/security/coreconf/IRIX.mk
@@ -96,16 +96,21 @@ ifdef USE_MDUPDATE
 	OS_CFLAGS += -MDupdate $(DEPENDENCIES)
 endif
 
 ifeq ($(USE_N32),1)
 	SHLIB_LD_OPTS	+= -n32 -mips3
 endif
 
 MKSHLIB     += $(LD) $(SHLIB_LD_OPTS) -shared -soname $(@:$(OBJDIR)/%.so=%.so)
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = cp $(LIBRARY_NAME).def $@
 
 DSO_LDOPTS	= -elf -shared -all
 
 ifdef DSO_BACKEND
 	DSO_LDOPTS += -soname $(DSO_NAME)
 endif
 
 #
--- a/security/coreconf/Linux.mk
+++ b/security/coreconf/Linux.mk
@@ -82,16 +82,21 @@ endif
 LIBC_TAG		= _glibc
 
 ifeq ($(OS_RELEASE),2.0)
 	OS_REL_CFLAGS	+= -DLINUX2_0
 	MKSHLIB		= $(CC) -shared -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so)
 	ifdef BUILD_OPT
 		OPTIMIZER	= -O2
 	endif
+	ifdef MAPFILE
+		MKSHLIB += -Wl,--version-script,$(MAPFILE)
+	endif
+	PROCESS_MAP_FILE = grep -v ';-' $(LIBRARY_NAME).def | \
+         sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@
 endif
 
 ifeq ($(USE_PTHREADS),1)
 OS_PTHREAD = -lpthread 
 endif
 
 OS_CFLAGS		= $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe -DLINUX -Dlinux -D_POSIX_SOURCE -D_BSD_SOURCE -DHAVE_STRERROR
 OS_LIBS			= -L/lib $(OS_PTHREAD) -ldl -lc
--- a/security/coreconf/NCR3.0.mk
+++ b/security/coreconf/NCR3.0.mk
@@ -61,16 +61,21 @@ else
 #	OS_LIBS	+=
 endif
 
 #OS_LIBS    += -lsocket -lnsl -ldl -lc
 
 MKSHLIB     += $(LD) $(DSO_LDOPTS)
 #DSO_LDOPTS += -G -z defs
 DSO_LDOPTS += -G
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = cp $(LIBRARY_NAME).def $@
 
 CPU_ARCH    = x86
 ARCH        = ncr
 
 NOSUCHFILE  = /solaris-rm-f-sucks
 
 # now take care of default GCC (rus@5/5/97)
  
--- a/security/coreconf/NEC4.2.mk
+++ b/security/coreconf/NEC4.2.mk
@@ -44,16 +44,21 @@ CC			= gcc
 CCC			= g++
 else
 CC			= $(CORE_DEPTH)/build/hcc
 OS_CFLAGS		= -Xa -KGnum=0 -KOlimit=4000
 CCC			= g++
 endif
 
 MKSHLIB			= $(LD) $(DSO_LDOPTS)
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = cp $(LIBRARY_NAME).def $@
 
 RANLIB			= /bin/true
 
 OS_CFLAGS		+= $(ODD_CFLAGS) -DSVR4 -D__SVR4 -DNEC -Dnec_ews -DHAVE_STRERROR
 OS_LIBS			= -lsocket -lnsl -ldl $(LDOPTIONS)
 LDOPTIONS		= -lc -L/usr/ucblib -lucb
 
 NOSUCHFILE		= /nec-rm-f-sucks
--- a/security/coreconf/NetBSD.mk
+++ b/security/coreconf/NetBSD.mk
@@ -66,12 +66,18 @@ ifeq ($(OBJECT_FMT),ELF)
 DSO_LDOPTS		+= -Wl,-soname,lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
 endif
 
 ifdef LIBRUNPATH
 DSO_LDOPTS		+= -Wl,-R$(LIBRUNPATH)
 endif
 
 MKSHLIB			= $(CC) $(DSO_LDOPTS)
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = cp $(LIBRARY_NAME).def $@
+
 
 G++INCLUDES		= -I/usr/include/g++
 
 INCLUDES		+= -I/usr/X11R6/include
--- a/security/coreconf/OS2.mk
+++ b/security/coreconf/OS2.mk
@@ -81,16 +81,22 @@ DSO_PIC_CFLAGS          =
 MKSHLIB                 = $(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@
 MKCSHLIB                = $(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@
 MKSHLIB_FORCE_ALL       = 
 MKSHLIB_UNFORCE_ALL     = 
 DSO_LDOPTS              = -Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO
 # DLL_SUFFIX              = .dll
 SHLIB_LDSTARTFILE	= 
 SHLIB_LDENDFILE		= 
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = copy $(LIBRARY_NAME).def $@
+
 endif   #NO_SHARED_LIB
 
 OS_CFLAGS          = -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -Zmtd -Zomf -Zmt  -DDEBUG -DDEBUG_wintrinh -DTRACING -g
 
 # Where the libraries are
 MOZ_COMPONENT_NSPR_LIBS=-L$(DIST)/lib $(NSPR_LIBS)
 NSPR_LIBS	= -lplds4 -lplc4 -lnspr4 
 NSPR_INCLUDE_DIR =   
--- a/security/coreconf/OSF1.mk
+++ b/security/coreconf/OSF1.mk
@@ -58,9 +58,15 @@ NON_LD_FLAGS += -ieee_with_inexact
 OS_CFLAGS    += -DOSF1 -D_REENTRANT 
 
 ifeq ($(USE_PTHREADS),1)
 	OS_CFLAGS += -pthread
 endif
 
 # The command to build a shared library on OSF1.
 MKSHLIB    += ld -shared -expect_unresolved "*" -soname $(notdir $@)
+ifdef MAPFILE
+MKSHLIB += -hidden -input $(MAPFILE)
+endif
+PROCESS_MAP_FILE = grep -v ';+' $(LIBRARY_NAME).def | grep -v ';-' | \
+ sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,^,-exported_symbol ,' > $@
+
 DSO_LDOPTS += -shared
--- a/security/coreconf/OpenVMS.mk
+++ b/security/coreconf/OpenVMS.mk
@@ -49,8 +49,14 @@ endif
 # OPTIMIZER in XCFLAGS means that each compilation line gets OPTIMIZER
 # included twice, but at least we get OPTIMIZER included in the link
 # operations; and OpenVMS needs it!
 #
 XCFLAGS                        += $(OPTIMIZER)
 
 # The command to build a shared library in POSIX on OpenVMS.
 MKSHLIB = vmsld_psm OBJDIR=$(OBJDIR) $(OPTIMIZER)
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = copy $(LIBRARY_NAME).def $@
+
--- a/security/coreconf/ReliantUNIX.mk
+++ b/security/coreconf/ReliantUNIX.mk
@@ -60,16 +60,21 @@ else
 	ODD_CFLAGS  = 
 	ifdef BUILD_OPT
 		OPTIMIZER += -O -F Olimit,4000
 	endif
 	MKSHLIB     = $(CC)
 	MKSHLIB    += -G -h $(@:$(OBJDIR)/%.so=%.so)
 	DSO_LDOPTS += -G -W l,-Blargedynsym
 endif
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = cp $(LIBRARY_NAME).def $@
 
 NOSUCHFILE  = /sni-rm-f-sucks
 ODD_CFLAGS += -DSVR4 -DSNI -DRELIANTUNIX
 CPU_ARCH    = mips
 RANLIB      = /bin/true
 
 # For purify
 NOMD_OS_CFLAGS += $(ODD_CFLAGS)
--- a/security/coreconf/SCO_SV3.2.mk
+++ b/security/coreconf/SCO_SV3.2.mk
@@ -68,16 +68,21 @@ JP_LOCALE    = ja
 SJIS_LOCALE  = ja_JP.SJIS
 KR_LOCALE    = ko_KR.EUC
 CN_LOCALE    = zh
 TW_LOCALE    = zh
 I2_LOCALE    = i2
 LOC_LIB_DIR  = /usr/lib/X11
 NOSUCHFILE   = /solaris-rm-f-sucks
 BSDECHO      = /bin/echo
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = cp $(LIBRARY_NAME).def $@
 
 #
 # These defines are for building unix plugins
 #
 BUILD_UNIX_PLUGINS  = 1
 #DSO_LDOPTS         += -b elf -G -z defs
 DSO_LDOPTS         += -b elf -G
 DSO_LDFLAGS        += -nostdlib -L/lib -L/usr/lib -lXm -lXt -lX11 -lgen
--- a/security/coreconf/SunOS5.mk
+++ b/security/coreconf/SunOS5.mk
@@ -127,16 +127,24 @@ OS_DEFINES += -DSVR4 -DSYSV -D__svr4 -D_
 ifneq ($(LOCAL_THREADS_ONLY),1)
 	OS_DEFINES		+= -D_REENTRANT
 endif
 
 # Purify doesn't like -MDupdate
 NOMD_OS_CFLAGS += $(DSO_CFLAGS) $(OS_DEFINES) $(SOL_CFLAGS)
 
 MKSHLIB  = $(LD) $(DSO_LDOPTS)
+ifdef MAPFILE
+    MKSHLIB += -M $(MAPFILE)
+endif
+PROCESS_MAP_FILE = grep -v ';-' $(LIBRARY_NAME).def | \
+         sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@
+
+
+
 
 # ld options:
 # -G: produce a shared object
 # -z defs: no unresolved symbols allowed
 DSO_LDOPTS += -G -h $(notdir $@)
 
 # -KPIC generates position independent code for use in shared libraries.
 # (Similarly for -fPIC in case of gcc.)
--- a/security/coreconf/UNIXWARE2.1.mk
+++ b/security/coreconf/UNIXWARE2.1.mk
@@ -44,8 +44,14 @@ CCC         = $(CORE_DEPTH)/build/hcpp
 RANLIB      = true
 OS_CFLAGS   = -KPIC -DSVR4 -DSYSV -DUNIXWARE
 MKSHLIB     = $(LD)
 MKSHLIB    += $(DSO_LDOPTS)
 DSO_LDOPTS += -G
 CPU_ARCH    = x86
 ARCH        = sco
 NOSUCHFILE  = /solaris-rm-f-sucks
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = cp $(LIBRARY_NAME).def $@
+
--- a/security/coreconf/WIN16.mk
+++ b/security/coreconf/WIN16.mk
@@ -104,14 +104,20 @@ OS_CFLAGS     += -ml -3 -bd -zc -zu -bt=
 #OS_EXE_CFLAGS += -ml -3 -bt=windows -d_X86_ -dWIN16
 OS_LIB_FLAGS   = -c -iro
 
 # Name of the binary code directories
 OS_DLL_OPTION = CASEEXACT
 OS_DLLFLAGS  =
 OS_LIBS      =
 W16_EXPORTS  = #
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = copy $(LIBRARY_NAME).def $@
+
 
 #
 #  The following is NOT needed for the NSPR 2.0 library.
 #
 
 OS_CFLAGS += -d_WINDOWS -d_MSC_VER=700
--- a/security/coreconf/WIN32.mk
+++ b/security/coreconf/WIN32.mk
@@ -86,16 +86,22 @@ else
 	OPTIMIZER  += -Od -Z7
 	#OPTIMIZER += -Zi -Fd$(OBJDIR)/ -Od
 	DEFINES    += -DDEBUG -D_DEBUG -UNDEBUG -DDEBUG_$(USERNAME)
 	DLLFLAGS   += -DEBUG -DEBUGTYPE:CV -OUT:"$@"
 	LDFLAGS    += -DEBUG -DEBUGTYPE:CV
 endif
 
 DEFINES += -DWIN32
+ifdef MAPFILE
+# Add LD options to restrict exported symbols to those in the map file
+endif
+# Change PROCESS to put the mapfile in the correct format for this platform
+PROCESS_MAP_FILE = copy $(LIBRARY_NAME).def $@
+
 
 #
 #  The following is NOT needed for the NSPR 2.0 library.
 #
 
 DEFINES += -D_WINDOWS
 
 # override default, which is ASFLAGS = CFLAGS
--- a/security/coreconf/rules.mk
+++ b/security/coreconf/rules.mk
@@ -372,37 +372,17 @@ ifeq ($(OS_ARCH), WINNT)
 	@$(MAKE_OBJDIR)
 # The resource compiler does not understand the -U option.
 	$(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $<
 	@echo $(RES) finished
 endif
 
 $(MAPFILE): $(LIBRARY_NAME).def
 	@$(MAKE_OBJDIR)
-ifeq ($(OS_ARCH),SunOS)
-	grep -v ';-' $(LIBRARY_NAME).def | \
-	 sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@
-endif
-ifeq ($(OS_ARCH),Linux)
-	grep -v ';-' $(LIBRARY_NAME).def | \
-	 sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@
-endif
-ifeq ($(OS_ARCH),AIX)
-	grep -v ';+' $(LIBRARY_NAME).def | grep -v ';-' | \
-		sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' > $@
-endif
-ifeq ($(OS_ARCH), HP-UX)
-	grep -v ';+' $(LIBRARY_NAME).def | grep -v ';-' | \
-	 sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,^,+e ,' > $@
-endif
-ifeq ($(OS_ARCH), OSF1)
-	grep -v ';+' $(LIBRARY_NAME).def | grep -v ';-' | \
- sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,^,-exported_symbol ,' > $@
-endif
-
+	$(PROCESS_MAP_FILE)
 
 
 $(OBJDIR)/$(PROG_PREFIX)%$(PROG_SUFFIX): $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 ifeq ($(OS_ARCH),WINNT)
 	$(MKPROG) $(OBJDIR)/$(PROG_PREFIX)$*$(OBJ_SUFFIX) -Fe$@ -link \
 	$(LDFLAGS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
 else