Second installment of shared library changes.

This commit is contained in:
Janet B. Anderson
1998-05-13 14:44:21 +00:00
parent a7045a039e
commit 69fadca2bb
11 changed files with 122 additions and 50 deletions

View File

@@ -9,6 +9,7 @@ ARCH_CLASS = Linux
include $(EPICS_BASE)/config/CONFIG.Host.UnixCommon
AR = ar -rc
ARCMD = $(AR) $@
RANLIB = ranlib -t
# Configure OS vendor C compiler
@@ -55,4 +56,17 @@ CCC_DEPENDS_FLAG = -MM
ARCH_DEP_CFLAGS = -D_X86_ -Dlinux
ARCH_DEP_LDFLAGS =
#glibc FAQ
# "_GNU_SOURCE: glibc does not make the GNU extensions available
# automatically. If a program depends on the GNU extensions or some other
# non-standard functionality, it is necessary to compile it with the C
# compiler option -D_GNU_SOURCE, or better to put #define _GNU_SOURCE at
# the beginning of your source files, before any C library header files
# are included. This difference normally manifests itself in the form
# of missing prototypes and/or data type definitions. Thus, if you get
# such errors, the first thing you should do is try defining _GNU_SOURCE
# and see if that makes the problem go away."
#ARCH_DEP_CFLAGS += -D_GNU_SOURCE

View File

@@ -17,13 +17,14 @@ LIBNAME = $(LIBRARY:%=lib%.a)
# CONFIG.Host.<arch> files may override
SHRLIB_SUFFIX = .so
SHRLIB_VERSION = .$(EPICS_VERSION).$(EPICS_REVISION)
SHRLIBNAME = lib$(LIBRARY)$(SHRLIB_SUFFIX)$(SHRLIB_VERSION)
SHRLIBNAME = lib$(LIBRARY)$(SHRLIB_SUFFIX)$(SHRLIB_VERSION:%=.%)
SHRLIB_CFLAGS = $($(ANSI)_SHRLIB_CFLAGS_$(SHARED_LIBRARIES))
SHRLIB_LDFLAGS = $($(ANSI)_SHRLIB_LDFLAGS_$(SHARED_LIBRARIES))
LINK.dll= $(SHRLIB_LINKER) -o $@ $(CFLAGS) $(CPPFLAGS) $(SHRLIB_LDFLAGS) $(LDFLAGS)
INSTALL_SHRLIB = $(INSTALL_LIB)
LINK.shrlib= $(SHRLIB_LINKER) -o $@ $(CFLAGS) $(CPPFLAGS) $(SHRLIB_LDFLAGS) $(LDFLAGS)
#-------------------------------------------------------
# Unix command definitions

View File

