Support out-of-tree builds

The autoconf documentation turned out to be helpful:
http://www.gnu.org/software/autoconf/manual/autoconf.html#Build-Directories


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1257 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-10-21 17:41:52 +00:00
parent ce31b29b68
commit ecd50392ab
3 changed files with 25 additions and 11 deletions
+6 -2
View File
@@ -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
+3
View File
@@ -1,3 +1,6 @@
# Support out-of-tree builds
VPATH := @srcdir@
prefix := @prefix@
exec_prefix := @exec_prefix@
datarootdir := @datarootdir@
+16 -9
View File
@@ -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