Menu

[r3316]: / trunk / unix-common.mk  Maximize  Restore  History

Download this file

105 lines (85 with data), 3.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
# -*-makefile-*- <-- an Emacs control
# The including make file must define these make variables:
#
# SHARED_LIBS_TO_BUILD: List of the shared libraries that need to be
# built -- just the basic library names. E.g. "libfoo libbar"
#
# SHARED_LIBS_TO_INSTALL: List of the shared libraries that need to be
# installed -- just the basic library names. E.g. "libfoo libbar"
#
# SHLIB_SUFFIX: Shared library filename suffix, e.g. "so".
#
# MAJ: Library major version number, e.g. "3" in file name "libfoo.3.1"
#
# MIN: Library minor version number, e.g. "1" in file name "libfoo.3.1"
#
# LDFLAGS_SHLIB: linker (Ld) flags needed to link object files together into
# a shared library. May use $(SONAME) for the soname of the library.
# Include -lc if appropriate.
#
# LADD: Additional linker flags (normally set on the make command line).
#
# INSTALL_DATA: beginning of shell command to install a library file.
#
# DESTDIR: main installation directory
#
# LIBINST_DIR: directory in which to install libraries, relative to DESTDIR.
#
# LN_S: beginning of shell command to make symbolic link (e.g. "ln -s").
#
# CXXLD: beginning of shell command to link, e.g. "g++".
# This make file defines these make variables that the including make file
# can use:
#
# SHLIB_CMD: a command to build a shared library for C linkage
# You can use this in a rule to build a shared library
# SHLIBPP_CMD: Same, but for C++ linkage
# Including make file must contain a rule to build each library file
# (e.g. libfoo.3.1)
# This make file provides these rules:
#
# install-shared-libraries: install all shared libraries and the necessary
# symbolic links.
# uninstall-shared-libraries: remove what would be installed by
# install-shared-libraries
# SONAME is to be referenced by $(LDFLAGS_SHLIB) in the rule to make
# a shared library (in common.mk). I.e. $@ is the name of the shared
# library file.
# SONAME is the name of the library file being built, with the minor
# version number cut off. E.g. if we're building libfoo.so.1.2, SONAME
# is libfoo.so.1 .
SONAME = $(@:%.$(MIN)=%)
SHLIB_CMD = $(CCLD) $(LADD) $(LDFLAGS_SHLIB) -o $@ $^
SHLIB_LE_TARGETS = $(call shliblefn, $(SHARED_LIBS_TO_BUILD))
$(SHLIB_LE_TARGETS):%:%.$(MAJ)
rm -f $@
$(LN_S) $< $@
SONAME_TARGETS = $(SHLIB_LE_TARGETS:%=%.$(MAJ))
$(SONAME_TARGETS):%:%.$(MIN)
rm -f $@
$(LN_S) $< $@
.PHONY: $(SHLIB_INSTALL_TARGETS)
.PHONY: install-shared-libraries
SHLIB_INSTALL_TARGETS = $(SHARED_LIBS_TO_INSTALL:%=%/install)
#SHLIB_INSTALL_TARGETS is like "libfoo/install libbar/install"
install-shared-libraries: $(SHLIB_INSTALL_TARGETS)
LIBDESTDIR = $(DESTDIR)$(LIBINST_DIR)
$(SHLIB_INSTALL_TARGETS):%/install:%.$(SHLIB_SUFFIX).$(MAJ).$(MIN)
# $< is a library file name, e.g. libfoo.so.3.1 .
$(INSTALL_SHLIB) $< $(LIBDESTDIR)/$<
cd $(LIBDESTDIR); \
rm -f $(<:%.$(MIN)=%); \
$(LN_S) $< $(<:%.$(MIN)=%)
cd $(LIBDESTDIR); \
rm -f $(<:%.$(MAJ).$(MIN)=%); \
$(LN_S) $(<:%.$(MIN)=%) $(<:%.$(MAJ).$(MIN)=%)
.PHONY: uninstall-shared-libraries
uninstall-shared-libraries:
@list='$(SHARED_LIBS_TO_INSTALL)'; \
for p in $$list; do \
echo "Uninstalling $$p shared library"; \
cd $(LIBDESTDIR); \
rm -f $$p.$(SHLIB_SUFFIX); \
rm -f $$p.$(SHLIB_SUFFIX).$(MAJ); \
rm -f $$p.$(SHLIB_SUFFIX).$(MAJ).$(MIN); \
done
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.