]>
Commit | Line | Data |
---|---|---|
b2e465d6 AL |
1 | # -*- make -*- |
2 | ||
3 | # This creates a python shared module. | |
4 | ||
5 | # Input | |
6 | # $(SOURCE) - The source code to use | |
7 | # $(MODULE) - The name of the module without module or .so | |
8 | ||
9 | # All output is writtin to .opic files in the build directory to | |
10 | # signify the PIC output. | |
11 | ||
12 | # See defaults.mak for information about LOCAL | |
13 | ||
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) | |
20 | ||
21 | # Install the command hooks | |
22 | library: $(LIB)/$(MODULE)module.so | |
23 | clean: clean/$(LOCAL) | |
24 | veryclean: veryclean/$(LOCAL) | |
25 | ||
26 | # Make Directories | |
27 | MKDIRS += $(OBJ) $(DEP) $(LIB) | |
28 | ||
29 | # The clean rules | |
30 | .PHONY: clean/$(LOCAL) veryclean/$(LOCAL) | |
31 | clean/$(LOCAL): | |
32 | -rm -f $($(@F)-OBJS) $($(@F)-DEP) | |
33 | veryclean/$(LOCAL): clean/$(LOCAL) | |
34 | -rm -f $($(@F)-HEADERS) $(LIB)/$($(@F)-MODULE)module.so* | |
35 | ||
36 | # The binary build rule. | |
37 | ifdef PYTHONLIB | |
38 | ifndef ONLYSTATICLIBS | |
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)\ | |
43 | -o $@ -shared \ | |
44 | $(filter %.opic,$^) \ | |
45 | $($(@F)-SLIBS) $(PYTHONLIB) | |
46 | else | |
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 | |
51 | else | |
52 | .PHONY: $(LIB)/$(MODULE)module.so | |
53 | $(LIB)/$(MODULE)module.so: | |
54 | echo No python support, not building $@ | |
55 | endif # ifdef PYTHONLIB | |
56 | ||
57 | # Compilation rules | |
58 | vpath %.cc $(SUBDIRS) | |
59 | $(OBJ)/%.opic: %.cc | |
60 | echo Compiling $< to $@ | |
cbc9ec23 | 61 | $(CXX) -c $(INLINEDEPFLAG) $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) -o $@ $(abspath $<) |
b2e465d6 AL |
62 | $(DoDep) |
63 | ||
64 | # Include the dependencies that are available | |
65 | The_DFiles = $(wildcard $($(LOCAL)-DEP)) | |
66 | ifneq ($(words $(The_DFiles)),0) | |
67 | include $(The_DFiles) | |
68 | endif |