@@ -125,7 +125,7 @@ CCC_SLIBS_YES=
CCC_SLIBS_NO=
LINK_OPT_FLAGS_YES = /WARN:3 /incremental:no /opt:ref\
/release /version:$(EPICS_VERSION).$(EPICS_REVISION)
/release $(PROD_VERSION:%=/version:%)
LINK_OPT_FLAGS_NO = /WARN:3 /debug
OPT_LDFLAGS = $(LINK_OPT_FLAGS_$(HOST_OPT))
@@ -191,30 +191,33 @@ HOST_OPT_FLAGS += $(subst $@, /_WINDLL, $(findstring $@,$(LIBOBJS)))
#
# A WIN32 dll has three parts:
# x.dll: the real dll (DLLNAME)
# x.dll: the real dll (SHRLIBNAME)
# x.lib: what you link to progs that use the dll (LIBNAME)
# x.exp: what you need to build the dll (in no variable)
#
LINK.dll = $(WINLINK) /nologo $(WIN32_DLLFLAGS) /implib:$(@:%.dll=%.lib) /out:$@ $(DLL_DEF_FLAG)
LINK.shrlib = $(WINLINK) /nologo $(WIN32_DLLFLAGS) /implib:$(DLL_LINK_LIBNAME) /out:$(SHRLIBNAME) $(DLL_DEF_FLAG)
# adjust names of libraries to build
#
# But: if there are no objects LIBOBJS to include
# in this library (may be for e.g. base/src/libCompat
# on some archs), don't define (and build) any library!
DLLNAME = $(LIBRARY).dll
SHRLIBNAME = $(LIBRARY).dll
#
# Under WIN32 we have the unique situation where the DLL link creates the
# DLL link library xxx.lib and we need to be very careful to avoid replacing
# the xxx.lib created by the dll link with an xxx.lib created by $(AR)
#
# LIBTYPE is empty if we are not building a DLL
# SHARED_LIBRARIES is YES if we are building a DLL and NO if we aren't
#
DLL_LINK_LIBNAME_SHARED = $(LIBRARY).lib
DLL_LINK_LIBNAME = $(DLL_LINK_LIBNAME_$(LIBTYPE))
OBJECT_LIBNAME_ = $(LIBRARY).lib
LIBNAME = $(OBJECT_LIBNAME_$(LIBTYPE))
DLL_LINK_LIBNAME_YES = $(LIBRARY).lib
DLL_LINK_LIBNAME = $(DLL_LINK_LIBNAME_$(SHARED_LIBRARIES))
OBJECT_LIBNAME_NO = $(LIBRARY).lib
LIBNAME = $(OBJECT_LIBNAME_$(SHARED_LIBRARIES))
# dll install location
INSTALL_SHRLIB = $(INSTALL_BIN)
#--------------------------------------------------
# Dependancy definitions

View File

@@ -17,6 +17,8 @@ EXE=.exe
ANSI=GCC
# c++ code won't build with b19
CPLUSPLUS=
# Shared libraries not implemented yet
SHARED_LIBRARIES=NO
#==========================
# Fix for cygwin32 beta17.1 includes
#OP_SYS_INCLUDES += /usr/local/include/g++

View File

@@ -148,6 +148,7 @@ TARGET_INCLUDES = $($(basename $@)_INCLUDES)
TARGET_CFLAGS = $($(basename $@)_CFLAGS)
TARGET_CXXFLAGS = $($(basename $@)_CXXFLAGS)
TARGET_LDFLAGS = $($(basename $@)_LDFLAGS)
TARGET_LDLIBS = $($(basename $@)_LDLIBS)
TARGET_CPPFLAGS = $($(basename $@)_CPPFLAGS)
TARGET_SNCFLAGS = $($(basename $@)_SNCFLAGS)
@@ -205,7 +206,7 @@ CXXFLAGS = $(OPT_CXXFLAGS) $(DEBUG_CXXFLAGS) $(WARN_CXXFLAGS) $(TARGET_CXXFLAGS)
LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS)\
$(ARCH_DEP_LDFLAGS) $(STATIC_LDFLAGS) $(OP_SYS_LDFLAGS)
LDLIBS = $(USR_LDLIBS) $(ARCH_DEP_LDLIBS)\
LDLIBS = $(TARGET_LDLIBS) $(USR_LDLIBS) $(ARCH_DEP_LDLIBS)\
$(STATIC_LDLIBS) $(OP_SYS_LDLIBS)
CPPFLAGS += $(TARGET_CPPFLAGS) $(USR_CPPFLAGS)

View File

@@ -12,7 +12,7 @@ CHMOD=echo
WHAT=echo
ECHO=echo
WIND_HOST_TYPE =
WIND_HOST_TYPE = x86-win32
# Use std path variables from ms
HOME = $(HOMEDRIVE)$(HOMEPATH)

View File

