Permalink
Browse files

add rebar support (Tuncer Ayaz and Steve Vinoski)

Add support for building yaws with rebar. The original configure and
make support is kept intact.

If you build with rebar you get a local install. The rebar approach
does not support a regular install, which defaults into /usr/local. If
you want a regular install, use configure and make.

Create a new top-level contrib directory and move unused src files
there. Also move src/benchmarks and src/contrib contents there as
well. Remove the obsolete src/patches directory. This is all to keep
rebar from compiling this unused code (since by default it compiles
everything under the src dir).

Move a number of build rules out of Makefiles into separate scripts so
they can be used by both rebar and make.

Modify yaws version specifier and handling to be amenable to rebar.

Clean up trailing whitespace in a number of scripts and Makefiles.

Use the following environment variables to customize the rebar build
defaults:

DEFAULT_CHARSET: used in mime type table (default: "")
ERLBINDIR: e.g. /usr/local/bin
ETCDIR: etc directory (default: ./etc)
VARDIR: var directory (default: ./var)
  • Loading branch information...
1 parent d8cf062 commit bedbc05b597a9c0ed2a74c8cb763e776161ccb5a @tuncer tuncer committed with vinoski May 7, 2011
View
@@ -5,28 +5,34 @@ include ./vsn.mk
PKGCONFIG_FILES = yaws.pc
-all debug clean: cleantests
+all debug clean:
@set -e ; \
for d in $(SUBDIRS) ; do \
- if [ -f $$d/Makefile ]; then ( cd $$d && $(MAKE) $@ ) || exit 1 ; fi ; \
+ if [ -f $$d/Makefile ]; \
+ then ( cd $$d && $(MAKE) $@ ) || exit 1 ; \
+ fi ; \
done
rm -rf yaws-${YAWS_VSN}.script yaws-${YAWS_VSN}.boot
rm -rf yaws-${YAWS_VSN}.rel yaws-${YAWS_VSN}.tar.gz
cleantests:
cd test && $(MAKE) clean
-install: all
+clean: cleantests
+
+install: all
set -e ; \
for d in $(SUBDIRS) ; do \
- if [ -f $$d/Makefile ]; then ( cd $$d && $(MAKE) $@ ) || exit 1 ; fi ; \
+ if [ -f $$d/Makefile ]; \
+ then ( cd $$d && $(MAKE) $@ ) || exit 1 ; \
+ fi ; \
done
$(INSTALL) -d $(DESTDIR)$(PREFIX)/lib/pkgconfig
$(INSTALL) -m 644 $(PKGCONFIG_FILES) $(DESTDIR)$(PREFIX)/lib/pkgconfig
@echo "-------------------------------"
@echo
- @echo "** etc files went into ${ETCDIR}"
- @echo "** executables went into ${prefix}/bin"
+ @echo "** etc files went into ${ETCDIR}"
+ @echo "** executables went into ${prefix}/bin"
@echo "** library files went into ${prefix}/lib/yaws"
@echo "** var files went into ${VARDIR}"
@echo "** default docroot went into ${VARDIR}/yaws/www"
@@ -45,7 +51,7 @@ local_install: all
# Target for folks that want to build a proper OTP release
-# to be used with regular OTP release management.
+# to be used with regular OTP release management.
release: vsn.mk include.mk yaws.rel.src all
sed -e "s/%YAWS_VSN%/${YAWS_VSN}/g" \
-e "s/%ERTS_VSN%/${ERTS_VSN}/" \
@@ -70,28 +76,15 @@ touch:
find . -name '*' -print | xargs touch -m
find . -name '*.erl' -print | xargs touch -m
-
-
-
-foo:
- @echo "-------------------------------"
- @echo
- @echo "** etc files will go into ${ETCDIR}"
- @echo "** executables will go into ${prefix}/bin"
- @echo "** library file will go into ${prefix}/lib/yaws"
- @echo "** var files will go into ${VARDIR}"
- @echo
- @echo "--------------------------------"
-
-yaws.plt:
+yaws.plt:
dialyzer --build_plt -r . --output_plt yaws.plt \
-r $(ERLDIR)/lib/sasl-$(SASL_VSN) \
-r $(ERLDIR)/lib/kernel-$(KERNEL_VSN) \
-r $(ERLDIR)/lib/stdlib-$(STDLIB_VSN) \
- -r $(ERLDIR)/lib/erts-$(ERTS_VSN)
+ -r $(ERLDIR)/lib/erts-$(ERTS_VSN)
# Not debug compiled, let's just ignore it
-# -r $(ERLDIR)/lib/ssl-$(SSL_VSN)
+# -r $(ERLDIR)/lib/ssl-$(SSL_VSN)
dialyzer: yaws.plt
dialyzer --plt yaws.plt -r .
View
@@ -5,88 +5,111 @@ This is yaws, a webserver for dynamic content written in Erlang.
To build and install
-0. Get and install an erlang system (http://www.erlang.org)
+0. Get and install an Erlang system (http://www.erlang.org)
-1. If you've cloned the source from github, there is no ./configure
- script in the source, create one:
+1. If you've cloned the source from github and you want to build using
+ configure and make, note there is no ./configure script in the
+ source, so create one:
# autoconf
+1.b Install build-deps. On Ubuntu/debian this is pretty much equal to
+# apt-get build-dep yaws
-1.b Install build-deps. On Ubuntu/debian this is pretty much equal to
-# apt-get build-dep yaws
+2. You can build using rebar:
-:-)
+# rebar compile
+ or via configure and make:
+# ./configure --prefix=/usr/local
-2. ./configure --prefix=/usr/local
- This will install everything under /usr/local including var files
- in /usr/local/var/run/yaws and etc files in
- /usr/local/etc/yaws.*
+ If using rebar, you'll get a local installation with yaws in
+ $HOME/bin and the yaws configuration file in $HOME/yaws.conf. If
+ using configuration and make, the build will be configured by
+ default for installation under /usr/local including var files in
+ /usr/local/var/run/yaws and etc files in /usr/local/etc/yaws.
- A plain ./configure will install executables under
- /usr/local/bin and libs in /usr/local/lib/yaws etc and
- var files will end up under /usr/local/etc and /usr/local/var
+ NOTE: With configure, you can also change the target directory for
+ etc and var directories by using:
-
-Note: We can also change the target directory for etc and var
- directories by using:
-
- --localstatedir=DIR for files that should go in /var
- --sysconfdir=DIR for files that should go in /etc
- --disable-pam If we for some reason do not want pam support
+ --localstatedir=DIR for files that should go in /var
+ --sysconfdir=DIR for files that should go in /etc
+ --disable-pam If we for some reason do not want pam support
--with-extrainclude=DIR Will add DIR to the include path
- May be useful if e.g. pam is installed
- somewhere where its usually not found
+ May be useful if e.g. pam is installed
+ somewhere where its usually not found
--with-defaultcharset=String Will set the default charset used
in generated page headers. Usually never needed.
-
-This way you can precisely control where you install Yaws (This is
-usefull for computers where you do not have right access to the
-standard systemdirs).
-For example:
-./configure --prefix=/home/install/yaws --localstatedir=/home/install/yaws/var --sysconfdir=/home/install/etc
+ This way you can precisely control where you install Yaws (This is
+ useful for computers where you do not have right access to the
+ standard systemdirs).
+
+ For example:
+
+ ./configure --prefix=/home/install/yaws --localstatedir=/home/install/yaws/var --sysconfdir=/home/install/etc
+
+2b. Note to packagers (rpm, deb ...) All install targets support the
+ DESTDIR variable. Thus, if we do
+ ./configure --prefix=/usr; make
-2b. Note to packagers (rpm, deb ...) All install targets support the
- DESTDIR variable.
- Thus, if we do ./configure --prefix=/usr; make
we can subsequently do:
+
DESTDIR=/foo/bar make install
- All yaws files will be installed under DESTDIR, but all
- code will assume yaws should be installed under /usr
+ All yaws files will be installed under DESTDIR, but all
+ code will assume yaws should be installed under /usr.
3. make
- This will build the system
- make docs
- (Optional) You can issue this command if you want to build Yaws
- documentation.
+ This will build the system.
+
+ make docs
+
+ (Optional) You can issue this command if you want to build Yaws
+ documentation.
+
+ make local_install
- make local_install
- and perform something we call a
- local install. It will create an executable script in the $HOME/bin
- directory and a config file in $HOME/yaws.conf. This is for developers
- only
+ This will create an executable script in the $HOME/bin directory
+ and a config file in $HOME/yaws.conf. This is for developers
+ only. This is the only type of installation "rebar compile"
+ supports.
-4. To test the build, Start as bin/yaws -i
- This will start a webserver at http://0.0.0.0:8000
- Terminate through ^C or
- > init:stop()
+4. To test the build, start it as
+
+ ./bin/yaws -i
+
+ If you used rebar to compile yaws, you can alternatively start yaws
+ with
+
+ $HOME/bin/yaws -i
+
+ Either approach will start a webserver at http://0.0.0.0:8000 .
+ Terminate through ^C, or ^G followed by q, or
+
+ > init:stop()
+
+ NOTE: If you've used rebar to build the system, none of the
+ following directions apply. With rebar only local installations are
+ supported.
5. as root make install
-6. as root start as /usr/local/bin/yaws -i
- (this starts an interactive system)
+6. as root start as
+
+ /usr/local/bin/yaws -i
-7. This will create a webserver at http://${host} and one at https://${host}
+ This starts an interactive system.
-8. as root edit /usr/local/etc/yaws/yaws.conf
+7. With the default yaws.conf file, this will create a webserver at
+ http://${host} and one at https://${host}
-9. Create content in /usr/local/var/yaws
+8. as root edit /usr/local/etc/yaws/yaws.conf
+
+9. Create content in /usr/local/var/yaws/www
10a. Start as /usr/local/bin/yaws --daemon --heart
This will start a daemon (--daemon) which will be autorestarted when/if
@@ -96,7 +119,6 @@ For example:
10b. Or start interactive system as /usr/local/bin/yaws -i
-
11. Example: Here is how I compile/start the yaws system that runs
at http://yaws.hyber.org (Ubuntu server system)
@@ -33,7 +33,7 @@ INSTALL_DATA=${INSTALL} -m 644
# Hmm, don't know if you are supposed to like this better... ;-)
-APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/%VSN%/$$vsn/; s/%MODULES%/$$mods/; print; }'
+APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/\{vsn, git\}/\{vsn, $$vsn\}/; s/\{modules,\[\]\}/\{modules,\[$$mods\]\}/; print; }'
# Targets
@@ -33,7 +33,7 @@ INSTALL_DATA=${INSTALL} -m 644
# Hmm, don't know if you are supposed to like this better... ;-)
-APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/%VSN%/$$vsn/; s/%MODULES%/$$mods/; print; }'
+APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/\{vsn, git\}/\{vsn, $$vsn\}/; s/\{modules,\[\]\}/\{modules,\[$$mods\]\}/; print; }'
# Targets
@@ -33,7 +33,7 @@ INSTALL_DATA=${INSTALL} -m 644
# Hmm, don't know if you are supposed to like this better... ;-)
-APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/%VSN%/$$vsn/; s/%MODULES%/$$mods/; print; }'
+APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/\{vsn, git\}/\{vsn, $$vsn\}/; s/\{modules,\[\]\}/\{modules,\[$$mods\]\}/; print; }'
# Targets
View
@@ -26,8 +26,8 @@ CFLAGS += -I/usr/include/pam/ $(EXTRAINCLUDE)
# Targets
#
-all: $(PRIV_FILES)
-debug:
+all: $(PRIV_FILES)
+debug:
CFLAGS="$(CFLAGS) -g" $(MAKE) all
clean:
@@ -2,6 +2,8 @@
/* author: vinoski@ieee.org */
/* Created : 09 Nov 2008 by Steve Vinoski <vinoski@ieee.org> */
+#ifdef HAVE_SENDFILE
+
#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
@@ -15,8 +17,6 @@
#elif (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__)
#include <sys/socket.h>
#include <sys/uio.h>
-#else
-#error "yaws_sendfile_drv not supported on this platform"
#endif
#include "erl_driver.h"
@@ -299,3 +299,9 @@ DRIVER_INIT(yaws_sendfile_drv)
{
return &yaws_sendfile_driver_entry;
}
+
+#else
+
+#error "yaws_sendfile_drv not supported on this platform"
+
+#endif /* HAVE_SENDFILE */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -43,6 +43,9 @@ endif
CC=@CC@
CFLAGS=@CFLAGS@
+ifeq ($(HAVE_SENDFILE),true)
+CFLAGS += -DHAVE_SENDFILE
+endif
LINKER=@LINKER@
LDFLAGS=@LDFLAGS@
WIN32=@WIN32@
@@ -88,21 +91,18 @@ endif
# Hmm, don't know if you are supposed to like this better... ;-)
-APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/%VSN%/$$vsn/; s/%MODULES%/$$mods/; print; }'
+APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/\{vsn, git\}/\{vsn, $$vsn\}/; s/\{modules,\[\]\}/\{modules,\[$$mods\]\}/; print; }'
# Targets
../ebin/%.app: %.app.src ../vsn.mk Makefile
perl -e $(APPSCRIPT) "$(VSN)" $(MODULES) < $< > $@
-../ebin/%.appup: %.appup
+../ebin/%.appup: %.appup
cp $< $@
../ebin/%.$(EMULATOR): %.erl
$(ERLC) $(ERLC_FLAGS) -o ../ebin $<
%.$(EMULATOR): %.erl
$(ERLC) $(ERLC_FLAGS) $<
-
-
-
View
@@ -0,0 +1,18 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+
+{erl_opts, [{platform_define,
+ "(linux|freebsd|darwin)", 'HAVE_SENDFILE'},
+ no_debug_info]}.
+
+{port_envs, [{"CFLAGS", "$CFLAGS -g -O3 -Wall -I/usr/include/security"},
+ {"(linux|freebsd|dragonfly|solaris|darwin)",
+ "DRV_CFLAGS", "$DRV_CFLAGS -DHAVE_SENDFILE"}]}.
+
+{so_specs, [{"priv/lib/epam.so", ["c_src/epam.o"]},
+ {"priv/lib/setuid_drv.so", ["c_src/setuid_drv.o"]},
+ {"priv/lib/yaws_sendfile_drv.so",
+ ["c_src/yaws_sendfile_drv.o", "c_src/hashtable.o"]}]}.
+
+{pre_hooks, [{compile, "./scripts/rebar-pre-script"},
+ {clean, "./scripts/rebar-pre-script clean"}]}.
View
6 scripts/Install 100644 → 100755
@@ -84,9 +84,9 @@ elif [ "`uname -s`" = "FreeBSD" ]; then
sed -e "s;%prefix%;$p;g" -e "s;%etcdir%;$e;g" freebsd/yaws.sh > ${destdir}${etcdir}/rc.d/yaws.sh
elif [ "`uname -s`" = "NetBSD" ]; then
sed -e "s;%prefix%;$p;g" -e "s;%etcdir%;$e;g" netbsd/yaws.sh > /etc/rc.d/yaws
-else
- install -d ${destdir}${etcdir}
- echo "Don't know how to make /etc/init scrips for this system"
+else
+ install -d ${destdir}${etcdir}
+ echo "Don't know how to make /etc/init scripts for this system"
echo "possibly add ${prefix}/bin/yaws --daemon --heart to your /etc/rc.local manually"
fi
Oops, something went wrong.

0 comments on commit bedbc05

Please sign in to comment.