3 # This creates a python shared module.
6 # $(SOURCE) - The source code to use
7 # $(MODULE) - The name of the module without module or .so
9 # All output is writtin to .opic files in the build directory to
10 # signify the PIC output.
12 # See defaults.mak for information about LOCAL
14 # Some local definitions
15 LOCAL := $(MODULE)module.so
16 $(LOCAL)-OBJS := $(addprefix $(OBJ)/,$(addsuffix .opic,$(notdir $(basename $(SOURCE)))))
17 $(LOCAL)-DEP := $(addprefix $(DEP)/,$(addsuffix .opic.d,$(notdir $(basename $(SOURCE)))))
18 $(LOCAL)-SLIBS := $(SLIBS)
19 $(LOCAL)-MODULE := $(MODULE)
21 # Install the command hooks
22 library: $(LIB)/$(MODULE)module.so
24 veryclean: veryclean/$(LOCAL)
27 MKDIRS += $(OBJ) $(DEP) $(LIB)
30 .PHONY: clean/$(LOCAL) veryclean/$(LOCAL)
32 -rm -f $($(@F)-OBJS) $($(@F)-DEP)
33 veryclean/$(LOCAL): clean/$(LOCAL)
34 -rm -f $($(@F)-HEADERS) $(LIB)/$($(@F)-MODULE)module.so*
36 # The binary build rule.
39 $(LIB)/$(MODULE)module.so: $($(LOCAL)-OBJS)
40 -rm -f $(LIB)/$($(@F)-MODULE)module.so* 2> /dev/null
41 echo Building shared Python module $@
42 $(CXX) $(CXXFLAGS) $(LDFLAGS) $(PICFLAGS) $(LFLAGS) $(LFLAGS_SO)\
45 $($(@F)-SLIBS) $(PYTHONLIB)
47 .PHONY: $(LIB)/$(MODULE)module.so
48 $(LIB)/$(MODULE)module.so:
49 echo Don't know how to make a python module here, not building $@
50 endif # ifndef ONLYSTATICLIBS
52 .PHONY: $(LIB)/$(MODULE)module.so
53 $(LIB)/$(MODULE)module.so:
54 echo No python support, not building $@
55 endif # ifdef PYTHONLIB
60 echo Compiling $< to $@
61 $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) -o $@ $(abspath $<)
64 # Include the dependencies that are available
65 The_DFiles = $(wildcard $($(LOCAL)-DEP))
66 ifneq ($(words $(The_DFiles)),0)