The following example shows how you can create a makefile for the shared library shown in Example: creating a sample shared library.
The makefile assumes that the export file bg.exp defines the symbols that the shared library exports.
#
#
all: m_abg libbg.a m_alpha
# Create m_abg containing alpha, beta, and gamma
m_abg: alpha.cbl beta.cbl gamma.cbl
cob2 -o m_abg alpha.cbl beta.cbl gamma.cbl
# Create libbg.a containing beta and gamma
# sh_bg.o is a shared object that exports the symbols defined in bg.exp
# libbg.a is a shared library that contains one shared object that
# contains both beta and gamma
# More objects can be added to the library
libbg.a: beta.cbl gamma.cbl bg.exp
rm -f libbg.a
cob2 -o sh_bg beta.cbl gamma.cbl -bE:bg.exp -bM:SRE -bnoentry
ar -rv libbg.a sh_bg
rm -f sh_bg
# Create m_alpha containing alpha and using library libbg.a
m_alpha: alpha.cbl
cob2 -o m_alpha alpha.cbl -L. libbg.a
clean:
rm -f m_abg m_alpha sh_bg libbg.a *.lst
Executing either the command m_abg or the command m_alpha provides the same output.