diff --git a/Makefile.in b/Makefile.in index e8e5e381..198ab1e8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,3 +1,7 @@ +# Support out-of-tree builds +srcdir := @srcdir@ +VPATH := @srcdir@ + prefix := @prefix@ exec_prefix := @exec_prefix@ datarootdir := @datarootdir@ @@ -49,7 +53,7 @@ distclean: clean %.o: %.cpp Makefile @mkdir -p .depend - $(CXX) $(CXXFLAGS) -c -o $@ $< -MMD -MF .depend/$<.dep + $(CXX) $(CXXFLAGS) -c -o $@ $< -MMD -MF .depend/$@.dep install: znc mkdir -p $(DESTDIR)$(bindir) @@ -57,7 +61,7 @@ install: znc install -m 0755 znc $(DESTDIR)$(bindir) install -m 0755 znc-config $(DESTDIR)$(bindir) install -m 0755 znc-buildmod $(DESTDIR)$(bindir) - install -m 0644 *.h $(DESTDIR)$(prefix)/include/znc + install -m 0644 $(srcdir)/*.h $(DESTDIR)$(prefix)/include/znc @if test -n "@MODTARGET@"; then \ $(MAKE) -C modules install DESTDIR=$(DESTDIR); \ fi diff --git a/man/Makefile.in b/man/Makefile.in index 29fb137c..5d95595c 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -1,3 +1,6 @@ +# Support out-of-tree builds +VPATH := @srcdir@ + prefix := @prefix@ exec_prefix := @exec_prefix@ datarootdir := @datarootdir@ diff --git a/modules/Makefile.in b/modules/Makefile.in index d15b0207..597a26d1 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -1,3 +1,7 @@ +# Support out-of-tree builds +srcdir := @srcdir@ +VPATH := @srcdir@ + prefix := @prefix@ exec_prefix := @exec_prefix@ datarootdir := @datarootdir@ @@ -9,7 +13,7 @@ sbindir := @sbindir@ localstatedir := @localstatedir@ CXX := @CXX@ # CXXFLAGS are for the main binary, so don't use them here, use MODFLAGS instead -MODFLAGS := @CPPFLAGS@ @MODFLAGS@ -I.. +MODFLAGS := @CPPFLAGS@ @MODFLAGS@ -I$(srcdir)/.. LDFLAGS := @LDFLAGS@ # LIBS are not and should not be used in here. # The znc binary links already against those. @@ -18,14 +22,16 @@ PERL := @PERL@ MODDIR := @MODDIR@ DATADIR := @DATADIR@ +FILES := $(basename $(wildcard $(srcdir)/*.cpp)) +# Strip away the srcdir, we want them to be created in the current dir +FILES := $(shell echo $(FILES) | sed -e "s:$(srcdir)/::g") + ifeq "@NOSSL@" "1" -FILES := $(foreach file, $(wildcard *.cpp), \ - $(if $(shell grep REQUIRESSL $(file)), \ +FILES := $(foreach file, $(FILES), \ + $(if $(shell grep REQUIRESSL $(srcdir)/$(file).cpp), \ , \ $(basename $(file)) \ )) -else -FILES := $(basename $(wildcard *.cpp)) endif ifneq "$(PERL)" "" @@ -57,8 +63,9 @@ create_install_dir: rm -rf $(DESTDIR)$(MODDIR)/*.so install_metadirs: create_install_dir - for a in *; do \ - if [ -d $$a ] && [ -f $${a}.so ]; then \ + for a in $(srcdir)/*; do \ + d=$$(echo $$a | sed -e "s:$(srcdir)/::g"); \ + if [ -d $$a ] && [ -f $${d}.so ]; then \ cp -Rp $$a $(DESTDIR)$(DATADIR); \ fi \ done @@ -68,10 +75,10 @@ clean: %.so: %.cpp Makefile @mkdir -p .depend - $(CXX) $(MODFLAGS) $(LDFLAGS) -shared -o $@ $< $($(basename $<)FLAGS) -MMD -MF .depend/$<.dep + $(CXX) $(MODFLAGS) $(LDFLAGS) -shared -o $@ $< $($(basename $@)FLAGS) -MMD -MF .depend/$@.dep modperl_install: create_install_dir - for i in *.pm; do \ + for i in $(srcdir)/*.pm; do \ install -m 0644 $$i $(DESTDIR)$(MODDIR); \ done