SHELL := @SHELL@ # Support out-of-tree builds srcdir := @srcdir@ VPATH := @srcdir@ prefix := @prefix@ exec_prefix := @exec_prefix@ datarootdir := @datarootdir@ bindir := @bindir@ datadir := @datadir@ sysconfdir := @sysconfdir@ libdir := @libdir@ 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$(srcdir)/.. MODLINK := @MODLINK@ LDFLAGS := @LDFLAGS@ # LIBS are not and should not be used in here. # The znc binary links already against those. # LIBS := @LIBS@ PERL := @PERL_BINARY@ MODDIR := @MODDIR@ DATADIR := @DATADIR@ LIBZNC := @LIBZNC@ LIBZNCDIR:= @LIBZNCDIR@ TCL_FLAGS:= @TCL_FLAGS@ ifneq "$(LIBZNC)" "" LDFLAGS += -L.. -lznc -Wl,-rpath,$(LIBZNCDIR) endif FILES := $(notdir $(wildcard $(srcdir)/*.cpp)) # If extra is enabled ifeq "@EXTRA@" "yes" FILES += $(addprefix extra/, $(notdir $(wildcard $(srcdir)/extra/*.cpp))) endif FILES := $(basename $(FILES)) ifeq "@NOSSL@" "1" FILES := $(foreach file, $(FILES), \ $(if $(shell grep REQUIRESSL $(srcdir)/$(file).cpp), \ , \ $(basename $(file)) \ )) endif ifneq "$(PERL)" "" # We execute this now so that we see the 'beauty' of these flags in make's output modperlFLAGS := $(shell $(PERL) -MExtUtils::Embed -e perl_inc -e ldopts) # Perl API is ugly, casting string literals to char* and redeclaring functions :( modperlFLAGS += -Wno-write-strings -Wno-redundant-decls -Wno-missing-declarations PERLHOOK := modperl_install else FILES := $(shell echo $(FILES) | sed -e "s/modperl//") endif ifeq "@SASL@" "" FILES := $(shell echo $(FILES) | sed -e "s:extra/saslauth::") endif saslauthFLAGS := -lsasl2 ifeq "@CHARSET@" "" FILES := $(shell echo $(FILES) | sed -e "s:extra/charset::") endif charsetFLAGS := @LIBICONV@ ifeq "$(TCL_FLAGS)" "" FILES := $(shell echo $(FILES) | sed -e "s:extra/modtcl::") else TCLHOOK := modtcl_install endif modtclFLAGS := $(TCL_FLAGS) TARGETS := $(addsuffix .so, $(FILES)) CLEAN := *.so extra/*.so .PHONY: all clean install modperl_install all: $(TARGETS) install: all create_install_dir install_metadirs $(PERLHOOK) $(TCLHOOK) install -m 0755 $(TARGETS) $(DESTDIR)$(MODDIR) create_install_dir: mkdir -p $(DESTDIR)$(MODDIR) mkdir -p $(DESTDIR)$(DATADIR) rm -rf $(DESTDIR)$(MODDIR)/*.so install_metadirs: create_install_dir 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 clean: rm -rf $(CLEAN) %.so: %.cpp Makefile @mkdir -p .depend @mkdir -p extra $(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -o $@ $< $($(notdir $(basename $@))FLAGS) -MMD -MF .depend/$(notdir $@).dep modperl_install: create_install_dir for i in $(srcdir)/*.pm; do \ install -m 0644 $$i $(DESTDIR)$(MODDIR); \ done modtcl_install: mkdir -p $(DESTDIR)$(DATADIR)/modtcl/ install -m 0644 $(srcdir)/extra/modtcl.tcl $(srcdir)/extra/binds.tcl $(DESTDIR)$(DATADIR)/modtcl/ uninstall: # Yes, we are lazy, just remove everything in there rm -rf $(DESTDIR)$(MODDIR)/* rm -rf $(DESTDIR)$(DATADIR)/* rmdir $(DESTDIR)$(MODDIR) rmdir $(DESTDIR)$(DATADIR) -include $(wildcard .depend/*.dep)