@@ -56,6 +56,7 @@ TORNADO=YES
#TORNADO=NO
# VxWorks directory for TORNADO=YES
#VX_DIR_YES=c:\\Tornado
VX_DIR_YES = /usr/local/vw/tornado101
# VxWorks directory for TORNADO=NO
@@ -98,13 +99,17 @@ CMPLR=STRICT
# Individual Makefiles may override
CXXCMPLR=STRICT
# Build shared libraries? (Unix type Host builds only)
# Build shared libraries?
# (archive libraries will also be built)
# must be either YES or NO
# NOTE: CONFIG_SITE.Host.$(HOST_ARCH) files may override
#
# NOTE WIN32: YES results in a DLL. CONFIG_SITE.Host.WIN32
# distribution file contains YES override
#
# NOTE solaris and sun4: If YES then LD_LIBRARY_PATH must
# include $(INSTALL_LOCATION)/lib/$(HOST_ARCH) both
# for the base build and when invoking base executables
# include fullpathname $(INSTALL_LOCATION)/lib/$(HOST_ARCH)
# for both the base build and when invoking base executables
SHARED_LIBRARIES=NO
# Build client objects statically ?

View File

@@ -0,0 +1,8 @@
#
# $Id$
#
# Site Specific Configuration Information
# Only the local epics system manager should modify this file
SHARED_LIBRARIES = YES

View File

