From 07661f0d55dc4700722ee3f66218e86d0f77a55c Mon Sep 17 00:00:00 2001 From: nsensfel Date: Tue, 10 Apr 2018 16:09:55 +0200 Subject: ... --- Makefile | 9 ++- conf/yaws.conf | 115 --------------------------------------- conf/yaws.conf.m4 | 115 +++++++++++++++++++++++++++++++++++++++ src/battlemap/Makefile | 3 +- src/battlemap/mk/preprocessor.mk | 18 +++++- src/battlemap/module.conf | 9 +++ 6 files changed, 149 insertions(+), 120 deletions(-) delete mode 100644 conf/yaws.conf create mode 100644 conf/yaws.conf.m4 diff --git a/Makefile b/Makefile index d9ae18f..f7f311c 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,14 @@ ## CONFIG ###################################################################### ################################################################################ MODULES ?= battlemap +MODULES_DIR ?= ${CURDIR}/src -SRC_DIR ?= ${CURDIR}/src - +YAWS_CONFIG_TEMPLATE ?= ${CURDIR}/conf/yaws.conf.m4 +YAWS_API_HEADER ?= /my/src/yaws/include/yaws_api.hrl ################################################################################ ## MAKEFILE MAGIC ############################################################## ################################################################################ -MODULES_SRC = $(addprefix $(SRC_DIR)/,$(MODULES)) +MODULES_SRC = $(addprefix $(MODULES_DIR)/,$(MODULES)) ################################################################################ ## SANITY CHECKS ############################################################### @@ -23,6 +24,8 @@ endif ################################################################################ ## TARGET RULES ################################################################ ################################################################################ +export + all: for module in $(MODULES_SRC) ; do \ $(MAKE) -C $$module all; \ diff --git a/conf/yaws.conf b/conf/yaws.conf deleted file mode 100644 index 6127741..0000000 --- a/conf/yaws.conf +++ /dev/null @@ -1,115 +0,0 @@ -# conf for yaws - -# First we have a set of globals that apply to all virtual servers - -# This is the directory where all logfiles for -# all virtual servers will be written. -logdir = /my/src/yaws/_inst/var/log/yaws - -# These are the paths to directories where additional -# beam code can be placed. The daemon will add these -# directories to its search path. -ebin_dir = /my/src/tacticians-server/ebin - -# This is a directory where application specific .hrl -# files can be placed. Application-specific .yaws code can -# then include these .hrl files. -include_dir = /my/src/yaws/_inst/lib/yaws/examples/include - -# Set this to an integer value to control -# max number of connections from clients into the server. -max_connections = nolimit - -# Normally, yaws does not restrict the number of times a connection is -# kept alive using keepalive. Setting this parameter to an integer X -# will ensure that connections are closed once they have been used X times. -# This can be a useful to guard against long running connections -# collecting too much garbage in the Erlang VM. -keepalive_maxuses = nolimit - -# Override the garbage collection option parameters for processes -# that handle new connections. Useful for systems expecting long-lived -# connections that handle a lot of data. The default value is Erlang's -# default. Valid options are {fullsweep_after, X} and/or {min_heap_size, Y} where -# X and Y are integers. See Erlang's erlang:spawn_opt/4 function for more -# details. The value type is a quoted string containing an Erlang proplist or -# the atom undefined. -process_options = "[]" - -# Set the size of the cached acceptor process pool. The value must be an -# integer greater than or equal to 0. The default pool size is 8. Setting -# the pool size to 0 effectively disables the pool. -#acceptor_pool_size = 8 - -# This is a debug variable, possible values are http | traffic | false -# It is also possible to set the trace (possibly to the tty) while -# invoking yaws from the shell as in -# yaws -i -T -x (see man yaws). -trace = false - -# It is possible to have yaws start additional application-specific code at -# startup. Set runmod to the name of the module you want yaws to start. It -# assumes the module has an exported function start/0. To have multiple -# runmods just add more "runmod = xyz" lines. -# -# runmod = mymodule - -# By default yaws will copy the erlang error_log and -# append it to a wrap log called report.log (in the logdir). -# This feature can be turned off. This would typically -# be the case when yaws runs within another larger app. -copy_error_log = true - -# Logs are wrap logs -log_wrap_size = 1000000 - -# Possibly resolve all hostnames in logfiles so webalizer -# can produce the nice geography piechart -log_resolve_hostname = false - -# Fail completely or not if yaws fails to bind a listen socket. -fail_on_bind_err = true - -# If HTTP auth is used, it is possible to have a specific -# auth log. As of release 1.90 the global auth_log is -# deprecated and ignored. Now, this variable must be set in -# server part -#auth_log = true - -# When we're running multiple yaws systems on the same -# host, we need to give each yaws system an individual -# name. Yaws will write a number of runtime files under -# ${HOME}/.yaws/yaws/${id} -# The default value is "default" -# If we're not planning to run multiple webservers on the -# same host it's much better to leave this value unset since -# then all the ctl function (--stop et.el) work without having -# to supply the id. -# -# id = myname - -# Earlier versions of Yaws picked the first virtual host -# in a list of hosts with the same IP/PORT when the Host: -# header doesn't match any name on any Host. -# This is often nice in testing environments but not -# acceptable in real-world hosting scenarios; -# think http://porn.bigcompany.com -pick_first_virthost_on_nomatch = true - -# If the HTTP client session is to be kept alive, wait this many -# milliseconds for a new request before timing out the connection. Note -# that infinity is a valid value but it's not recommended. -keepalive_timeout = 30000 - -# Now, a set of virtual servers. -# The examples below first show two virthosted servers on the same IP (0.0.0.0) -# in this case, but an explicit IP can be given as well. - - - port = 8000 - listen = 0.0.0.0 - docroot = /my/src/tacticians-server/www/ - auth_log = true - appmods = character_turn load_state - start_mod = handler - diff --git a/conf/yaws.conf.m4 b/conf/yaws.conf.m4 new file mode 100644 index 0000000..8a68f0b --- /dev/null +++ b/conf/yaws.conf.m4 @@ -0,0 +1,115 @@ +# conf for yaws + +# First we have a set of globals that apply to all virtual servers + +# This is the directory where all logfiles for +# all virtual servers will be written. +logdir = __MODULE_LOG_DIR + +# These are the paths to directories where additional +# beam code can be placed. The daemon will add these +# directories to its search path. +ebin_dir = __MODULE_BIN_DIR + +# This is a directory where application specific .hrl +# files can be placed. Application-specific .yaws code can +# then include these .hrl files. +include_dir = __MODULE_INCLUDE_DIR + +# Set this to an integer value to control +# max number of connections from clients into the server. +max_connections = nolimit + +# Normally, yaws does not restrict the number of times a connection is +# kept alive using keepalive. Setting this parameter to an integer X +# will ensure that connections are closed once they have been used X times. +# This can be a useful to guard against long running connections +# collecting too much garbage in the Erlang VM. +keepalive_maxuses = nolimit + +# Override the garbage collection option parameters for processes +# that handle new connections. Useful for systems expecting long-lived +# connections that handle a lot of data. The default value is Erlang's +# default. Valid options are {fullsweep_after, X} and/or {min_heap_size, Y} where +# X and Y are integers. See Erlang's erlang:spawn_opt/4 function for more +# details. The value type is a quoted string containing an Erlang proplist or +# the atom undefined. +process_options = "[]" + +# Set the size of the cached acceptor process pool. The value must be an +# integer greater than or equal to 0. The default pool size is 8. Setting +# the pool size to 0 effectively disables the pool. +#acceptor_pool_size = 8 + +# This is a debug variable, possible values are http | traffic | false +# It is also possible to set the trace (possibly to the tty) while +# invoking yaws from the shell as in +# yaws -i -T -x (see man yaws). +trace = false + +# It is possible to have yaws start additional application-specific code at +# startup. Set runmod to the name of the module you want yaws to start. It +# assumes the module has an exported function start/0. To have multiple +# runmods just add more "runmod = xyz" lines. +# +# runmod = mymodule + +# By default yaws will copy the erlang error_log and +# append it to a wrap log called report.log (in the logdir). +# This feature can be turned off. This would typically +# be the case when yaws runs within another larger app. +copy_error_log = true + +# Logs are wrap logs +log_wrap_size = 1000000 + +# Possibly resolve all hostnames in logfiles so webalizer +# can produce the nice geography piechart +log_resolve_hostname = false + +# Fail completely or not if yaws fails to bind a listen socket. +fail_on_bind_err = true + +# If HTTP auth is used, it is possible to have a specific +# auth log. As of release 1.90 the global auth_log is +# deprecated and ignored. Now, this variable must be set in +# server part +#auth_log = true + +# When we're running multiple yaws systems on the same +# host, we need to give each yaws system an individual +# name. Yaws will write a number of runtime files under +# ${HOME}/.yaws/yaws/${id} +# The default value is "default" +# If we're not planning to run multiple webservers on the +# same host it's much better to leave this value unset since +# then all the ctl function (--stop et.el) work without having +# to supply the id. +# +# id = myname + +# Earlier versions of Yaws picked the first virtual host +# in a list of hosts with the same IP/PORT when the Host: +# header doesn't match any name on any Host. +# This is often nice in testing environments but not +# acceptable in real-world hosting scenarios; +# think http://porn.bigcompany.com +pick_first_virthost_on_nomatch = true + +# If the HTTP client session is to be kept alive, wait this many +# milliseconds for a new request before timing out the connection. Note +# that infinity is a valid value but it's not recommended. +keepalive_timeout = 30000 + +# Now, a set of virtual servers. +# The examples below first show two virthosted servers on the same IP (0.0.0.0) +# in this case, but an explicit IP can be given as well. + + + port = 8000 + listen = 0.0.0.0 + docroot = __MODULE_WWW_DIR + auth_log = true + appmods = __MODULE_APP_MODS + start_mod = handler + diff --git a/src/battlemap/Makefile b/src/battlemap/Makefile index 4eca95a..8c7d206 100644 --- a/src/battlemap/Makefile +++ b/src/battlemap/Makefile @@ -44,6 +44,7 @@ include ${CURDIR}/mk/debug.mk include ${CURDIR}/mk/erlang.mk include ${CURDIR}/mk/preprocessor.mk include ${CURDIR}/mk/yaws.mk + ################################################################################ ## TARGET RULES ################################################################ ################################################################################ @@ -56,7 +57,7 @@ build: $(PREPROCESSOR_RESULT) $(ERLANG_RESULT) run: yaws_run clean: - rm -rf $(BIN_DIR)/* + rm -rf $(PREPROCESSOR_RESULT) $(ERLANG_RESULT) ################################################################################ ## INTERNAL RULES ############################################################## diff --git a/src/battlemap/mk/preprocessor.mk b/src/battlemap/mk/preprocessor.mk index 2b332a4..d27de1b 100644 --- a/src/battlemap/mk/preprocessor.mk +++ b/src/battlemap/mk/preprocessor.mk @@ -2,6 +2,7 @@ ## CONFIG ###################################################################### ################################################################################ CONFIG_FILE ?= ${CURDIR}/module.conf +YAWS_CONFIG_TEMPLATE ?= ################################################################################ ## MAKEFILE MAGIC ############################################################## @@ -9,6 +10,14 @@ CONFIG_FILE ?= ${CURDIR}/module.conf PREPROCESSOR_FILES = $(shell find ${CURDIR} -name "*.m4") PREPROCESSED_FILES = $(patsubst %.m4,%,$(PREPROCESSOR_FILES)) +MAKEFILE_TO_M4 = \ + --define=__MAKEFILE_MODULE_NAME=$(MODULE_NAME) \ + --define=__MAKEFILE_MODULE_PORT=$(MODULE_PORT) \ + --define=__MAKEFILE_BIN_DIR=$(BIN_DIR) \ + --define=__MAKEFILE_INCLUDE_DIR=$(INCLUDE_DIR) \ + --define=__MAKEFILE_LOG_DIR=$(LOG_DIR) \ + --define=__MAKEFILE_WWW_DIR=$(WWW_DIR) + ################################################################################ ## SANITY CHECKS ############################################################### ################################################################################ @@ -16,13 +25,20 @@ ifeq ($(wildcard $(CONFIG_FILE)),) $(error "Missing CONFIG_FILE ($(CONFIG_FILE)).") endif +ifeq ($(wildcard $(YAWS_CONFIG_TEMPLATE)),) +$(error "Missing YAWS_CONFIG_TEMPLATE ($(YAWS_CONFIG_TEMPLATE)).") +endif + ################################################################################ ## TARGET RULES ################################################################ ################################################################################ -PREPROCESSOR_RESULT = $(PREPROCESSED_FILES) +PREPROCESSOR_RESULT = $(PREPROCESSED_FILES) yaws.conf ################################################################################ ## INTERNAL RULES ############################################################## ################################################################################ $(PREPROCESSED_FILES): %: $(CONFIG_FILE) %.m4 m4 -P $^ > $@ + +yaws.conf: $(CONFIG_FILE) $(YAWS_CONFIG_TEMPLATE) + m4 -P $(MAKEFILE_TO_M4) $^ > $@ diff --git a/src/battlemap/module.conf b/src/battlemap/module.conf index e69de29..8c2a2b6 100644 --- a/src/battlemap/module.conf +++ b/src/battlemap/module.conf @@ -0,0 +1,9 @@ +m4_define(`__MODULE_NAME', `__MAKEFILE_MODULE_NAME')m4_dnl +m4_define(`__MODULE_PORT', `__MAKEFILE_MODULE_PORT')m4_dnl +m4_dnl +m4_define(`__MODULE_BIN_DIR', `__MAKEFILE_BIN_DIR')m4_dnl +m4_define(`__MODULE_INCLUDE_DIR', `__MAKEFILE_INCLUDE_DIR')m4_dnl +m4_define(`__MODULE_LOG_DIR', `__MAKEFILE_LOG_DIR')m4_dnl +m4_define(`__MODULE_WWW_DIR', `__MAKEFILE_WWW_DIR')m4_dnl +m4_dnl +m4_define(`__MODULE_APP_MODS', `character_turn load_state')m4_dnl -- cgit v1.2.3-70-g09d2