3 # This creates a shared library.
6 # $(SOURCE) - The source code to use
7 # $(HEADERS) - Exported header files and private header files
8 # $(LIBRARY) - The name of the library without lib or .so
9 # $(MAJOR) - The major version number of this library
10 # $(MINOR) - The minor version number of this library
12 # All output is writtin to .opic files in the build directory to
13 # signify the PIC output.
15 # See defaults.mak for information about LOCAL
17 # Some local definitions
18 LOCAL
:= lib
$(LIBRARY
).so.
$(MAJOR
).
$(MINOR
)
19 $(LOCAL
)-OBJS
:= $(addprefix $(OBJ
)/,$(addsuffix .opic
,$(notdir $(basename $(SOURCE
)))))
20 $(LOCAL
)-DEP
:= $(addprefix $(DEP
)/,$(addsuffix .opic.d
,$(notdir $(basename $(SOURCE
)))))
21 $(LOCAL
)-HEADERS
:= $(addprefix $(INCLUDE
)/,$(HEADERS
))
22 $(LOCAL
)-SONAME
:= lib
$(LIBRARY
).so.
$(MAJOR
)
23 $(LOCAL
)-SLIBS
:= $(SLIBS
)
24 $(LOCAL
)-LIBRARY
:= $(LIBRARY
)
26 # Install the command hooks
27 headers
: $($(LOCAL
)-HEADERS
)
28 library
: $(LIB
)/lib
$(LIBRARY
).so
$(LIB
)/lib
$(LIBRARY
).so.
$(MAJOR
)
30 veryclean
: veryclean
/$(LOCAL
)
33 MKDIRS
+= $(OBJ
) $(DEP
) $(LIB
) $(dir $($(LOCAL
)-HEADERS
))
36 .PHONY
: clean/$(LOCAL
) veryclean
/$(LOCAL
)
38 -rm -f
$($(@F
)-OBJS
) $($(@F
)-DEP
)
39 veryclean
/$(LOCAL
): clean/$(LOCAL
)
40 -rm -f
$($(@F
)-HEADERS
) $(LIB
)/lib
$($(@F
)-LIBRARY
).so
*
42 # Build rules for the two symlinks
43 .PHONY
: $(LIB
)/lib
$(LIBRARY
).so.
$(MAJOR
) $(LIB
)/lib
$(LIBRARY
).so
44 $(LIB
)/lib
$(LIBRARY
).so.
$(MAJOR
): $(LIB
)/lib
$(LIBRARY
).so.
$(MAJOR
).
$(MINOR
)
46 $(LIB
)/lib
$(LIBRARY
).so
: $(LIB
)/lib
$(LIBRARY
).so.
$(MAJOR
).
$(MINOR
)
49 # The binary build rule
50 $(LIB
)/lib
$(LIBRARY
).so.
$(MAJOR
).
$(MINOR
): $($(LOCAL
)-HEADERS
) $($(LOCAL
)-OBJS
)
51 -rm -f
$(LIB
)/lib
$($(@F
)-LIBRARY
).so
* 2> /dev
/null
52 echo Building shared library
$@
53 $(CXX
) $(CXXFLAGS
) $(LDFLAGS
) $(PICFLAGS
) $(LFLAGS
) $(LFLAGS_SO
)\
54 -o
$@
$(SONAME_MAGIC
)$($(@F
)-SONAME
) -shared \
61 echo Compiling
$< to
$@
62 $(CXX
) -c
$(INLINEDEPFLAG
) $(CPPFLAGS
) $(CXXFLAGS
) $(PICFLAGS
) -o
$@
$<
65 # Include the dependencies that are available
66 The_DFiles
= $(wildcard $($(LOCAL
)-DEP
))
67 ifneq ($(words $(The_DFiles
)),0)