diff --git a/Makefile.in b/Makefile.in index ef3f77a1..83667438 100644 --- a/Makefile.in +++ b/Makefile.in @@ -13,6 +13,7 @@ LDFLAGS := @LDFLAGS@ INCLUDES := @INCLUDES@ LIBS := @LIBS@ prefix := @prefix@ +DEPEND := yes SRCS := String.cpp Csocket.cpp main.cpp znc.cpp User.cpp IRCSock.cpp Client.cpp DCCBounce.cpp \ DCCSock.cpp Chan.cpp Nick.cpp Server.cpp Modules.cpp MD5.cpp Buffer.cpp Utils.cpp \ @@ -22,17 +23,12 @@ CLEAN := znc znc-static *.o core core.* DISTCLEAN := Makefile config.log config.status znc-config .depend \ modules/.depend modules/Makefile -.PHONY: all modules clean distclean install depend +.PHONY: all modules clean distclean install all: @DEPEND@ znc @MODTARGET@ .depend: - $(CXX) -MM $(CXXFLAGS) $(SRCS) $(INCLUDES) >.depend - @if test -n "@MODTARGET@"; then \ - $(MAKE) -C modules .depend; \ - fi - -depend: .depend + @mkdir -p .depend znc: $(OBJS) $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) @@ -56,8 +52,13 @@ clean: distclean: clean rm -rf $(DISTCLEAN) +ifeq ($(DEPEND), yes) +.cpp.o: .depend + $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $< -MMD -MF .depend/$<.dep +else .cpp.o: $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $< +endif install: znc @MODTARGET@ mkdir -p $(DESTDIR)$(prefix)/bin @@ -70,4 +71,4 @@ install: znc @MODTARGET@ $(MAKE) -C modules install DESTDIR=$(DESTDIR); \ fi --include .depend +-include $(wildcard .depend/*.dep) diff --git a/modules/Makefile.in b/modules/Makefile.in index 81b40947..8441c066 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -15,6 +15,7 @@ LIBS := @LIBS@ PERL := @PERL@ MODDIR := @MODDIR@ DATADIR := @DATADIR@ +DEPEND := yes ifeq "@NOSSL@" "1" FILES := $(foreach file, $(wildcard *.cpp), \ @@ -45,14 +46,12 @@ TARGETS := $(addsuffix .so, $(FILES)) CLEAN := *.so -.PHONY: all clean install depend modperl_install +.PHONY: all clean install modperl_install all: $(TARGETS) .depend: - $(CXX) -MM $(CXXFLAGS) $(SRCS) $(INCLUDES) $(PERLCC) >.depend - -depend: .depend + @mkdir -p .depend install: all create_install_dir install_metadirs $(PERLHOOK) install -m 0755 $(TARGETS) $(DESTDIR)$(MODDIR) @@ -72,12 +71,17 @@ install_metadirs: create_install_dir clean: rm -rf $(CLEAN) +ifeq ($(DEPEND), yes) +%.so: %.cpp .depend + $(CXX) $(CXXFLAGS) $(INCLUDES) $(LDFLAGS) $($(basename $<)FLAGS) -shared -o $@ $< -MMD -MF .depend/$<.dep +else %.so: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDES) $(LDFLAGS) $($(basename $<)FLAGS) -shared -o $@ $< +endif modperl_install: create_install_dir for i in *.pm; do \ install -m 0755 $$i $(DESTDIR)$(MODDIR); \ done --include .depend +-include $(wildcard .depend/*.dep)