From 46079901051086425aea6530fd0348ff89377a48 Mon Sep 17 00:00:00 2001 From: Claes Wikstrom Date: Sun, 25 May 2008 20:27:50 +0000 Subject: [PATCH] cygwin support git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@1253 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52 --- scripts/Makefile | 42 +++++++++++++++++++++--------------------- scripts/Subst | 7 ++++++- scripts/yaws.template | 4 ++-- src/Makefile | 22 ++++++++++------------ src/yaws_config.erl | 13 +++++++------ 5 files changed, 46 insertions(+), 42 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index be9306f5f..873994a81 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -6,11 +6,11 @@ all debug: ../bin/yaws yaws.conf ../bin/yaws: yaws.template cat yaws.template | \ ./Subst %yawsdir% `pwd`/.. | \ - ./Subst %vardir% $(VARDIR) | \ - ./Subst %run_erl% "$(ERLBINDIR)/run_erl" | \ - ./Subst %to_erl% "$(ERLBINDIR)/to_erl" | \ - ./Subst %erl% "$(ERL)" | \ - ./Subst %werl% "$(WERL)" > ../bin/yaws + ./Subst %vardir% $(VARDIR) | \ + ./Subst %run_erl% "$(ERLBINDIR)/run_erl" | \ + ./Subst %to_erl% "$(ERLBINDIR)/to_erl" | \ + ./Subst %erl% $(ERL) | \ + ./Subst %werl% $(WERL) > ../bin/yaws chmod +x ../bin/yaws @@ -23,14 +23,14 @@ local_install: ../bin/yaws fi; \ echo "--- Installing local config file at $${target} "; \ cat yaws.conf.template | \ - ./Subst %yawsdir% `pwd`/.. | \ - ./Subst %logdir% $$HOME/yaws_logs | \ - ./Subst %host% `hostname` | \ - ./Subst %port% 8000 | \ - ./Subst %vardir% $(VARDIR) | \ - ./Subst %docroot% `pwd`/../www | \ - ./Subst %certdir% `pwd`/../ssl | \ - ./Subst %sslport% 4443 > $${target}; \ + ./Subst %yawsdir% `pwd`/.. | \ + ./Subst %logdir% $$HOME/yaws_logs | \ + ./Subst %host% `hostname` | \ + ./Subst %port% 8000 | \ + ./Subst %vardir% $(VARDIR) | \ + ./Subst %docroot% `pwd`/../www | \ + ./Subst %certdir% `pwd`/../ssl | \ + ./Subst %sslport% 4443 > $${target}; \ $(INSTALL) -d $$HOME/bin; \ rm $$HOME/bin/yaws 2> /dev/null; \ cp -f ../bin/yaws $$HOME/bin/yaws; \ @@ -40,14 +40,14 @@ local_install: ../bin/yaws yaws.conf: @echo PREFIX is $(PREFIX) cat yaws.conf.template | \ - ./Subst %yawsdir% $(PREFIX)/lib/yaws | \ - ./Subst %logdir% $(VARDIR)/log/yaws | \ - ./Subst %vardir% $(VARDIR) | \ - ./Subst %host% `hostname` | \ - ./Subst %port% 80 | \ - ./Subst %docroot% $(VARDIR)/yaws/www | \ - ./Subst %certdir% $(ETCDIR) | \ - ./Subst %sslport% 443 > yaws.conf + ./Subst %yawsdir% $(PREFIX)/lib/yaws | \ + ./Subst %logdir% $(VARDIR)/log/yaws | \ + ./Subst %vardir% $(VARDIR) | \ + ./Subst %host% `hostname` | \ + ./Subst %port% 80 | \ + ./Subst %docroot% $(VARDIR)/yaws/www | \ + ./Subst %certdir% $(ETCDIR) | \ + ./Subst %sslport% 443 > yaws.conf clean: rm -f ../bin/yaws yaws.conf diff --git a/scripts/Subst b/scripts/Subst index fc30e02c0..3416f6ccc 100755 --- a/scripts/Subst +++ b/scripts/Subst @@ -2,7 +2,12 @@ p=$1 -d=$2 + +if [ "$(uname -a | fgrep Cygwin)" != "" ]; then + d=`cygpath -m $2` +else + d=$2 +fi sed -e "s;$p;$d;g" diff --git a/scripts/yaws.template b/scripts/yaws.template index ef2d3e84f..41054a4a1 100755 --- a/scripts/yaws.template +++ b/scripts/yaws.template @@ -8,9 +8,9 @@ to_erl="%to_erl%" case `uname` in CYGWIN*) - yawsdir=`cygpath --windows $yawsdir` + yawsdir=`cygpath -m $yawsdir` werl="%werl%" - delim=\\;; + delim=/;; *) delim=/ esac diff --git a/src/Makefile b/src/Makefile index 3faac9be6..f90729a4e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -57,22 +57,20 @@ $(EBIN_FILES) : ../include/yaws.hrl ../include/yaws_api.hrl yaws_generated.erl: yaws_generated.template ../vsn.mk . ../vsn.mk; \ - sed -e "s/%VSN%/${YAWS_VSN}/" -e \ - "s;%VARDIR%;${VARDIR};g" -e \ - "s;%localinstall%;true;g" -e \ - "s;%ETCDIR%;${ETCDIR};g" \ - < yaws_generated.template > yaws_generated.erl - + cat yaws_generated.template | \ + ../scripts/Subst %VSN% ${YAWS_VSN} | \ + ../scripts/Subst %VARDIR% ${VARDIR} | \ + ../scripts/Subst %localinstall% true | \ + ../scripts/Subst %ETCDIR% ${ETCDIR} > yaws_generated.erl ## need to differentiate between local install and not regen: . ../vsn.mk; \ - sed -e "s/%VSN%/${YAWS_VSN}/" -e \ - "s;%VARDIR%;${VARDIR};g" -e \ - "s;%localinstall%;false;g" -e \ - "s;%ETCDIR%;${ETCDIR};g" \ - < yaws_generated.template > yaws_generated.erl - + cat yaws_generated.template | \ + ../scripts/Subst %VSN% ${YAWS_VSN} | \ + ../scripts/Subst %VARDIR% ${VARDIR} | \ + ../scripts/Subst %localinstall% false | \ + ../scripts/Subst %ETCDIR% ${ETCDIR} > yaws_generated.erl charset.def: if [ ! -z "$(DEFAULT_CHARSET)" ]; then \ diff --git a/src/yaws_config.erl b/src/yaws_config.erl index be26fb03e..ea32b3438 100644 --- a/src/yaws_config.erl +++ b/src/yaws_config.erl @@ -379,10 +379,10 @@ fload(FD, globals, GC, C, Cs, Lno, Chars) -> Err end; {error, Error} -> - {error, ?F("Direcory ~s is not readable: ~s", [Name, Error])} + {error, ?F("Directory ~s is not readable: ~s", [Name, Error])} end; false -> - {error, ?F("Expect directory at line ~w", [Lno])} + {error, ?F("Expect directory at line ~w (subconfdir: ~s)", [Lno, Dir])} end; ["trace", '=', Bstr] when GC#gconf.trace == false -> @@ -412,7 +412,7 @@ fload(FD, globals, GC, C, Cs, Lno, Chars) -> fload(FD, globals, GC#gconf{logdir = Dir}, C, Cs, Lno+1, Next); false -> - {error, ?F("Expect directory at line ~w", [Lno])} + {error, ?F("Expect directory at line ~w (logdir ~s)", [Lno, Dir])} end; ["ebin_dir", '=', Ebindir] -> @@ -423,7 +423,7 @@ fload(FD, globals, GC, C, Cs, Lno, Chars) -> [Dir|GC#gconf.ebin_dir]}, C, Cs, Lno+1, Next); false -> - {error, ?F("Expect directory at line ~w", [Lno])} + {error, ?F("Expect directory at line ~w (ebin_dir: ~s)", [Lno, Dir])} end; ["runmod", '=', Mod0] -> @@ -476,7 +476,7 @@ fload(FD, globals, GC, C, Cs, Lno, Chars) -> [Dir|GC#gconf.include_dir]}, C, Cs, Lno+1, Next); false -> - {error, ?F("Expect directory at line ~w", [Lno])} + {error, ?F("Expect directory at line ~w (include_dir: ~s)", [Lno, Dir])} end; ["mnesia_dir", '=', Mnesiadir] -> @@ -728,7 +728,8 @@ fload(FD, server, GC, C, Cs, Lno, Chars) -> xtra_docroots = tl(RootDirs)}, fload(FD, server, GC, C2, Cs, Lno+1, Next); _ -> - {error, ?F("Expect directory at line ~w", [Lno])} + {error, ?F("Expect directory at line ~w (docroot: ~s)", + [Lno, hd(RootDirs)])} end; ["partial_post_size",'=',Size] ->