@@ -1,4 +1,4 @@
#
# $Id$
#
# Rules for making things specified in Makefile.Host
@@ -238,8 +238,7 @@ INCREC +=$(RECTYPES) $(MENUS)
INSTALL_PROD= $(PROD:%= $(INSTALL_BIN)/%)
INSTALL_LIBS= $(LIBNAME:%=$(INSTALL_LIB)/%)
INSTALL_SHRLIBS= $(SHRLIBNAME:%=$(INSTALL_LIB)/%)
INSTALL_DLLS=$(DLLNAME:%=$(INSTALL_BIN)/%)
INSTALL_SHRLIBS= $(SHRLIBNAME:%=$(INSTALL_SHRLIB)/%)
INSTALL_DLL_LINK_LIBS=$(DLL_LINK_LIBNAME:%=$(INSTALL_LIB)/%)
INSTALL_TCLLIBS=$(TCLLIBNAME:%=$(INSTALL_TCLLIB)/%)
INSTALL_TCLINDEX=$(TCLINDEX:%=$(INSTALL_TCLLIB)/%)
@@ -282,6 +281,15 @@ ifdef TEMPLATES_DIR
DIRECTORY_TARGETS += $(INSTALL_TEMPLATES)/$(TEMPLATES_DIR)
endif
#---------------------------------------------------------------
ifneq (x$(SHARED_LIBRARIES_$(ARCH_CLASS)),x)
SHARED_LIBRARIES+=$(subst -nil-,,$(SHARED_LIBRARIES_$(ARCH_CLASS)))
else
ifdef SHARED_LIBRARIES_DEFAULT
SHARED_LIBRARIES_+=$(SHARED_LIBRARIES_DEFAULT)
endif
endif
#---------------------------------------------------------------
# must use c++ linker if linking to shared libs with c++ code
ifeq ($(strip $(SHARED_LIBRARIES)),YES)
@@ -291,6 +299,15 @@ endif # CPLUSPLUS
endif # LIBTYPE
#---------------------------------------------------------------
# Version number for base shared libraries (and win32 products)
ifeq ($(EPICS_BASE),$(TOP))
SHRLIB_VERSION = $(EPICS_VERSION).$(EPICS_REVISION)
PROD_VERSION = $(EPICS_VERSION).$(EPICS_REVISION)
endif # EPICS_BASE
#---------------------------------------------------------------
# Libraries
#
# if there are no objects LIBOBJS to include
# in this library (may be for e.g. base/src/libCompat
# on some archs), don't define (and build) any library!
@@ -299,17 +316,10 @@ ifdef LIBOBJS
LIBTARGETS = $(INSTALL_LOCATION_LIB) $(INSTALL_LIB)
LIBTARGETS += $(LIBNAME) $(INSTALL_LIBS)
# check if DLL or plain lib requested: (Win32 build)
ifeq ($(strip $(LIBTYPE)),SHARED)
#
# LIBTYPE=="SHARED" indicates build
# DLL and install both dll and dll link library
#
LIBTARGETS += $(DLLNAME) $(INSTALL_DLLS) $(INSTALL_DLL_LINK_LIBS)
endif # LIBTYPE=SHARED
# check if shared library requested: (Unix type build)
# check if shared libraries requested
ifeq ($(strip $(SHARED_LIBRARIES)),YES)
PROD_VERSION =$(SHRLIB_VERSION)
CFLAGS += $(SHRLIB_CFLAGS)
CXXFLAGS += $(SHRLIB_CFLAGS)
ifeq ($(findstring cc,$(suffix $(LIBSRCS))),cc)
@@ -317,7 +327,8 @@ SHRLIB_LINKER = $(CXX)
else
SHRLIB_LINKER = $(CC)
endif
LIBTARGETS += $(SHRLIBNAME) $(INSTALL_SHRLIBS)
LIBTARGETS += $(SHRLIBNAME) $(INSTALL_SHRLIBS) $(INSTALL_DLL_LINK_LIBS)
endif # SHARED_LIBRARIES=YES
endif # LIBOBJS
@@ -356,7 +367,7 @@ depends:: $(LIBSRCS) $(SRCS)
clean::
@echo "Cleaning"
@$(RM) *.i *$(OBJ) *.a $(PROD) $(TESTPROD) $(LIBNAME) $(INC) *$(RES) $(TARGETS)
@$(RM) *.i *$(OBJ) *.a $(PROD) $(TESTPROD) $(LIBNAME) $(SHRLIBNAME) $(INC) *$(RES) $(TARGETS)
$(DIRECTORY_TARGETS) :
$(MKDIR) $@
@@ -379,6 +390,22 @@ endif
ifdef PRODNAME
ifneq (x$(PRODNAME_SRCS_$(ARCH_CLASS)),x)
PRODNAME_SRCS += $(subst -nil-,,$(PRODNAME_SRCS_$(ARCH_CLASS)))
else
ifdef PRODNAME_SRCS_DEFAULT
PRODNAME_SRCS += $(PRODNAME_SRCS_DEFAULT)
endif
endif
ifneq (x$(PRODNAME_RCS_$(ARCH_CLASS)),x)
PRODNAME_RCS += $(subst -nil-,,$(PRODNAME_RCS_$(ARCH_CLASS)))
else
ifdef PRODNAME_RCS_DEFAULT
PRODNAME_RCS += $(PRODNAME_RCS_DEFAULT)
endif
endif
$(PRODNAME): $(PROD_DEPLIBS) $(PRODNAME_DEPLIBS)
ifdef PRODNAME_SRCS
@@ -409,7 +436,11 @@ PROD_RESS=$(addsuffix $(RES), $(basename $(RCS) $(COND_PROD_RCS)))
PROD_MAKE_COMMAND=$(MAKE) $@\
PRODNAME="$@"\
PRODNAME_SRCS="$(SRCS) $($(basename $@)_SRCS)"\
PRODNAME_RCS="$(RCS) $($(basename $@)_RCS) $($(basename $@)_RCS_$(ARCH_CLASS))"\
PRODNAME_SRCS_DEFAULT="$($(basename $@)_SRCS_DEFAULT)"\
PRODNAME_SRCS_$(ARCH_CLASS)="$($(basename $@)_SRCS_$(ARCH_CLASS))"\
PRODNAME_RCS="$(RCS) $($(basename $@)_RCS)"\
PRODNAME_RCS_DEFAULT="$($(basename $@)_RCS_DEFAULT)"\
PRODNAME_RCS_$(ARCH_CLASS)="$($(basename $@)_RCS_$(ARCH_CLASS))"\
PRODNAME_LIBS="$($(basename $@)_LIBS)"
$(PROD): $(PROD_OBJS) $(PROD_RESS) $(PROD_DEPLIBS) $(COND_PROD_DEPLIBS)
@@ -638,12 +669,8 @@ $(DBDNAME): ../$(DBDEXPAND)
@$(RM) $@
$(EPICS_BASE)/bin/$(HOST_ARCH)/dbExpand$(EXE) $(USER_DBDFLAGS) $< > $@
# rule for shareable (DLL- dynamic link library) creation
$(DLLNAME): $(LIBOBJS)
$(LINK.dll) $(LIBOBJS) $(DLL_LDLIBS)
$(SHRLIBNAME): $(LIBOBJS)
$(LINK.dll) $(LIBOBJS)
$(DLL_LINK_LIBNAME) $(SHRLIBNAME): $(LIBOBJS)
$(LINK.shrlib) $(LIBOBJS) $(DLL_LDLIBS)
# rule for lib (archive of object files) creation
$(LIBNAME): $(LIBOBJS)
@@ -674,14 +701,14 @@ endif # RANLIB
$(INSTALL_LIB)/%.lib: %.lib
@echo "Installing library $@"
@$(INSTALL) -m 644 $< $(INSTALL_LIB)
@$(INSTALL) -d -m 644 $< $(INSTALL_LIB)
$(INSTALL_SHRLIBS): $(SHRLIBNAME)
$(INSTALL_SHRLIB)/lib%: lib%
@echo "Installing library $@"
$(INSTALL) -m 555 $< $(INSTALL_LIB)
@$(INSTALL) -m 555 $< $(INSTALL_SHRLIB)
ifdef SHRLIB_VERSION
$(RM) $(subst $(SHRLIB_VERSION),,$@)
ln -s $< $(subst $(SHRLIB_VERSION),,$@)
@$(RM) $(@:%.$(SHRLIB_VERSION)=%)
ln -s $< $(@:%.$(SHRLIB_VERSION)=%)
endif # SHRLIB_VERSION
$(INSTALL_TCLLIB)/%: %

