Permalink
Browse files

Separate compilation and linking for modules.

To gain more benefits from distcc.
  • Loading branch information...
1 parent cf49449 commit f4097e6fd5d4e479a9559e79df12fdf1fd8a201a Alexey Sokolov committed Oct 29, 2011
Showing with 39 additions and 21 deletions.
  1. +9 −5 modules/Makefile.in
  2. +14 −9 modules/modperl/Makefile.inc
  3. +14 −6 modules/modpython/Makefile.inc
  4. +2 −1 modules/modtcl/Makefile.inc
View
@@ -81,16 +81,16 @@ endif
ifeq "@SASL@" ""
FILES := $(shell echo $(FILES) | sed -e "s:extra/saslauth::")
endif
-saslauthFLAGS := -lsasl2
+saslauthLDFLAGS := -lsasl2
ifeq "@CHARSET@" ""
FILES := $(shell echo $(FILES) | sed -e "s:extra/charset::")
endif
-charsetFLAGS := @LIBICONV@
+charsetLDFLAGS := @LIBICONV@
TARGETS := $(addsuffix .so, $(FILES))
-CLEAN += *.so extra/*.so
+CLEAN += *.so extra/*.so *.o extra/*.o
.PHONY: all clean install install_datadir uninstall
@@ -115,11 +115,15 @@ install_datadir:
clean:
rm -rf $(CLEAN)
-%.so: %.cpp Makefile
+%.o: %.cpp Makefile
@mkdir -p .depend
@mkdir -p extra
$(E) Building $(if $(filter %extra/,$(dir $<)),extra )module $(notdir $(basename $@))...
- $(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -o $@ $< $($(notdir $(basename $@))FLAGS) -MMD -MF .depend/$(notdir $@).dep
+ $(Q)$(CXX) $(MODFLAGS) -c -o $@ $< $($(notdir $(basename $@))CXXFLAGS) -MMD -MF .depend/$(notdir $@).dep
+
+%.so: %.o Makefile
+ $(E) Linking $(if $(filter %extra/,$(dir $<)),extra )module $(notdir $(basename $@))...
+ $(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -o $@ $< $($(notdir $(basename $@))LDFLAGS)
uninstall:
# Yes, we are lazy, just remove everything in there
@@ -2,17 +2,19 @@
ifeq "$(PERL_ON)" "yes"
# We execute this now so that we see the 'beauty' of these flags in make's output
-PERLCOMMON := $(shell $(PERL) -MExtUtils::Embed -e perl_inc -e ldopts)
+PERL_CXX := $(shell $(PERL) -MExtUtils::Embed -e perl_inc)
+PERL_LD := $(shell $(PERL) -MExtUtils::Embed -e ldopts)
# Perl API is ugly, casting string literals to char* and redeclaring functions :(
-PERLCOMMON += -Wno-write-strings -Wno-redundant-decls -Wno-missing-declarations
+PERL_CXX += -Wno-write-strings -Wno-redundant-decls -Wno-missing-declarations
# This is for SWIG
-PERLCOMMON += -DSWIG_TYPE_TABLE=znc
-modperlFLAGS := $(PERLCOMMON)
+PERL_CXX += -DSWIG_TYPE_TABLE=znc
+modperlCXXFLAGS := $(PERL_CXX)
+modperlLDFLAGS := $(PERL_LD)
# Find additional headers for out-of-tree build
-modperlFLAGS += -I.
+modperlCXXFLAGS += -I.
PERLHOOK := modperl_install
-CLEAN += modperl/ZNC.so modperl/ZNC.pm
+CLEAN += modperl/ZNC.so modperl/ZNC.pm modperl/ZNC.o
CLEAN += modperl/swigperlrun.h modperl/ZNC.cpp modperl/functions.cpp
else
@@ -23,12 +25,15 @@ endif
install: $(PERLHOOK)
-modperl.so: modperl/ZNC.so modperl/swigperlrun.h
-modperl/ZNC.so: modperl/ZNC.cpp Makefile modperl/functions.cpp
+modperl.so: modperl/ZNC.so modperl/swigperlrun.h modperl/functions.cpp
+modperl/ZNC.so: modperl/ZNC.o Makefile
+ $(E) Linking ZNC Perl bindings library...
+ $(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) $(PERL_LD) -o $@ $<
+modperl/ZNC.o: modperl/ZNC.cpp Makefile
@mkdir -p modperl
@mkdir -p .depend
$(E) Building ZNC Perl bindings library...
- $(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -I$(srcdir) -MMD -MF .depend/modperl.library.dep $(PERLCOMMON) -Wno-unused-variable -o $@ $<
+ $(Q)$(CXX) $(MODFLAGS) -I$(srcdir) -MMD -MF .depend/modperl.library.dep $(PERL_CXX) -Wno-unused-variable -o $@ $< -c
ifneq "$(SWIG)" ""
modperl/swigperlrun.h:
@mkdir -p modperl
@@ -5,11 +5,13 @@ PYTHONCOMMON := $(PY_CFLAGS)
PYTHONCOMMON += -DSWIG_TYPE_TABLE=znc
PYTHONCOMMON += -Wno-missing-field-initializers -Wno-unused -Wno-shadow
PYTHONCOMMON += -Wno-missing-declarations -Wno-uninitialized
-modpythonFLAGS := $(PYTHONCOMMON) -I. $(PY_LDFLAGS)
+modpythonCXXFLAGS := $(PYTHONCOMMON) -I.
+modpythonLDFLAGS := $(PY_LDFLAGS)
PYTHONHOOK := modpython_install
CLEAN += modpython/_znc_core.so modpython/_znc_core.cpp modpython/znc_core.py modpython/znc_core.pyc
CLEAN += modpython/swigpyrun.h modpython/znc.pyc modpython/functions.cpp modpython/compiler *.pyc
+CLEAN += modpython/_znc_core.o modpython/compiler.o
ifneq "$(srcdir)" "."
# Copied from source for out-of-tree builds
CLEAN += modpython/znc.py
@@ -35,11 +37,14 @@ modpython_all: modpython/_znc_core.so modpython/swigpyrun.h modpython/znc.pyc mo
modpython_all: $(addsuffix c, $(notdir $(wildcard $(srcdir)/*.py)))
modpython/znc_core.py: modpython/_znc_core.so
-modpython/_znc_core.so: modpython/_znc_core.cpp Makefile
+modpython/_znc_core.o: modpython/_znc_core.cpp Makefile
@mkdir -p modpython
@mkdir -p .depend
$(E) Building ZNC python bindings library...
- $(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -I$(srcdir) -MMD -MF .depend/modpython.library.dep $(PYTHONCOMMON) -o $@ $< $(PY_LDFLAGS)
+ $(Q)$(CXX) $(MODFLAGS) -I$(srcdir) -MMD -MF .depend/modpython.library.dep $(PYTHONCOMMON) -o $@ $< -c
+modpython/_znc_core.so: modpython/_znc_core.o Makefile
+ $(E) Linking ZNC python bindings library...
+ $(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -o $@ $< $(PY_LDFLAGS)
ifneq "$(SWIG)" ""
modpython/swigpyrun.h:
@mkdir -p modpython
@@ -50,14 +55,17 @@ modpython/_znc_core.cpp: modpython/modpython.i Makefile
@mkdir -p .depend
$(Q)$(SWIG) -python -py3 -c++ -shadow -outdir modpython -I$(srcdir) -MMD -MF .depend/modpython.swig.dep -w362,315,401 -o $@ $<
endif
-modpython.so: modpython/functions.cpp
+modpython.o: modpython/functions.cpp
modpython/functions.cpp: modpython/functions.in modpython/codegen.pl
@mkdir -p modpython
$(Q)$(PERL) $(srcdir)/modpython/codegen.pl $< $@
-modpython/compiler: modpython/compiler.cpp Makefile
+modpython/compiler.o: modpython/compiler.cpp Makefile
$(E) Building optimizer for python files...
- $(Q)$(CXX) $(PYTHONCOMMON) -o $@ $< $(PY_LDFLAGS)
+ $(Q)$(CXX) $(PYTHONCOMMON) -o $@ $< -c -MMD -MF .depend/modpython.compiler.dep
+modpython/compiler: modpython/compiler.o Makefile
+ $(E) Building optimizer for python files...
+ $(Q)$(CXX) -o $@ $< $(PY_LDFLAGS)
modpython_install: install_datadir modpython_all
-for i in *.pyc $(srcdir)/*.py; do \
@@ -3,7 +3,8 @@ FILES := $(shell echo $(FILES) | sed -e "s:modtcl::")
else
TCLHOOK := modtcl_install
endif
-modtclFLAGS := $(TCL_FLAGS)
+modtclCXXFLAGS := $(TCL_FLAGS)
+modtclLDFLAGS := $(TCL_FLAGS)
.PHONY: modtcl_install

0 comments on commit f4097e6

Please sign in to comment.