| 1 |
# -*- Makefile -*- |
| 2 |
#---------------------------------------------------------------------------- |
| 3 |
# |
| 4 |
# |
| 5 |
# Build libraries (i.e., contain no binary executables) |
| 6 |
# GNU version |
| 7 |
# Requires GNU make |
| 8 |
#---------------------------------------------------------------------------- |
| 9 |
|
| 10 |
#--------------------------------------------------------------------------- |
| 11 |
# Library versioning |
| 12 |
#--------------------------------------------------------------------------- |
| 13 |
|
| 14 |
ifneq ($(versioned_so),0) |
| 15 |
# Turn on symbol versioning. The scheme that we follow is to allow |
| 16 |
# applications dependent on libraries, with same version numbers (major, |
| 17 |
# minor and beta) to run, but applications with dependencies on libraries |
| 18 |
# with different minor or major or beta versions to fail. |
| 19 |
# |
| 20 |
# Version number of the libraries |
| 21 |
# |
| 22 |
ifeq ($(SOVERSION),) |
| 23 |
ifeq ($(versioned_so),1) |
| 24 |
SOVERSION = .$(GNUACE_PROJECT_VERSION) |
| 25 |
else ifeq ($(versioned_so),2) |
| 26 |
SOVERSION = -$(GNUACE_PROJECT_VERSION) |
| 27 |
else ifeq ($(versioned_so),3) |
| 28 |
# Nothing |
| 29 |
else |
| 30 |
$(error unknown value for versioned_so: $(versioned_so)) |
| 31 |
endif |
| 32 |
endif # SOVERSION |
| 33 |
|
| 34 |
# Name that will be written into the dynamic library |
| 35 |
# |
| 36 |
ifeq ($(SONAME),) |
| 37 |
ifeq ($(versioned_so),1) |
| 38 |
SONAME = $(SHLIB)$(SOVERSION) |
| 39 |
else ifeq ($(versioned_so),2) |
| 40 |
SONAME = $(patsubst %.$(SOEXT),%,$(SHLIB))$(SOVERSION).$(SOEXT) |
| 41 |
else ifeq ($(versioned_so),3) |
| 42 |
SONAME = $(SHLIB) |
| 43 |
endif |
| 44 |
endif # SONAME |
| 45 |
endif # versioned_so |
| 46 |
|
| 47 |
|
| 48 |
#---------------------------------------------------------------------------- |
| 49 |
# The following targets arrange to build both unshared and shared libraries |
| 50 |
#---------------------------------------------------------------------------- |
| 51 |
|
| 52 |
VLIB = $(ARCH_LIB:%.$(LIBEXT)=%$(VAR).$(LIBEXT)) |
| 53 |
CLEANUP_VLIB = $(CLEANUP_LIB:%.$(LIBEXT)=%$(VAR).$(LIBEXT)) |
| 54 |
|
| 55 |
# Add VLIB to VLIBS if building static_libs. |
| 56 |
ifdef static_libs |
| 57 |
VLIBS += $(VLIB) |
| 58 |
endif |
| 59 |
|
| 60 |
SHLIB ?= |
| 61 |
# Setup shared library variables, including versions. |
| 62 |
VSHLIB_NO_VER = $(ARCH_SHLIB:%.$(SOEXT)=%$(VAR).$(SOEXT)) |
| 63 |
CLEANUP_VSHLIB_NO_VER = $(CLEANUP_SHLIB:%.$(SOEXT)=%$(VAR).$(SOEXT)) |
| 64 |
ifneq ($(versioned_so),2) |
| 65 |
VSHLIB = $(VSHLIB_NO_VER:%=%$(SOVERSION)) |
| 66 |
CLEANUP_VSHLIB = $(CLEANUP_VSHLIB_NO_VER:%=%$(SOVERSION)) |
| 67 |
SHLIB_WITH_VER = $(SHLIB:%=%$(SOVERSION)) |
| 68 |
else |
| 69 |
VSHLIB = $(if $(VSHLIB_NO_VER), $(patsubst %.$(SOEXT),%,$(VSHLIB_NO_VER))$(SOVERSION).$(SOEXT)) |
| 70 |
CLEANUP_VSHLIB = $(if $(CLEANUP_VSHLIB_NO_VER), $(patsubst %.$(SOEXT),%,$(CLEANUP_VSHLIB_NO_VER))$(SOVERSION).$(SOEXT)) |
| 71 |
SHLIB_WITH_VER = $(if $(SHLIB), $(patsubst %.$(SOEXT),%,$(SHLIB))$(SOVERSION).$(SOEXT)) |
| 72 |
endif |
| 73 |
|
| 74 |
SHLIBA ?= |
| 75 |
VSHLIBA = $(ARCH_SHLIBA:%.$(LIBEXT)=%$(VAR).$(LIBEXT)) |
| 76 |
|
| 77 |
# Add VSHLIB if we're building shared_libs. |
| 78 |
ifdef shared_libs |
| 79 |
VLIBS += $(VSHLIB) $(VSHLIBA) |
| 80 |
endif |
| 81 |
|
| 82 |
# Warn if no libs found |
| 83 |
ifeq ($(VLIBS),) |
| 84 |
LIB_WARNING = 0 |
| 85 |
ifndef LIB_UNCHECKED |
| 86 |
LIB_WARNING = 1 |
| 87 |
endif # !LIB_CHECKED |
| 88 |
ifndef SHLIB_UNCHECKED |
| 89 |
LIB_WARNING = 1 |
| 90 |
endif # !SHLIB_UNCHECKED |
| 91 |
ifeq ($(LIB_WARNING),1) |
| 92 |
@echo Warning: rules.lib.GNU included, but no library targets detected. |
| 93 |
endif # LIB_WARNING |
| 94 |
else # VLIBS |
| 95 |
# Libraries always depend on idl_stubs, if they exist. |
| 96 |
IDL_SRC ?= |
| 97 |
ifeq ($(IDL_SRC),) |
| 98 |
$(VLIBS): $(IDL_SRC) |
| 99 |
endif # IDL_SRC |
| 100 |
endif # !VLIBS |
| 101 |
|
| 102 |
VLOBJS = $(addprefix $(VDIR),$(foreach var, $(addsuffix .$(OBJEXT), $(basename $(LSRC)) $(RESOURCES)), $(patsubst ../%,$(notdir $(var)),$(var)))) |
| 103 |
ifdef LSRC2 |
| 104 |
LSRC += $(LSRC2) |
| 105 |
endif |
| 106 |
|
| 107 |
VSHOBJS = $(addprefix $(VSHDIR),$(foreach var, $(addsuffix .$(OBJEXT), $(basename $(LSRC)) $(RESOURCES)), $(patsubst ../%,$(notdir $(var)),$(var)))) |
| 108 |
|
| 109 |
ifneq ($(IDL_SRC),) |
| 110 |
$(VLOBJS) $(VSHOBJS): $(IDL_SRC) |
| 111 |
endif |
| 112 |
|
| 113 |
# Since INSLIB already has the ARCH dir appended, if appropriate, ARCH |
| 114 |
# needs to be stripped from V[SH]LIB on the way over to INSLIB. To avoid |
| 115 |
# an extra '/' which confuses the relative link calculation, ensure the |
| 116 |
# '/' after ARCH is stripped if it's an ARCH build. |
| 117 |
ARCHDIR ?= |
| 118 |
ifdef ARCH |
| 119 |
ARCHDIR = $(ARCH)/ |
| 120 |
endif |
| 121 |
|
| 122 |
ifneq ($(INSLIB),) |
| 123 |
ifdef static_libs |
| 124 |
LIB_INSTALL += $(VLIB:$(ARCHDIR)%=$(INSLIB)/%) |
| 125 |
CLEANUP_INSTALL += $(CLEANUP_VLIB:$(ARCHDIR)%=$(INSLIB)/%) |
| 126 |
endif # static_libs |
| 127 |
|
| 128 |
ifdef shared_libs |
| 129 |
LIB_INSTALL += $(VSHLIB:$(ARCHDIR)%=$(INSLIB)/%) |
| 130 |
CLEANUP_INSTALL += $(CLEANUP_VSHLIB:$(ARCHDIR)%=$(INSLIB)/%) |
| 131 |
CLEANUP_INSTALL += $(CLEANUP_VSHLIB_NO_VER:$(ARCHDIR)%=$(INSLIB)/%*) |
| 132 |
ifdef SHLIBA |
| 133 |
LIB_INSTALL += $(VSHLIBA:$(ARCHDIR)%=$(INSLIB)/%) |
| 134 |
CLEANUP_INSTALL += $(CLEANUP_SHLIBA:$(ARCHDIR)%=$(INSLIB)/%) |
| 135 |
endif |
| 136 |
endif # shared_libs |
| 137 |
endif # INSLIB |
| 138 |
|
| 139 |
ace_lib_prelink ?= 0 |
| 140 |
|
| 141 |
ifeq (1,$(VXWORKS)) |
| 142 |
|
| 143 |
ifeq (1,$(ace_lib_prelink)) |
| 144 |
.PHONY: ace-templ_inst |
| 145 |
|
| 146 |
ace-templ_inst: |
| 147 |
-$(LINK.cc) $(LINK_OUTPUT_FLAG) ace-templ_inst $(VLOBJS) $(LDFLAGS) $(ACE_SHLIBS) |
| 148 |
-$(RM) ace-templ_inst |
| 149 |
|
| 150 |
$(VLIB): $(VLOBJS) ace-templ_inst |
| 151 |
else |
| 152 |
$(VLIB): $(VLOBJS) |
| 153 |
endif |
| 154 |
ifeq (1,$(repo)) |
| 155 |
@echo $(LINK.cc) $(LINK_OUTPUT_FLAG) > .prelink.spec |
| 156 |
@echo xargs $(AR) $(ARFLAGS) $(notdir $@) $(AREXTRA) >> .prelink.spec |
| 157 |
@if not [""]==["$(ACE_SHLIBS)"] @echo $(subst -l,,$(ACE_SHLIBS)) >> .prelink.spec |
| 158 |
@echo Add .rpo files |
| 159 |
echo .prelink.spec $(foreach rpo,$(patsubst %.$(OBJEXT),%.rpo,$(filter %.$(OBJEXT), $?)),$(shell if exist $(rpo) echo $(rpo))) | xargs $(AR) $(ARFLAGS) $@ $(AREXTRA) |
| 160 |
endif |
| 161 |
@echo Add .o files |
| 162 |
echo $(TMPINCDIR:%=%/*.$(OBJEXT)) $(filter %.$(OBJEXT), $?) | xargs $(AR) $(ARFLAGS) $@ $(AREXTRA) |
| 163 |
-chmod a+r $@ |
| 164 |
ifneq (,$(RANLIB)) |
| 165 |
-$(RANLIB) $@ |
| 166 |
endif # RANLIB |
| 167 |
|
| 168 |
else # !VXWORKS |
| 169 |
|
| 170 |
$(VLIB): $(VLOBJS) |
| 171 |
ifeq (1,$(repo)) |
| 172 |
ifneq (,$(ACELIB)) |
| 173 |
#### With repo, link in all of the ace object files to the lib. |
| 174 |
#### This avoids multiple instantiations. We haven't found it to |
| 175 |
#### be necessary with shared libs, so just do it for static libs. |
| 176 |
vpath %.$(OBJEXT) $(ACE_ROOT)/ace/$(VDIR) |
| 177 |
|
| 178 |
$(VLIB): $(ACE_ROOT)/ace/$(VDIR)*.$(OBJEXT) |
| 179 |
endif # ! ACELIB |
| 180 |
endif # repo |
| 181 |
ifdef PRELIB |
| 182 |
$(PRELIB) |
| 183 |
endif |
| 184 |
ifeq (1,$(ace_lib_prelink)) |
| 185 |
#### Attempt a link (which will fail), to add template instantiations |
| 186 |
#### to lib files, for example. |
| 187 |
-$(LINK.cc) $(LINK_OUTPUT_FLAG) ace-templ_inst $? $(LDFLAGS) $(ACE_NUL_STDERR) |
| 188 |
endif # ace_lib_prelink |
| 189 |
ifneq (,$(AR.cc.override)) |
| 190 |
$(AR.cc.override) |
| 191 |
else |
| 192 |
([ "`echo $(TMPINCDIR:%=%/*.$(OBJEXT))`" != "$(TMPINCDIR:%=%/*.$(OBJEXT))" ] && echo $(TMPINCDIR:%=%/*.$(OBJEXT)); \ |
| 193 |
echo $(filter %.$(OBJEXT), $^)) | xargs $(AR) $(ARFLAGS) $@ $(AREXTRA) |
| 194 |
endif |
| 195 |
-chmod a+r $@ |
| 196 |
ifneq (,$(RANLIB)) |
| 197 |
-$(RANLIB) $@ |
| 198 |
endif # RANLIB |
| 199 |
|
| 200 |
endif # !VXWORKS |
| 201 |
|
| 202 |
ifeq ($(VXWORKSLINK),1) |
| 203 |
$(VSHLIB): $(basename $(notdir $(PRJ_FILE))).out |
| 204 |
-$(RM) $@ |
| 205 |
-$(LN_S) $(PROJECT_OUT) $@ |
| 206 |
-$(POST_BUILD_RULE) |
| 207 |
else # !VXWORKSLINK |
| 208 |
$(VSHLIB): $(VSHOBJS) |
| 209 |
ifdef PRELIB |
| 210 |
$(PRELIB) |
| 211 |
endif # PRELIB |
| 212 |
ifdef SHLIBBUILD |
| 213 |
$(SHLIBBUILD) |
| 214 |
else # ! SHLIBBUILD |
| 215 |
ifeq (1,$(ace_lib_prelink)) |
| 216 |
#### Attempt a link (which will fail), to add template instantiations |
| 217 |
#### to lib files, for example. |
| 218 |
-$(LINK.cc) $(LINK_OUTPUT_FLAG) ace-templ_inst $^ $(LDFLAGS) $(ACE_NUL_STDERR) |
| 219 |
endif # ace_lib_prelink |
| 220 |
ifneq ($(SOLINK.cc.override),) |
| 221 |
$(SOLINK.cc.override) |
| 222 |
else |
| 223 |
$(SHR_FILTER) $(SOLINK.cc) $(SO_OUTPUT_FLAG) $@ $^ $(LDFLAGS) $(ACE_SHLIBS) $(LIBS) |
| 224 |
endif #override |
| 225 |
endif # SHLIBBUILD |
| 226 |
endif # VXWORKSLINK |
| 227 |
ifneq ($(SOVERSION),) |
| 228 |
# This carefully works with both ARCH (where VSHLIB_* refer to the ARCH |
| 229 |
# subdir, but SHLIB does not) and non-ARCH builds (where VSHLIB_* and SHLIB |
| 230 |
# refer to the same place). SHLIB_WITH_VER should be the same as $@ but |
| 231 |
# without the ARCH subdir. |
| 232 |
-$(RM) $(VSHLIB_NO_VER) |
| 233 |
-$(LN_S) $(if $(findstring cp,$(firstword $(LN_S))),$(@),$(SHLIB_WITH_VER)) $(VSHLIB_NO_VER) |
| 234 |
endif |
| 235 |
-chmod a+rx $@ |