From b542249f115761b97d21d9528d6100aaa84ea9d7 Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Thu, 15 Apr 2004 19:55:38 +0000 Subject: [PATCH] * src/ejabberd.erl: Added searching of files in code:priv_lib (thanks to Sergei Golovan) * src/translate.erl: Likewise * src/ejabberd_app.erl: Added "log_path" configuration parameter (thanks to Sergei Golovan) * src/**/Makefile.win32: Updated (thanks to Sergei Golovan) * src/**/*.c: Updated (thanks to Sergei Golovan) * src/configure.erl: Added writing of version to Makefile.inc (thanks to Sergei Golovan) * doc/guide.tex: Updated link to expat (thanks to Sergei Golovan) SVN Revision: 223 --- ChangeLog | 18 +++++++ doc/guide.tex | 2 +- src/Makefile.win32 | 91 +++++++++++++++++++++++++-------- src/configure.erl | 6 ++- src/ejabberd.erl | 7 ++- src/ejabberd_app.erl | 18 ++++--- src/eldap/Makefile.win32 | 5 +- src/expat_erl.c | 5 +- src/mod_irc/Makefile.win32 | 35 ++++++------- src/mod_irc/iconv_erl.c | 5 +- src/stringprep/Makefile.win32 | 37 ++++++-------- src/stringprep/stringprep_drv.c | 5 +- src/translate.erl | 18 ++++--- 13 files changed, 161 insertions(+), 91 deletions(-) diff --git a/ChangeLog b/ChangeLog index c712bceb8..8c021c2b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2004-04-15 Alexey Shchepin + + * src/ejabberd.erl: Added searching of files in code:priv_lib + (thanks to Sergei Golovan) + * src/translate.erl: Likewise + + * src/ejabberd_app.erl: Added "log_path" configuration parameter + (thanks to Sergei Golovan) + + * src/**/Makefile.win32: Updated (thanks to Sergei Golovan) + + * src/**/*.c: Updated (thanks to Sergei Golovan) + + * src/configure.erl: Added writing of version to Makefile.inc + (thanks to Sergei Golovan) + + * doc/guide.tex: Updated link to expat (thanks to Sergei Golovan) + 2004-04-10 Alexey Shchepin * src/idna.erl: Support for IDNA (RFC3490) diff --git a/doc/guide.tex b/doc/guide.tex index a9ba8d3cc..7f8d4e129 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -128,7 +128,7 @@ packages: \begin{itemize} \item MS Visual C++~6.0 Compiler \item \footahref{http://www.erlang.org/download/otp_win32_R9C-0.exe}{Erlang emulator version~5.3} -\item \footahref{http://prdownloads.sourceforge.net/expat/expat_win32bin_1_95_6.exe?download}{Expat~1.95.6} +\item \footahref{http://prdownloads.sourceforge.net/expat/expat_win32bin_1_95_7.exe?download}{Expat~1.95.7} \item \footahref{http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.8-1-bin.exe?download}{Iconv~1.8 binaries} and diff --git a/src/Makefile.win32 b/src/Makefile.win32 index dff7f2151..567d202f4 100644 --- a/src/Makefile.win32 +++ b/src/Makefile.win32 @@ -1,9 +1,64 @@ include Makefile.inc -EXPAT_DIR="c:\progra~1\expat-1.95.6" +EXPAT_DIR="c:\progra~1\expat-1.95.7" -ALL : expat_erl.dll compile-beam all-recursive +ALL : build + +REL=..\release +EREL=$(REL)\ejabberd-$(EJABBERD_VERSION) +EBIN_DIR=$(EREL)\ebin +MSGS_DIR=$(EREL)\msgs +SRC_DIR=$(EREL)\src +PRIV_DIR=$(EREL)\priv +SO_DIR=$(PRIV_DIR)\lib +DOC_DIR=$(EREL)\doc + +release_clean : + if exist $(REL) rd /s /q $(REL) + + +release : build release_clean + mkdir $(REL) + mkdir $(EREL) + mkdir $(EBIN_DIR) + copy *.beam $(EBIN_DIR) + copy *.app $(EBIN_DIR) + mkdir $(PRIV_DIR) + mkdir $(SO_DIR) + copy *.dll $(SO_DIR) + mkdir $(MSGS_DIR) + copy msgs\*.msg $(MSGS_DIR) + mkdir $(SRC_DIR) + copy *.app $(SRC_DIR) + copy *.erl $(SRC_DIR) + copy *.hrl $(SRC_DIR) + copy *.c $(SRC_DIR) + mkdir $(SRC_DIR)\eldap + copy eldap\eldap.* $(SRC_DIR)\eldap + copy eldap\ELDAPv3.asn $(SRC_DIR)\eldap + mkdir $(SRC_DIR)\mod_irc + copy mod_irc\*.erl $(SRC_DIR)\mod_irc + copy mod_irc\*.c $(SRC_DIR)\mod_irc + mkdir $(SRC_DIR)\mod_muc + copy mod_muc\*.erl $(SRC_DIR)\mod_muc + mkdir $(SRC_DIR)\mod_pubsub + copy mod_pubsub\*.erl $(SRC_DIR)\mod_pubsub + mkdir $(SRC_DIR)\stringprep + copy stringprep\*.erl $(SRC_DIR)\stringprep + copy stringprep\*.c $(SRC_DIR)\stringprep + copy stringprep\*.tcl $(SRC_DIR)\stringprep + mkdir $(SRC_DIR)\web + copy web\*.erl $(SRC_DIR)\web + mkdir $(DOC_DIR) + copy ..\doc\*.html $(DOC_DIR) + copy ..\doc\*.png $(DOC_DIR) + +SOURCE = expat_erl.c +OBJECT = expat_erl.o +DLL = expat_erl.dll + +build : $(DLL) compile-beam all-recursive all-recursive : cd eldap @@ -26,12 +81,10 @@ compile-beam : CLEAN : clean-recursive clean-local clean-local : - -@erase expat_erl.obj - -@erase vc60.idb - -@erase expat_erl.dll + -@erase $(OBJECT) + -@erase $(DLL) -@erase expat_erl.exp -@erase expat_erl.lib - -@erase expat_erl.pch -@erase *.beam clean-recursive : @@ -49,24 +102,18 @@ clean-recursive : nmake -nologo -f Makefile.win32 clean cd .. -CPP=cl.exe -CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(EXPAT_DIR)\source\lib" /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpexpat_erl.pch /YX /FD /c +distclean : release_clean clean + -@erase Makefile.inc -.c.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< +CC=cl.exe +CC_FLAGS=-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -MD -Ox -I"$(ERLANG_DIR)\usr\include" -I"$(EI_DIR)\include" -I"$(EXPAT_DIR)\source\lib" -LINK32=link.exe -LINK32_FLAGS=kernel32.lib "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(EXPAT_DIR)\libs\libexpat.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:expat_erl.dll /nodefaultlib:libcmt -LINK32_OBJS=expat_erl.obj +LD=link.exe +LD_FLAGS=-release -nologo -incremental:no -dll "$(EI_DIR)\lib\ei_md.lib" "$(EI_DIR)\lib\erl_interface_md.lib" "$(EXPAT_DIR)\libs\libexpat.lib" MSVCRT.LIB kernel32.lib advapi32.lib gdi32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib -expat_erl.dll : $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< +$(DLL) : $(OBJECT) + $(LD) $(LD_FLAGS) -out:$(DLL) $(OBJECT) -SOURCE=expat_erl.c - -expat_erl.obj : $(SOURCE) +$(OBJECT) : $(SOURCE) + $(CC) $(CC_FLAGS) -c -Fo$(OBJECT) $(SOURCE) diff --git a/src/configure.erl b/src/configure.erl index fecc19c6e..7bb0d278d 100644 --- a/src/configure.erl +++ b/src/configure.erl @@ -12,10 +12,14 @@ -export([start/0]). +-include("ejabberd.hrl"). + start() -> EIDirS = "EI_DIR = " ++ code:lib_dir("erl_interface") ++ "\n", RootDirS = "ERLANG_DIR = " ++ code:root_dir() ++ "\n", - file:write_file("Makefile.inc", list_to_binary(EIDirS ++ RootDirS)), + Version = "EJABBERD_VERSION = " ++ ?VERSION ++ "\n", + file:write_file("Makefile.inc", + list_to_binary(EIDirS ++ RootDirS ++ Version)), halt(). diff --git a/src/ejabberd.erl b/src/ejabberd.erl index 3a5c19c62..fd6e48e08 100644 --- a/src/ejabberd.erl +++ b/src/ejabberd.erl @@ -23,7 +23,12 @@ stop() -> get_so_path() -> case os:getenv("EJABBERD_SO_PATH") of false -> - "."; + case code:priv_dir(ejabberd) of + {error, _} -> + "."; + Path -> + filename:join([Path, "lib"]) + end; Path -> Path end. diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index 02d3d0f74..26b29f4b6 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -51,12 +51,18 @@ init() -> register(ejabberd, self()), %erlang:system_flag(fullsweep_after, 0), %error_logger:logfile({open, ?LOG_PATH}), - LogPath = case os:getenv("EJABBERD_LOG_PATH") of - false -> - ?LOG_PATH; - Path -> - Path - end, + LogPath = + case application:get_env(log_path) of + {ok, Path} -> + Path; + undefined -> + case os:getenv("EJABBERD_LOG_PATH") of + false -> + ?LOG_PATH; + Path -> + Path + end + end, error_logger:add_report_handler(ejabberd_logger_h, LogPath), %timer:apply_interval(3600000, ?MODULE, dump_ports, []), ok = erl_ddll:load_driver(ejabberd:get_so_path(), expat_erl), diff --git a/src/eldap/Makefile.win32 b/src/eldap/Makefile.win32 index bcffb01c7..6feda635c 100644 --- a/src/eldap/Makefile.win32 +++ b/src/eldap/Makefile.win32 @@ -11,7 +11,10 @@ OBJS = \ ALL : $(OBJS) CLEAN : - -@erase ELDAPv3.asn1db ELDAPv3.erl ELDAPv3.hrl + -@erase ELDAPv3.asn1db + -@erase ELDAPv3.erl + -@erase ELDAPv3.hrl + -@erase ELDAPv3.beam -@erase $(OBJS) ELDAPv3.erl : ELDAPv3.asn diff --git a/src/expat_erl.c b/src/expat_erl.c index 237295a93..2df857d8f 100644 --- a/src/expat_erl.c +++ b/src/expat_erl.c @@ -243,12 +243,9 @@ ErlDrvEntry expat_driver_entry = { NULL /* F_PTR outputv, reserved */ }; -#ifdef WIN32 -__declspec(dllexport) -#endif DRIVER_INIT(expat_erl) /* must match name in driver_entry */ { - return &expat_driver_entry; + return &expat_driver_entry; } diff --git a/src/mod_irc/Makefile.win32 b/src/mod_irc/Makefile.win32 index c87bb2869..f348be8de 100644 --- a/src/mod_irc/Makefile.win32 +++ b/src/mod_irc/Makefile.win32 @@ -11,15 +11,17 @@ OBJS = \ $(OUTDIR)\mod_irc.beam \ $(OUTDIR)\mod_irc_connection.beam -ALL : $(OUTDIR)\iconv_erl.dll $(OBJS) +SOURCE = iconv_erl.c +OBJECT = iconv_erl.o +DLL = $(OUTDIR)\iconv_erl.dll + +ALL : $(DLL) $(OBJS) CLEAN : - -@erase $(OUTDIR)\iconv_erl.dll + -@erase $(DLL) -@erase $(OUTDIR)\iconv_erl.exp -@erase $(OUTDIR)\iconv_erl.lib - -@erase iconv_erl.obj - -@erase iconv_erl.pch - -@erase vc60.idb + -@erase $(OBJECT) -@erase $(OBJS) $(OUTDIR)\iconv.beam : iconv.erl @@ -31,22 +33,15 @@ $(OUTDIR)\mod_irc.beam : mod_irc.erl $(OUTDIR)\mod_irc_connection.beam : mod_irc_connection.erl erlc -W $(EFLAGS) -o $(OUTDIR) mod_irc_connection.erl -CPP=cl.exe -CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(GNUWIN_DIR)\include" /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpiconv_erl.pch /YX /FD /c +CC=cl.exe +CC_FLAGS=-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -MD -Ox -I"$(ERLANG_DIR)\usr\include" -I"$(EI_DIR)\include" -I"$(GNUWIN_DIR)\include" -.c.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< +LD=link.exe +LD_FLAGS=-release -nologo -incremental:no -dll "$(EI_DIR)\lib\ei_md.lib" "$(EI_DIR)\lib\erl_interface_md.lib" "$(GNUWIN_DIR)\lib\libiconv.lib" MSVCRT.LIB kernel32.lib advapi32.lib gdi32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib -LINK32=link.exe -LINK32_FLAGS=kernel32.lib "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(GNUWIN_DIR)\lib\libiconv.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\iconv_erl.dll /nodefaultlib:libcmt -LINK32_OBJS=iconv_erl.obj +$(DLL) : $(OBJECT) + $(LD) $(LD_FLAGS) -out:$(DLL) $(OBJECT) -$(OUTDIR)\iconv_erl.dll : $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -iconv_erl.obj : iconv_erl.c +$(OBJECT) : $(SOURCE) + $(CC) $(CC_FLAGS) -c -Fo$(OBJECT) $(SOURCE) diff --git a/src/mod_irc/iconv_erl.c b/src/mod_irc/iconv_erl.c index 923f5cc6f..5e986c016 100644 --- a/src/mod_irc/iconv_erl.c +++ b/src/mod_irc/iconv_erl.c @@ -105,12 +105,9 @@ ErlDrvEntry iconv_driver_entry = { NULL /* F_PTR outputv, reserved */ }; -#ifdef WIN32 -__declspec(dllexport) -#endif DRIVER_INIT(iconv_erl) /* must match name in driver_entry */ { - return &iconv_driver_entry; + return &iconv_driver_entry; } diff --git a/src/stringprep/Makefile.win32 b/src/stringprep/Makefile.win32 index 4f46efda2..37e806a1a 100644 --- a/src/stringprep/Makefile.win32 +++ b/src/stringprep/Makefile.win32 @@ -4,37 +4,32 @@ include ..\Makefile.inc OUTDIR = .. EFLAGS = -I .. -pz .. -ALL : $(OUTDIR)\stringprep_drv.dll $(OUTDIR)\stringprep.beam +SOURCE = stringprep_drv.c +AUXIL = uni_data.c uni_norm.c +OBJECT = stringprep_drv.o +DLL = $(OUTDIR)\stringprep_drv.dll + +ALL : $(DLL) $(OUTDIR)\stringprep.beam CLEAN : - -@erase $(OUTDIR)\stringprep_drv.dll + -@erase $(DLL) -@erase $(OUTDIR)\stringprep_drv.exp -@erase $(OUTDIR)\stringprep_drv.lib - -@erase stringprep_drv.obj - -@erase stringprep_drv.pch - -@erase vc60.idb + -@erase $(OBJECT) -@erase $(OUTDIR)\stringprep.beam $(OUTDIR)\stringprep.beam : stringprep.erl erlc -W $(EFLAGS) -o $(OUTDIR) stringprep.erl -CPP=cl.exe -CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpstringprep_drv.pch /YX /FD /c +CC=cl.exe +CC_FLAGS=-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -MD -Ox -I"$(ERLANG_DIR)\usr\include" -I"$(EI_DIR)\include" -.c.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< +LD=link.exe +LD_FLAGS=-release -nologo -incremental:no -dll "$(EI_DIR)\lib\ei_md.lib" "$(EI_DIR)\lib\erl_interface_md.lib" MSVCRT.LIB kernel32.lib advapi32.lib gdi32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib -LINK32=link.exe -LINK32_FLAGS=kernel32.lib "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\stringprep_drv.dll /nodefaultlib:libcmt +$(DLL) : $(OBJECT) + $(LD) $(LD_FLAGS) -out:$(DLL) $(OBJECT) -LINK32_OBJS=stringprep_drv.obj - -$(OUTDIR)\stringprep_drv.dll : $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -stringprep_drv.obj : stringprep_drv.c +$(OBJECT) : $(SOURCE) $(AUXIL) + $(CC) $(CC_FLAGS) -c -Fo$(OBJECT) $(SOURCE) diff --git a/src/stringprep/stringprep_drv.c b/src/stringprep/stringprep_drv.c index 2ae83be80..0f6826d9e 100644 --- a/src/stringprep/stringprep_drv.c +++ b/src/stringprep/stringprep_drv.c @@ -325,11 +325,8 @@ ErlDrvEntry stringprep_driver_entry = { NULL /* F_PTR outputv, reserved */ }; -#ifdef WIN32 -__declspec(dllexport) -#endif DRIVER_INIT(stringprep_erl) /* must match name in driver_entry */ { - return &stringprep_driver_entry; + return &stringprep_driver_entry; } diff --git a/src/translate.erl b/src/translate.erl index 63507c8c1..2e7f87229 100644 --- a/src/translate.erl +++ b/src/translate.erl @@ -18,12 +18,18 @@ start() -> ets:new(translations, [named_table, public]), - Dir = case os:getenv("EJABBERD_MSGS_PATH") of - false -> - ?MSGS_DIR; - Path -> - Path - end, + Dir = + case os:getenv("EJABBERD_MSGS_PATH") of + false -> + case code:lib_dir(ejabberd) of + {error, _} -> + ?MSGS_DIR; + Path -> + filename:join([Path, "msgs"]) + end; + Path -> + Path + end, load_dir(Dir), ok.