]> granicus.if.org Git - ejabberd/commitdiff
Use OTP directory structure for 'make install'
authorPaweł Chmielowski <pchmielowski@process-one.net>
Thu, 15 Oct 2015 13:08:45 +0000 (15:08 +0200)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Thu, 15 Oct 2015 13:08:45 +0000 (15:08 +0200)
Makefile.in
ejabberdctl.template

index f7b30d4689e7ce369f1c314337c44d948becad8b..c5f2b2d0f9ff3f2fa4d00707e1a8c4c49dcd7184 100644 (file)
@@ -109,9 +109,33 @@ spec:
        $(ERL) -noinput +B -pa ebin -pa deps/*/ebin -eval \
        'case xml_gen:compile("tools/xmpp_codec.spec") of ok -> halt(0); _ -> halt(1) end.'
 
-DLLs := $(wildcard deps/*/priv/*.so) $(wildcard deps/*/priv/lib/*.so)
+TO_DEST=$(foreach path,$(1),$(if $(filter deps/%,$(path)),$(patsubst deps/%,$(DESTDIR)/lib/%,$(path)),$(patsubst %,$(DESTDIR)/lib/ejabberd/%,$(path))))
+FILTER_DIRS=$(foreach path,$(1),$(if $(wildcard $(path)/*),,$(path)))
+FILES_WILDCARD=$(call FILTER_DIRS,$(foreach w,$(1),$(wildcard $(w))))
 
-install: all
+DEPS_FILES:=$(call FILES_WILDCARD,deps/*/ebin/*.beam deps/*/ebin/*.app deps/*/priv/* deps/*/priv/lib/* deps/*/priv/bin/* deps/*/include/*.hrl)
+DEPS_FILES_FILTERED:=$(filter-out %/epam,$(DEPS_FILES))
+DEPS_DIRS:=$(sort deps/ $(wildcard deps/*) $(dir $(DEPS_FILES)))
+
+MAIN_FILES:=$(filter-out %/configure.beam,$(call FILES_WILDCARD,ebin/*.beam ebin/*.app priv/msgs/*.msg priv/lib/* include/*.hrl))
+MAIN_DIRS:=$(sort $(dir $(MAIN_FILES)))
+
+define COPY_template =
+$(call TO_DEST,$(1)): $(1) $(call TO_DEST,$(dir $(1)))
+       $(INSTALL) -m 644 $(1) $(call TO_DEST,$(1))
+endef
+
+$(foreach file,$(DEPS_FILES_FILTERED) $(MAIN_FILES),$(eval $(call COPY_template,$(file))))
+
+$(call TO_DEST,$(MAIN_DIRS) $(DEPS_DIRS)):
+       $(INSTALL) -d $@
+
+$(call TO_DEST,deps/p1_pam/priv/bin/epam): $(DESTDIR)/lib/%: deps/% $(call TO_DEST,deps/p1_pam/priv/bin/)
+       $(INSTALL) -m 750 $(O_USER) $< $@
+
+copy-files: $(call TO_DEST,$(DEPS_FILES) $(MAIN_FILES))
+
+install: all copy-files
        #
        # Configuration files
        $(INSTALL) -d -m 750 $(G_USER) $(ETCDIR)
@@ -146,41 +170,16 @@ install: all
                -e "s*@installuser@*$(INIT_USER)*" ejabberd.init.template \
                > ejabberd.init
        chmod 755 ejabberd.init
-       #
-       # Binary Erlang files
-       $(INSTALL) -d $(BEAMDIR)
-       $(INSTALL) -m 644 ebin/*.app $(BEAMDIR)
-       $(INSTALL) -m 644 ebin/*.beam $(BEAMDIR)
-       $(INSTALL) -m 644 deps/*/ebin/*.app $(BEAMDIR)
-       $(INSTALL) -m 644 deps/*/ebin/*.beam $(BEAMDIR)
        # Install Elixir and Elixir dependancies
        -$(INSTALL) -m 644 deps/*/lib/*/ebin/*.app $(BEAMDIR)
        -$(INSTALL) -m 644 deps/*/lib/*/ebin/*.beam $(BEAMDIR)
        rm -f $(BEAMDIR)/configure.beam
        #
-       # ejabberd header files
-       $(INSTALL) -d $(INCLUDEDIR)
-       $(INSTALL) -m 644 include/*.hrl $(INCLUDEDIR)
-       $(INSTALL) -m 644 deps/*/include/*.hrl $(INCLUDEDIR)
-       #
        # Binary C programs
        $(INSTALL) -d $(PBINDIR)
        $(INSTALL) -m 750 $(O_USER) tools/captcha.sh $(PBINDIR)
        $(INSTALL) -m 750 $(O_USER) tools/joincluster $(PBINDIR)
        $(INSTALL) -m 750 $(O_USER) tools/leavecluster $(PBINDIR)
-       [ -f deps/p1_pam/priv/bin/epam ] \
-               && $(INSTALL) -m 750 $(O_USER) deps/p1_pam/priv/bin/epam $(PBINDIR) \
-               || true
-       #
-       # Binary system libraries
-       $(INSTALL) -d $(SODIR)
-       $(INSTALL) -m 644 $(DLLs) $(SODIR)
-       [ -f $(SODIR)/jiffy.so ] && (cd $(PRIVDIR); ln -s lib/jiffy.so; true) || true
-       [ -f $(SODIR)/sqlite3_drv.so ] && (cd $(PRIVDIR); ln -s lib/sqlite3_drv.so; true) || true
-       #
-       # Translated strings
-       $(INSTALL) -d $(MSGSDIR)
-       $(INSTALL) -m 644 priv/msgs/*.msg $(MSGSDIR)
        #
        # Copy lite.sql
        [ -d deps/sqlite3 ] && $(INSTALL) -d $(SQLDIR) || true
index ea29fa2891066a7bd0ef043939b8aed128e45365..f90f71e5345313c8b7d5c5accd7730bf9d643114 100755 (executable)
@@ -15,6 +15,7 @@ ERL={{erl}}
 IEX={{bindir}}/iex
 EPMD={{bindir}}/epmd
 INSTALLUSER={{installuser}}
+ERL_LIBS={{libdir}}
 
 # check the proper system user is used if defined
 if [ "$INSTALLUSER" != "" ] ; then
@@ -87,21 +88,12 @@ if [ "{{release}}" != "true" ] ; then
     if [ "$EJABBERDDIR" = "" ] ; then
         EJABBERDDIR={{libdir}}/ejabberd
     fi
-    if [ "$EJABBERD_EBIN_PATH" = "" ] ; then
-        EJABBERD_EBIN_PATH=$EJABBERDDIR/ebin
-    fi
     if [ "$EJABBERD_PRIV_PATH" = "" ] ; then
         EJABBERD_PRIV_PATH=$EJABBERDDIR/priv
     fi
     if [ "$EJABBERD_BIN_PATH" = "" ] ; then
         EJABBERD_BIN_PATH=$EJABBERD_PRIV_PATH/bin
     fi
-    if [ "$EJABBERD_SO_PATH" = "" ] ; then
-        EJABBERD_SO_PATH=$EJABBERD_PRIV_PATH/lib
-    fi
-    if [ "$EJABBERD_MSGS_PATH" = "" ] ; then
-        EJABBERD_MSGS_PATH=$EJABBERD_PRIV_PATH/msgs
-    fi
 fi
 EJABBERD_LOG_PATH=$LOGS_DIR/ejabberd.log
 DATETIME=`date "+%Y%m%d-%H%M%S"`
@@ -154,9 +146,7 @@ cd $SPOOL_DIR
 
 # export global variables
 export EJABBERD_CONFIG_PATH
-export EJABBERD_MSGS_PATH
 export EJABBERD_LOG_PATH
-export EJABBERD_SO_PATH
 export EJABBERD_BIN_PATH
 export EJABBERD_DOC_PATH
 export EJABBERD_PID_PATH
@@ -166,6 +156,7 @@ export ERL_INETRC
 export ERL_MAX_PORTS
 export ERL_MAX_ETS_TABLES
 export CONTRIB_MODULES_PATH
+export ERL_LIBS
 
 # start server
 start()