View File

@@ -1,9 +1,13 @@
# $Id$
ifneq (x$(LIBOBJS_$(ARCH_CLASS)),x)
LIBOBJS += $(subst -nil-,,$(LIBOBJS_$(ARCH_CLASS)))
LIBOBJS+=$(subst -nil-,,$(LIBOBJS_$(ARCH_CLASS)))
else
ifdef LIBOBJS_DEFAULT
LIBOBJS+=$(LIBOBJS_DEFAULT)
endif
endif
INCREC +=$(RECTYPES) $(MENUS)
INSTALL_PROD = $(PROD:%= $(INSTALL_BIN)/%)
INSTALL_LIBS = $(LIBNAME:%= $(INSTALL_BIN)/%)

View File

@@ -89,10 +89,6 @@ LIBSRCS_DEFAULT = posix.c
LIBSRCS_WIN32 = win32_special.c
LIBSRCS_BSD = -nil-
# Type of library to build.
# On WIN32, SHARED results in a DLL, others may ignore this.
LIBTYPE=SHARED
# Library to build:
# lib$(LIBRARY).a or ..dll/..exp/..lib
#
@@ -100,6 +96,12 @@ LIBTYPE=SHARED
#
LIBRARY=libname
# if SHARED_LIBRARIES is YES then
# Library version
SHRLIB_VERSION =
# On WIN32 results in /version:$(SHRLIB_VERSION) link option
# On Unix type hosts .$(SHRLIB_VERSION) is appended to library name
# --------------------------------------------------------------------
# defining products (executable programs)
# --------------------------------------------------------------------
@@ -137,6 +139,11 @@ PROD_WIN32 = product_only_for_WIN32
PROD_BSD = product_only_for_BSD
PROD_SYSV = product_only_for_SYSV
# Product version
PROD_VERSION =
# On WIN32 results in /version:$(SHRLIB_VERSION) link option
# On Unix type hosts PROD_VERSION) is ignored
# Scripts to install
#
# If there is both ../$(SCRIPT) and ../$(ARCH_CLASS)/$(SCRIPT),