aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LICENSE2
-rw-r--r--Makefile7
-rw-r--r--README.md287
-rw-r--r--build.config17
-rw-r--r--core/core.mk71
-rw-r--r--core/deps.mk85
-rw-r--r--core/docs.mk19
-rw-r--r--core/erlc.mk59
-rw-r--r--core/test.mk48
-rw-r--r--erlang.mk781
-rw-r--r--packages.v1.tsv51
-rw-r--r--packages.v1.txt51
-rw-r--r--packages.v2.tsv59
-rwxr-xr-xpkg_add.sh10
-rw-r--r--plugins/asciidoc.mk46
-rw-r--r--plugins/bootstrap.mk88
-rw-r--r--plugins/c_src.mk90
-rw-r--r--plugins/ci.mk65
-rw-r--r--plugins/cover.mk136
-rw-r--r--plugins/ct.mk68
-rw-r--r--plugins/dialyzer.mk15
-rw-r--r--plugins/edoc.mk11
-rw-r--r--plugins/elvis.mk39
-rw-r--r--plugins/erlydtl.mk18
-rw-r--r--plugins/escript.mk64
-rw-r--r--plugins/eunit.mk54
-rw-r--r--plugins/relx.mk24
-rw-r--r--plugins/shell.mk28
-rw-r--r--plugins/triq.mk31
-rw-r--r--plugins/xref.mk38
-rw-r--r--test/Makefile220
31 files changed, 1639 insertions, 943 deletions
diff --git a/LICENSE b/LICENSE
index e43ab78..5ea629c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/Makefile b/Makefile
index d7bb08d..cc77d0b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -17,7 +17,7 @@ BUILD_CONFIG = $(shell sed "s/\#.*//" $(BUILD_CONFIG_FILE))
ERLANG_MK = erlang.mk
-.PHONY: all
+.PHONY: all check
all: pkg
awk 'FNR==1 && NR!=1{print ""}1' $(patsubst %,%.mk,$(BUILD_CONFIG)) > $(ERLANG_MK)
@@ -25,3 +25,6 @@ all: pkg
pkg:
cat packages.v2.tsv | awk 'BEGIN { FS = "\t" }; { print $$1 "\t" $$3 "\t" $$5 "\t" $$6 }' > packages.v1.tsv
cp packages.v1.tsv packages.v1.txt
+
+check:
+ make -C test
diff --git a/README.md b/README.md
index c3e4e93..cf0551d 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,18 @@ Common Makefile rules for building and testing Erlang applications.
Also features support for dependencies and a package index.
+Why erlang.mk?
+--------------
+
+A number of reasons might push someone to use erlang.mk instead of
+an Erlang-based build tool, including but not limited to the following:
+
+ * You want a very fast compilation and test cycle
+ * You want the full power of Unix at your disposal when hooking into your build tool
+ * You want to be able to easily edit the damn build tool and fix it when it fails
+ * You want to use the deps mechanism with non-Erlang Makefile-based projects
+ * Your project will be part of a larger make or automake based environment
+
Requirements
------------
@@ -72,6 +84,15 @@ DEPS = cowboy
include erlang.mk
```
+If you need to specify multiple dependencies, you can specify each
+of them separated by spaces:
+
+``` Makefile
+PROJECT = my_project
+DEPS = cowboy gun
+include erlang.mk
+```
+
If the project you want is not included in the package index, or if
you want a different version, a few options are available. You can
edit the package file and contribute to it by opening a pull request.
@@ -82,7 +103,8 @@ put the project information directly in the Makefile.
In the latter case you need to create a variable `dep_*` with the
asterisk replaced by the project name, for example `cowboy`. This
variable must contain three things: the fetching method used, the
-URL and the version requested.
+URL and the version requested. These lines must be defined before
+the erlang.mk include line.
The following snippet overrides the Cowboy version required:
@@ -94,6 +116,17 @@ dep_cowboy = git https://github.com/ninenines/cowboy 1.0.0
They will always be compiled using the command `make`. If the dependency
does not feature a Makefile, then erlang.mk will be used for building.
+For subversion dependencies, the url specifies trunk, branch or
+tag. To specify a particular revision, use `@revision` at the end of
+the url. No separate specification of branch, tag, or revision is
+required or possible.
+
+``` erlang
+DEPS = ex1 ex2
+dep_ex1 = svn https://example.com/svn/trunk/project/ex1
+dep_ex2 = svn svn://example.com/svn/branches/erlang-proj/ex2@264
+```
+
You can also specify test-only dependencies. These dependencies will only
be downloaded when running `make tests`. The format is the same as above,
except the variable `TEST_DEPS` holds the list of test-only dependencies.
@@ -106,6 +139,24 @@ dep_ct_helper = git https://github.com/extend/ct_helper.git master
Please note that the test dependencies will only be compiled once
when they are fetched, unlike the normal dependencies.
+Autopatch
+---------
+
+The autopatch features allows you to automatically fix packages
+that are not compatible with erlang.mk. It can also be used to
+convert compatible packages to use erlang.mk itself for building
+when used as dependency.
+
+The patching occurs only once, immediately after the package has
+been fetched.
+
+erlang.mk defines a number of packages to be patched. You can add
+more packages to the list by appending the `AUTOPATCH` variable.
+
+``` Makefile
+AUTOPATCH += gproc
+```
+
Releases
--------
@@ -173,6 +224,30 @@ You can enable verbose mode by calling Make with the variable
$ V=1 make
```
+Parallel execution can be enabled through the use of the
+`-j` option. The following output showcases concurrent
+downloading of dependencies.
+
+``` bash
+$ make -j32
+Cloning into '/home/essen/ninenines/cowboy/deps/ranch'...
+Cloning into '/home/essen/ninenines/cowboy/deps/cowlib'...
+```
+
+The `-O` option will ensure that output from different
+targets is grouped, which is particularly useful when
+running tests with different frameworks at the same time.
+The disadvantage of this option however is that there is
+no output until the target is completed.
+
+The``MAKEFLAGS` variable can be used to set it permanently
+on your system. It can be set in your `.zshrc`, `.bashrc`
+or equivalent file.
+
+``` bash
+MAKEFLAGS="-j32 -O"
+```
+
Core package functionality
--------------------------
@@ -180,7 +255,7 @@ The following targets are specific to packages:
`pkg-list` lists all packages in the index.
-`pkg-search n=STRING` searches the index for STRING.
+`pkg-search q=STRING` searches the index for STRING.
Packages are downloaded into `DEPS_DIR` (`./deps/` by default).
@@ -202,9 +277,37 @@ You can change compilation options by setting the `ERLC_OPTS`
variable. It takes the arguments that will then be passed to
`erlc`. For more information, please see `erl -man erlc`.
+Test target compilation options can be specified in `TEST_ERLC_OPTS`.
+It will override `ERLC_OPTS`.
+
You can specify a list of modules to be compiled first using
the `COMPILE_FIRST` variable.
+You can also use the `ERLC_EXCLUDE` variable to prevent some
+modules from being compiled by the core compiler. Note that
+`ERLC_EXCLUDE` is a list of module names (i.e., no file extension
+is required).
+
+If `{id, "git"},` is found in your project's `.app.src`, the
+extended output of `git describe ...` will replace it. This
+can be retrieved at runtime via `application:get_key/2`.
+
+Updating erlang.mk
+------------------
+
+You can update erlang.mk by running `make erlang-mk`. This automated
+update will always take the latest erlang.mk version, compile it and
+replace the erlang.mk of your project with the updated version.
+
+If your project includes a `build.config`, erlang.mk will use it
+when building the updated version.
+
+The `ERLANG_MK_BUILD_CONFIG` variable can be used to rename the
+`build.config` file.
+
+The `ERLANG_MK_BUILD_DIR` variable contains the path to the
+temporary directory used to build the updated erlang.mk.
+
Bootstrap plugin
----------------
@@ -222,12 +325,12 @@ templates.
`list-templates` lists the available templates.
-C compiler plugin
------------------
+C/C++ compiler plugin
+---------------------
-This plugin is not included by default. It is meant to
-simplify the management of projects that include C source
-code, like NIFs.
+This plugin is available by default. It is meant to
+simplify the management of projects that include C
+and/or C++ source code, like NIFs for example.
If the file `$(C_SRC_DIR)/Makefile` exists, then the plugin
simply calls it when needed. Otherwise it tries to compile
@@ -243,14 +346,17 @@ You can override the temporary file containing information
about Erlang's environment by setting the `C_SRC_ENV` variable.
This file is automatically generated on first run.
-Finally you can add extra compiler options using the
-`C_SRC_OPTS` variable. You can also override the defaults
-`CC` and `CFLAGS` if required.
+The `CC`, `CXX`, `CFLAGS`, `CXXFLAGS`, `LDLIBS` and `LDFLAGS` variables
+may be modified or replaced with any value of your choosing.
+The defaults are system dependent.
Common_test plugin
------------------
-This plugin is available by default.
+This plugin is available by default. It adds the following
+target:
+
+`ct` runs all test suites for this application.
There is nothing to configure to use it, simply create your
test suites in the `./test/` directory and erlang.mk will
@@ -287,7 +393,10 @@ included in the PLT file. There is no need to specify `erts`,
are automatically added.
Dialyzer options can be modified by defining the `DIALYZER_OPTS`
-variable. For more information please see `erl -man dialyzer`.
+variable. The directories to be analyzed can be overriden using
+the `DIALYZER_DIRS` variable. It defaults to analyzing source
+files recursively found in `src/`. For more information please
+see `erl -man dialyzer`.
EDoc plugin
-----------
@@ -298,12 +407,76 @@ EDoc options can be specified in Erlang format by defining
the `EDOC_OPTS` variable. For more information please see
`erl -man edoc`.
+Elvis plugin
+------------
+
+This plugin is available by default. It adds the following
+target:
+
+`elvis` runs Elvis style checker for this application.
+
+The `ELVIS_CONFIG` variable specifies the location of the
+configuration file which holds the rules to be applied.
+If there's no `elvis.config` file the default one will be
+downloaded. When the `ELVIS` variable points to a non-existing
+file then the `elvis` executable will be downloaded as well.
+Any other option should go in the `ELVIS_OPTS` variable.
+
ErlyDTL plugin
--------------
This plugin is available by default. It adds automatic
compilation of ErlyDTL templates found in `templates/*.dtl`
-or any subdirectory.
+or any subdirectory.
+
+By default it ignores names of subdirectories and compiles
+`a/b/templatename.dtl` into `templatename_dtl.beam`. To include
+subdirectories names in the compiled module name add
+`DTL_FULL_PATH=1` into your Makefile - `a/b/templatename.dtl`
+will be compiled into `a_b_templatename_dtl.beam`.
+
+
+Escript plugin
+--------------
+
+This plugin is available by default. It adds the following
+target:
+
+`escript` which creates a shell-executable archive named
+the same as your `$(PROJECT)`, containing the following files
+from your application and its dependencies:
+
+* `*.beam`
+* contents of `priv/`
+* `sys.config` for your application
+
+There are a number of optional configuration parameters:
+
+* `ESCRIPT_NAME` if a different output file is required
+* `ESCRIPT_COMMENT` to alter the comment line in the escript header
+* `ESCRIPT_BEAMS` for the paths searched for `*.beam` files to include
+* `ESCRIPT_SYS_CONFIG` defaults to `rel/sys.config`
+* `ESCRIPT_EMU_ARGS` for the parameters used to start the VM
+* `ESCRIPT_SHEBANG` for the line used by your shell to start `escript`
+* `ESCRIPT_STATIC` for non-beam directories to be included as well
+
+Refer to http://www.erlang.org/doc/man/escript.html for
+more information on `escript` functionality in general.
+
+EUnit plugin
+------------
+
+This plugin is available by default. It adds the following
+target:
+
+`eunit` which runs all the EUnit tests found in `ebin` or
+the test directory specified in `TEST_DIR`.
+
+`EUNIT_OPTS` can be used to specify EUnit-specific options
+(e.g. `verbose`) that will be used when calling
+`eunit:test/2`. This configuration parameter is empty
+by default.. Note that EUnit options are specified as
+a comma-separated list of options.
Relx plugin
-----------
@@ -322,22 +495,98 @@ You can change the generated releases location by setting
the `RELX_OUTPUT_DIR` variable. Any other option should go
in the `RELX_OPTS` variable.
+If `RELX_OPTS` includes the `-o` option (instead of using
+`RELX_OUTPUT_DIR`, then that option must be the first in
+the list, otherwise erlang.mk will fail to find it and
+will not be able to clean up the release directory.
+
+Shell plugin
+------------
+
+This plugin is available by default.
+
+`SHELL_DEPS` adds the specified modules only when `make shell`
+or `make build-shell-deps` is run. For example, to include a module
+reloader and TDD test runner, one might add `SHELL_DEPS = tddreloader`
+to the Makefile.
+
+You can add extra `erl` options by defining the `SHELL_OPTS` variable.
+For more information please see `erl -man erl`.
+
+`SHELL_PATH` adds paths to the shell's library search path. By default
+this option sets the paths to `-pa ../$(PROJECT)/ebin $(DEPS_DIR)/*/ebin`.
+
+Triq plugin
+-----------
+
+This plugin is available by default. It adds the following
+target:
+
+`triq` will check all the properties found in `ebin` or
+the test directory specified in `TEST_DIR`.
+
+You can use the `t` variable to give a specific module
+or function to run, for example:
+
+``` bash
+$ make triq t=cow_http_hd
+```
+
+Or:
+
+``` bash
+$ make triq t=cow_http_hd:prop_parse_accept
+```
+
+Xref plugin
+------------
+
+This plugin is available by default. It adds the following
+target:
+
+`xref` Erlang Xref Runner (inspired in rebar's rebar_xref)
+
+The `XREF_CONFIG` variable specifies the location of the
+configuration file which holds the checks to be applied.
+If there is no `xref.config` all `xref` checks will be
+applied to the binaries located in the `/ebin` directory.
+
Contributing
------------
You can contribute by providing feedback, creating patches,
adding packages to the index or new features as plugins.
-For packages, you only need to edit the `packages.v2.tsv`
-file, adding your package (they are sorted alphabetically),
-and then running `make` to update the older files kept for
-compatibility reasons.
+To add a package to the index, please use the `pkg_add.sh`
+script. To use it, first fork the repository, then please
+follow the example below:
+
+``` bash
+$ git clone https://github.com/$YOURUSERNAME/erlang.mk
+$ cd erlang.mk
+$ ./pkg_add.sh cowboy git https://github.com/ninenines/cowboy 1.0.0 http://ninenines.eu "Small, fast and modular HTTP server."
+$ git push origin master
+```
+
+Then open a pull request. The arguments given to the script
+are, in order, the project name, the download method used,
+the repository URL, the commit/tag/branch/version to pull,
+a link to the package's website and finally its description.
+Make sure to put double quotes around the description.
+
+You can submit as many packages as you want in one pull
+request as long as you follow the instructions above.
For patches or plugins, you have to edit the `core/*.mk`
-or `plugins/*.mk` files and then run `make` to create an
-updated `erlang.mk`. If you submit a new plugin, you also
+or `plugins/*.mk` files. If you submit a new plugin, you also
need to add it to the `build.config` file.
+Make sure to keep the commit title short, to have a single
+commit per package/feature/fix and you're good to submit
+a pull request! And again, please don't forget to run make
+and to commit the updated erlang.mk or index files along
+with your other changes. Thanks!
+
Support
-------
diff --git a/build.config b/build.config
index 7440d0d..d68eaff 100644
--- a/build.config
+++ b/build.config
@@ -5,14 +5,27 @@
core/core
core/deps
core/erlc
+core/docs
+core/test
# Plugins.
#
# Comment to disable, uncomment to enable.
+plugins/asciidoc
plugins/bootstrap
-#plugins/c_src
+plugins/c_src
+plugins/ci
plugins/ct
plugins/dialyzer
-plugins/erlydtl
plugins/edoc
+plugins/elvis
+plugins/erlydtl
+plugins/escript
+plugins/eunit
plugins/relx
+plugins/shell
+plugins/triq
+plugins/xref
+
+# Plugins enhancing the functionality of other plugins.
+plugins/cover
diff --git a/core/core.mk b/core/core.mk
index d25897b..5cb0b54 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -1,4 +1,4 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -12,7 +12,7 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.PHONY: all deps app rel docs tests clean distclean help
+.PHONY: all deps app rel docs install-docs tests check clean distclean help erlang-mk
ERLANG_MK_VERSION = 1
@@ -28,12 +28,32 @@ V ?= 0
gen_verbose_0 = @echo " GEN " $@;
gen_verbose = $(gen_verbose_$(V))
+# "erl" command.
+
+ERL = erl +A0 -noinput -boot start_clean
+
# Core targets.
-all:: deps app rel
+ifneq ($(words $(MAKECMDGOALS)),1)
+.NOTPARALLEL:
+endif
+
+all:: deps
+ @$(MAKE) --no-print-directory app
+ @$(MAKE) --no-print-directory rel
+
+# Noop to avoid a Make warning when there's nothing to do.
+rel::
+ @echo -n
+
+check:: clean app tests
+
+clean:: clean-crashdump
-clean::
+clean-crashdump:
+ifneq ($(wildcard erl_crash.dump),)
$(gen_verbose) rm -f erl_crash.dump
+endif
distclean:: clean
@@ -42,26 +62,47 @@ help::
"erlang.mk (version $(ERLANG_MK_VERSION)) is distributed under the terms of the ISC License." \
"Copyright (c) 2013-2014 Loïc Hoguin <[email protected]>" \
"" \
- "Usage: [V=1] make [target]" \
+ "Usage: [V=1] make [-jNUM] [target]" \
"" \
"Core targets:" \
- " all Run deps, app and rel targets in that order" \
- " deps Fetch dependencies (if needed) and compile them" \
- " app Compile the project" \
- " rel Build a release for this project, if applicable" \
- " docs Build the documentation for this project" \
- " tests Run the tests for this project" \
- " clean Delete temporary and output files from most targets" \
- " distclean Delete all temporary and output files" \
- " help Display this help and exit" \
+ " all Run deps, app and rel targets in that order" \
+ " deps Fetch dependencies (if needed) and compile them" \
+ " app Compile the project" \
+ " rel Build a release for this project, if applicable" \
+ " docs Build the documentation for this project" \
+ " install-docs Install the man pages for this project" \
+ " tests Run the tests for this project" \
+ " check Compile and run all tests and analysis for this project" \
+ " clean Delete temporary and output files from most targets" \
+ " distclean Delete all temporary and output files" \
+ " help Display this help and exit" \
"" \
"The target clean only removes files that are commonly removed." \
"Dependencies and releases are left untouched." \
"" \
- "Setting V=1 when calling make enables verbose mode."
+ "Setting V=1 when calling make enables verbose mode." \
+ "Parallel execution is supported through the -j Make flag."
# Core functions.
+ifeq ($(shell which wget 2>/dev/null | wc -l), 1)
define core_http_get
wget --no-check-certificate -O $(1) $(2)|| rm $(1)
endef
+else
+define core_http_get
+ $(ERL) -eval 'ssl:start(), inets:start(), case httpc:request(get, {"$(2)", []}, [{autoredirect, true}], []) of {ok, {{_, 200, _}, _, Body}} -> case file:write_file("$(1)", Body) of ok -> ok; {error, R1} -> halt(R1) end; {error, R2} -> halt(R2) end, halt(0).'
+endef
+endif
+
+# Automated update.
+
+ERLANG_MK_BUILD_CONFIG ?= build.config
+ERLANG_MK_BUILD_DIR ?= .erlang.mk.build
+
+erlang-mk:
+ git clone https://github.com/ninenines/erlang.mk $(ERLANG_MK_BUILD_DIR)
+ if [ -f $(ERLANG_MK_BUILD_CONFIG) ]; then cp $(ERLANG_MK_BUILD_CONFIG) $(ERLANG_MK_BUILD_DIR); fi
+ cd $(ERLANG_MK_BUILD_DIR) && make
+ cp $(ERLANG_MK_BUILD_DIR)/erlang.mk ./erlang.mk
+ rm -rf $(ERLANG_MK_BUILD_DIR)
diff --git a/core/deps.mk b/core/deps.mk
index f15ae74..3b18ce9 100644
--- a/core/deps.mk
+++ b/core/deps.mk
@@ -1,10 +1,13 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
.PHONY: distclean-deps distclean-pkg pkg-list pkg-search
# Configuration.
+AUTOPATCH ?= edown gen_leader gproc
+export AUTOPATCH
+
DEPS_DIR ?= $(CURDIR)/deps
export DEPS_DIR
@@ -27,26 +30,85 @@ export PKG_FILE2
PKG_FILE_URL ?= https://raw.githubusercontent.com/ninenines/erlang.mk/master/packages.v2.tsv
+# Verbosity.
+
+dep_verbose_0 = @echo " DEP " $(1);
+dep_verbose = $(dep_verbose_$(V))
+
# Core targets.
+ifneq ($(SKIP_DEPS),)
+deps::
+else
deps:: $(ALL_DEPS_DIRS)
@for dep in $(ALL_DEPS_DIRS) ; do \
if [ -f $$dep/GNUmakefile ] || [ -f $$dep/makefile ] || [ -f $$dep/Makefile ] ; then \
- $(MAKE) -C $$dep ; \
+ $(MAKE) -C $$dep || exit $$? ; \
else \
- echo "include $(CURDIR)/erlang.mk" | $(MAKE) -f - -C $$dep ; \
+ echo "ERROR: No makefile to build dependency $$dep. Consider adding it to AUTOPATCH." ; \
+ exit 1 ; \
fi ; \
done
+endif
distclean:: distclean-deps distclean-pkg
# Deps related targets.
+define dep_autopatch
+ $(ERL) -eval " \
+DepDir = \"$(DEPS_DIR)/$(1)/\", \
+fun() -> \
+ {ok, Conf} = case file:consult(DepDir ++ \"rebar.config\") of \
+ {error, enoent} -> {ok, []}; Res -> Res end, \
+ File = case lists:keyfind(deps, 1, Conf) of false -> []; {_, Deps} -> \
+ [begin {Method, Repo, Commit} = case Repos of \
+ {git, R} -> {git, R, master}; \
+ {M, R, {branch, C}} -> {M, R, C}; \
+ {M, R, {tag, C}} -> {M, R, C}; \
+ {M, R, C} -> {M, R, C} \
+ end, \
+ io_lib:format(\"DEPS += ~s\ndep_~s = ~s ~s ~s~n\", [Name, Name, Method, Repo, Commit]) \
+ end || {Name, _, Repos} <- Deps] \
+ end, \
+ First = case lists:keyfind(erl_first_files, 1, Conf) of false -> []; {_, Files} -> \
+ Names = [[\" \", begin \"lre.\" ++ R = lists:reverse(F), lists:reverse(R) end] \
+ || \"src/\" ++ F <- Files], \
+ io_lib:format(\"COMPILE_FIRST +=~s\n\", [Names]) \
+ end, \
+ ok = file:write_file(\"$(DEPS_DIR)/$(1)/Makefile\", [\"ERLC_OPTS = +debug_info\n\n\", File, First, \"\ninclude erlang.mk\"]) \
+end(), \
+AppSrcOut = \"$(DEPS_DIR)/$(1)/src/$(1).app.src\", \
+AppSrcIn = case filelib:is_regular(AppSrcOut) of false -> \"$(DEPS_DIR)/$(1)/ebin/$(1).app\"; true -> AppSrcOut end, \
+fun() -> \
+ {ok, [{application, $(1), L}]} = file:consult(AppSrcIn), \
+ L2 = case lists:keyfind(modules, 1, L) of {_, _} -> L; false -> [{modules, []}|L] end, \
+ L3 = case lists:keyfind(vsn, 1, L2) of {vsn, git} -> lists:keyreplace(vsn, 1, L2, {vsn, \"git\"}); _ -> L2 end, \
+ ok = file:write_file(AppSrcOut, io_lib:format(\"~p.~n\", [{application, $(1), L3}])) \
+end(), \
+case AppSrcOut of AppSrcIn -> ok; _ -> ok = file:delete(AppSrcIn) end, \
+halt()."
+endef
+
+ifeq ($(V),0)
+define dep_autopatch_verbose
+ @echo " PATCH " $(1);
+endef
+endif
+
define dep_fetch
if [ "$$$$VS" = "git" ]; then \
- git clone -n -- $$$$REPO $(DEPS_DIR)/$(1); \
+ git clone -q -n -- $$$$REPO $(DEPS_DIR)/$(1); \
cd $(DEPS_DIR)/$(1) && git checkout -q $$$$COMMIT; \
+ elif [ "$$$$VS" = "hg" ]; then \
+ hg clone -q -U $$$$REPO $(DEPS_DIR)/$(1); \
+ cd $(DEPS_DIR)/$(1) && hg update -q $$$$COMMIT; \
+ elif [ "$$$$VS" = "svn" ]; then \
+ svn checkout -q $$$$REPO $(DEPS_DIR)/$(1); \
+ elif [ "$$$$VS" = "cp" ]; then \
+ cp -R $$$$REPO $(DEPS_DIR)/$(1); \
else \
+ echo "Unknown or invalid dependency: $(1). Please consult the erlang.mk README for instructions." >&2; \
exit 78; \
fi
endef
@@ -54,19 +116,24 @@ endef
define dep_target
$(DEPS_DIR)/$(1):
@mkdir -p $(DEPS_DIR)
- @if [ ! -f $(PKG_FILE2) ]; then $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL)); fi
ifeq (,$(dep_$(1)))
- DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);) \
+ @if [ ! -f $(PKG_FILE2) ]; then $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL)); fi
+ $(dep_verbose) DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);); \
VS=$$$$(echo $$$$DEPPKG | cut -d " " -f1); \
REPO=$$$$(echo $$$$DEPPKG | cut -d " " -f2); \
COMMIT=$$$$(echo $$$$DEPPKG | cut -d " " -f3); \
$(call dep_fetch,$(1))
else
- VS=$(word 1,$(dep_$(1))); \
+ $(dep_verbose) VS=$(word 1,$(dep_$(1))); \
REPO=$(word 2,$(dep_$(1))); \
COMMIT=$(word 3,$(dep_$(1))); \
$(call dep_fetch,$(1))
endif
+ifneq ($(filter $(1),$(AUTOPATCH)),)
+ $(call dep_autopatch_verbose,$(1)) \
+ $(call dep_autopatch,$(1)); \
+ cd $(DEPS_DIR)/$(1)/ && ln -s ../../erlang.mk
+endif
endef
$(foreach dep,$(DEPS),$(eval $(call dep_target,$(dep))))
@@ -77,7 +144,7 @@ distclean-deps:
# Packages related targets.
$(PKG_FILE2):
- $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL))
+ @$(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL))
pkg-list: $(PKG_FILE2)
@cat $(PKG_FILE2) | awk 'BEGIN { FS = "\t" }; { print \
@@ -98,8 +165,10 @@ pkg-search:
$(error Usage: make pkg-search q=STRING)
endif
+ifeq ($(PKG_FILE2),$(CURDIR)/.erlang.mk.packages.v2)
distclean-pkg:
$(gen_verbose) rm -f $(PKG_FILE2)
+endif
help::
@printf "%s\n" "" \
diff --git a/core/docs.mk b/core/docs.mk
new file mode 100644
index 0000000..e1e2d0e
--- /dev/null
+++ b/core/docs.mk
@@ -0,0 +1,19 @@
+# Copyright (c) 2015, Viktor Söderqvist <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: docs-deps
+
+# Configuration.
+
+ALL_DOC_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(DOC_DEPS))
+
+# Targets.
+
+$(foreach dep,$(DOC_DEPS),$(eval $(call dep_target,$(dep))))
+
+ifneq ($(SKIP_DEPS),)
+doc-deps:
+else
+doc-deps: $(ALL_DOC_DEPS_DIRS)
+ @for dep in $(ALL_DOC_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
+endif
diff --git a/core/erlc.mk b/core/erlc.mk
index 87d10d8..dc488a5 100644
--- a/core/erlc.mk
+++ b/core/erlc.mk
@@ -1,38 +1,66 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
.PHONY: clean-app
# Configuration.
-ERLC_OPTS ?= -Werror +debug_info +warn_export_all +warn_export_vars \
- +warn_shadow_vars +warn_obsolete_guard # +bin_opt_info +warn_missing_spec
+ERLC_OPTS ?= -Werror +debug_info +warn_export_vars +warn_shadow_vars \
+ +warn_obsolete_guard # +bin_opt_info +warn_export_all +warn_missing_spec
COMPILE_FIRST ?=
COMPILE_FIRST_PATHS = $(addprefix src/,$(addsuffix .erl,$(COMPILE_FIRST)))
+ERLC_EXCLUDE ?=
+ERLC_EXCLUDE_PATHS = $(addprefix src/,$(addsuffix .erl,$(ERLC_EXCLUDE)))
+
+ERLC_MIB_OPTS ?=
+COMPILE_MIB_FIRST ?=
+COMPILE_MIB_FIRST_PATHS = $(addprefix mibs/,$(addsuffix .mib,$(COMPILE_MIB_FIRST)))
# Verbosity.
appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src;
appsrc_verbose = $(appsrc_verbose_$(V))
-erlc_verbose_0 = @echo " ERLC " $(filter %.erl %.core,$(?F));
+erlc_verbose_0 = @echo " ERLC " $(filter-out $(patsubst %,%.erl,$(ERLC_EXCLUDE)),\
+ $(filter %.erl %.core,$(?F)));
erlc_verbose = $(erlc_verbose_$(V))
xyrl_verbose_0 = @echo " XYRL " $(filter %.xrl %.yrl,$(?F));
xyrl_verbose = $(xyrl_verbose_$(V))
-# Core targets.
+mib_verbose_0 = @echo " MIB " $(filter %.bin %.mib,$(?F));
+mib_verbose = $(mib_verbose_$(V))
+
+# Targets.
-app:: ebin/$(PROJECT).app
+ifeq ($(wildcard ebin/test),)
+app:: app-build
+else
+app:: clean app-build
+endif
+
+app-build: erlc-include ebin/$(PROJECT).app
$(eval MODULES := $(shell find ebin -type f -name \*.beam \
| sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//'))
+ @if [ -z "$$(grep -E '^[^%]*{modules,' src/$(PROJECT).app.src)" ]; then \
+ echo "Empty modules entry not found in $(PROJECT).app.src. Please consult the erlang.mk README for instructions." >&2; \
+ exit 1; \
+ fi
+ $(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null || true))
$(appsrc_verbose) cat src/$(PROJECT).app.src \
| sed "s/{modules,[[:space:]]*\[\]}/{modules, \[$(MODULES)\]}/" \
+ | sed "s/{id,[[:space:]]*\"git\"}/{id, \"$(GITDESCRIBE)\"}/" \
> ebin/$(PROJECT).app
+erlc-include:
+ -@if [ -d ebin/ ]; then \
+ find include/ src/ -type f -name \*.hrl -newer ebin -exec touch $(shell find src/ -type f -name "*.erl") \; 2>/dev/null || printf ''; \
+ fi
+
define compile_erl
$(erlc_verbose) erlc -v $(ERLC_OPTS) -o ebin/ \
- -pa ebin/ -I include/ $(COMPILE_FIRST_PATHS) $(1)
+ -pa ebin/ -I include/ $(filter-out $(ERLC_EXCLUDE_PATHS),\
+ $(COMPILE_FIRST_PATHS) $(1))
endef
define compile_xyrl
@@ -41,10 +69,22 @@ define compile_xyrl
@rm ebin/*.erl
endef
+define compile_mib
+ $(mib_verbose) erlc -v $(ERLC_MIB_OPTS) -o priv/mibs/ \
+ -I priv/mibs/ $(COMPILE_MIB_FIRST_PATHS) $(1)
+ $(mib_verbose) erlc -o include/ -- priv/mibs/*.bin
+endef
+
ifneq ($(wildcard src/),)
ebin/$(PROJECT).app::
@mkdir -p ebin/
+ifneq ($(wildcard mibs/),)
+ebin/$(PROJECT).app:: $(shell find mibs -type f -name \*.mib)
+ @mkdir -p priv/mibs/ include
+ $(if $(strip $?),$(call compile_mib,$?))
+endif
+
ebin/$(PROJECT).app:: $(shell find src -type f -name \*.erl) \
$(shell find src -type f -name \*.core)
$(if $(strip $?),$(call compile_erl,$?))
@@ -56,7 +96,6 @@ endif
clean:: clean-app
-# Extra targets.
-
clean-app:
- $(gen_verbose) rm -rf ebin/
+ $(gen_verbose) rm -rf ebin/ priv/mibs/ \
+ $(addprefix include/,$(addsuffix .hrl,$(notdir $(basename $(wildcard mibs/*.mib)))))
diff --git a/core/test.mk b/core/test.mk
new file mode 100644
index 0000000..7dd5d61
--- /dev/null
+++ b/core/test.mk
@@ -0,0 +1,48 @@
+# Copyright (c) 2015, Loïc Hoguin <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: test-deps test-dir test-build clean-test-dir
+
+# Configuration.
+
+TEST_DIR ?= $(CURDIR)/test
+
+ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS))
+
+TEST_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard
+TEST_ERLC_OPTS += -DTEST=1
+
+# Targets.
+
+$(foreach dep,$(TEST_DEPS),$(eval $(call dep_target,$(dep))))
+
+ifneq ($(SKIP_DEPS),)
+test-deps:
+else
+test-deps: $(ALL_TEST_DEPS_DIRS)
+ @for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
+endif
+
+ifneq ($(strip $(TEST_DIR)),)
+test-dir:
+ $(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -I include/ -o $(TEST_DIR) \
+ $(wildcard $(TEST_DIR)/*.erl $(TEST_DIR)/*/*.erl) -pa ebin/
+endif
+
+ifeq ($(wildcard ebin/test),)
+test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
+test-build:: clean deps test-deps
+ @$(MAKE) --no-print-directory app-build test-dir ERLC_OPTS="$(TEST_ERLC_OPTS)"
+ $(gen_verbose) touch ebin/test
+else
+test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
+test-build:: deps test-deps
+ @$(MAKE) --no-print-directory app-build test-dir ERLC_OPTS="$(TEST_ERLC_OPTS)"
+endif
+
+clean:: clean-test-dir
+
+clean-test-dir:
+ifneq ($(wildcard $(TEST_DIR)/*.beam),)
+ $(gen_verbose) rm -f $(TEST_DIR)/*.beam
+endif
diff --git a/erlang.mk b/erlang.mk
index 6f1b5c2..0060523 100644
--- a/erlang.mk
+++ b/erlang.mk
@@ -1,773 +1,14 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+# Automated update.
-.PHONY: all deps app rel docs tests clean distclean help
+ERLANG_MK_BUILD_CONFIG ?= build.config
+ERLANG_MK_BUILD_DIR ?= .erlang.mk.build
-ERLANG_MK_VERSION = 1
+erlang.mk: bootstrap
+ git clone https://github.com/ninenines/erlang.mk $(ERLANG_MK_BUILD_DIR)
+ if [ -f $(ERLANG_MK_BUILD_CONFIG) ]; then cp $(ERLANG_MK_BUILD_CONFIG) $(ERLANG_MK_BUILD_DIR); fi
+ cd $(ERLANG_MK_BUILD_DIR) && make
+ cp $(ERLANG_MK_BUILD_DIR)/erlang.mk ./erlang.mk
+ rm -rf $(ERLANG_MK_BUILD_DIR)
-# Core configuration.
-
-PROJECT ?= $(notdir $(CURDIR))
-PROJECT := $(strip $(PROJECT))
-
-# Verbosity.
-
-V ?= 0
-
-gen_verbose_0 = @echo " GEN " $@;
-gen_verbose = $(gen_verbose_$(V))
-
-# Core targets.
-
-all:: deps app rel
-
-clean::
- $(gen_verbose) rm -f erl_crash.dump
-
-distclean:: clean
-
-help::
- @printf "%s\n" \
- "erlang.mk (version $(ERLANG_MK_VERSION)) is distributed under the terms of the ISC License." \
- "Copyright (c) 2013-2014 Loïc Hoguin <[email protected]>" \
- "" \
- "Usage: [V=1] make [target]" \
- "" \
- "Core targets:" \
- " all Run deps, app and rel targets in that order" \
- " deps Fetch dependencies (if needed) and compile them" \
- " app Compile the project" \
- " rel Build a release for this project, if applicable" \
- " docs Build the documentation for this project" \
- " tests Run the tests for this project" \
- " clean Delete temporary and output files from most targets" \
- " distclean Delete all temporary and output files" \
- " help Display this help and exit" \
- "" \
- "The target clean only removes files that are commonly removed." \
- "Dependencies and releases are left untouched." \
- "" \
- "Setting V=1 when calling make enables verbose mode."
-
-# Core functions.
-
-define core_http_get
- wget --no-check-certificate -O $(1) $(2)|| rm $(1)
-endef
-
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
-# This file is part of erlang.mk and subject to the terms of the ISC License.
-
-.PHONY: distclean-deps distclean-pkg pkg-list pkg-search
-
-# Configuration.
-
-DEPS_DIR ?= $(CURDIR)/deps
-export DEPS_DIR
-
-REBAR_DEPS_DIR = $(DEPS_DIR)
-export REBAR_DEPS_DIR
-
-ALL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(DEPS))
-
-ifeq ($(filter $(DEPS_DIR),$(subst :, ,$(ERL_LIBS))),)
-ifeq ($(ERL_LIBS),)
- ERL_LIBS = $(DEPS_DIR)
-else
- ERL_LIBS := $(ERL_LIBS):$(DEPS_DIR)
-endif
-endif
-export ERL_LIBS
-
-PKG_FILE2 ?= $(CURDIR)/.erlang.mk.packages.v2
-export PKG_FILE2
-
-PKG_FILE_URL ?= https://raw.githubusercontent.com/ninenines/erlang.mk/master/packages.v2.tsv
-
-# Core targets.
-
-deps:: $(ALL_DEPS_DIRS)
- @for dep in $(ALL_DEPS_DIRS) ; do \
- if [ -f $$dep/GNUmakefile ] || [ -f $$dep/makefile ] || [ -f $$dep/Makefile ] ; then \
- $(MAKE) -C $$dep ; \
- else \
- echo "include $(CURDIR)/erlang.mk" | $(MAKE) -f - -C $$dep ; \
- fi ; \
- done
-
-distclean:: distclean-deps distclean-pkg
-
-# Deps related targets.
-
-define dep_fetch
- if [ "$$$$VS" = "git" ]; then \
- git clone -n -- $$$$REPO $(DEPS_DIR)/$(1); \
- cd $(DEPS_DIR)/$(1) && git checkout -q $$$$COMMIT; \
- else \
- exit 78; \
- fi
-endef
-
-define dep_target
-$(DEPS_DIR)/$(1):
- @mkdir -p $(DEPS_DIR)
- @if [ ! -f $(PKG_FILE2) ]; then $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL)); fi
-ifeq (,$(dep_$(1)))
- DEPPKG=$$$$(awk 'BEGIN { FS = "\t" }; $$$$1 == "$(1)" { print $$$$2 " " $$$$3 " " $$$$4 }' $(PKG_FILE2);) \
- VS=$$$$(echo $$$$DEPPKG | cut -d " " -f1); \
- REPO=$$$$(echo $$$$DEPPKG | cut -d " " -f2); \
- COMMIT=$$$$(echo $$$$DEPPKG | cut -d " " -f3); \
- $(call dep_fetch,$(1))
-else
- VS=$(word 1,$(dep_$(1))); \
- REPO=$(word 2,$(dep_$(1))); \
- COMMIT=$(word 3,$(dep_$(1))); \
- $(call dep_fetch,$(1))
-endif
-endef
-
-$(foreach dep,$(DEPS),$(eval $(call dep_target,$(dep))))
-
-distclean-deps:
- $(gen_verbose) rm -rf $(DEPS_DIR)
-
-# Packages related targets.
-
-$(PKG_FILE2):
- $(call core_http_get,$(PKG_FILE2),$(PKG_FILE_URL))
-
-pkg-list: $(PKG_FILE2)
- @cat $(PKG_FILE2) | awk 'BEGIN { FS = "\t" }; { print \
- "Name:\t\t" $$1 "\n" \
- "Repository:\t" $$3 "\n" \
- "Website:\t" $$5 "\n" \
- "Description:\t" $$6 "\n" }'
-
-ifdef q
-pkg-search: $(PKG_FILE2)
- @cat $(PKG_FILE2) | grep -i ${q} | awk 'BEGIN { FS = "\t" }; { print \
- "Name:\t\t" $$1 "\n" \
- "Repository:\t" $$3 "\n" \
- "Website:\t" $$5 "\n" \
- "Description:\t" $$6 "\n" }'
-else
-pkg-search:
- $(error Usage: make pkg-search q=STRING)
-endif
-
-distclean-pkg:
- $(gen_verbose) rm -f $(PKG_FILE2)
-
-help::
- @printf "%s\n" "" \
- "Package-related targets:" \
- " pkg-list List all known packages" \
- " pkg-search q=STRING Search for STRING in the package index"
-
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
-# This file is part of erlang.mk and subject to the terms of the ISC License.
-
-.PHONY: clean-app
-
-# Configuration.
-
-ERLC_OPTS ?= -Werror +debug_info +warn_export_all +warn_export_vars \
- +warn_shadow_vars +warn_obsolete_guard # +bin_opt_info +warn_missing_spec
-COMPILE_FIRST ?=
-COMPILE_FIRST_PATHS = $(addprefix src/,$(addsuffix .erl,$(COMPILE_FIRST)))
-
-# Verbosity.
-
-appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src;
-appsrc_verbose = $(appsrc_verbose_$(V))
-
-erlc_verbose_0 = @echo " ERLC " $(filter %.erl %.core,$(?F));
-erlc_verbose = $(erlc_verbose_$(V))
-
-xyrl_verbose_0 = @echo " XYRL " $(filter %.xrl %.yrl,$(?F));
-xyrl_verbose = $(xyrl_verbose_$(V))
-
-# Core targets.
-
-app:: ebin/$(PROJECT).app
- $(eval MODULES := $(shell find ebin -type f -name \*.beam \
- | sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//'))
- $(appsrc_verbose) cat src/$(PROJECT).app.src \
- | sed "s/{modules,[[:space:]]*\[\]}/{modules, \[$(MODULES)\]}/" \
- > ebin/$(PROJECT).app
-
-define compile_erl
- $(erlc_verbose) erlc -v $(ERLC_OPTS) -o ebin/ \
- -pa ebin/ -I include/ $(COMPILE_FIRST_PATHS) $(1)
-endef
-
-define compile_xyrl
- $(xyrl_verbose) erlc -v -o ebin/ $(1)
- $(xyrl_verbose) erlc $(ERLC_OPTS) -o ebin/ ebin/*.erl
- @rm ebin/*.erl
-endef
-
-ifneq ($(wildcard src/),)
-ebin/$(PROJECT).app::
- @mkdir -p ebin/
-
-ebin/$(PROJECT).app:: $(shell find src -type f -name \*.erl) \
- $(shell find src -type f -name \*.core)
- $(if $(strip $?),$(call compile_erl,$?))
-
-ebin/$(PROJECT).app:: $(shell find src -type f -name \*.xrl) \
- $(shell find src -type f -name \*.yrl)
- $(if $(strip $?),$(call compile_xyrl,$?))
-endif
-
-clean:: clean-app
-
-# Extra targets.
-
-clean-app:
- $(gen_verbose) rm -rf ebin/
-
-# Copyright (c) 2014, Loïc Hoguin <[email protected]>
-# This file is part of erlang.mk and subject to the terms of the ISC License.
-
-.PHONY: bootstrap bootstrap-lib bootstrap-rel new list-templates
-
-# Core targets.
-
-help::
- @printf "%s\n" "" \
- "Bootstrap targets:" \
- " bootstrap Generate a skeleton of an OTP application" \
- " bootstrap-lib Generate a skeleton of an OTP library" \
- " bootstrap-rel Generate the files needed to build a release" \
- " new t=TPL n=NAME Generate a module NAME based on the template TPL" \
- " list-templates List available templates"
-
-# Bootstrap templates.
-
-define bs_appsrc
-{application, $(PROJECT), [
- {description, ""},
- {vsn, "0.1.0"},
- {modules, []},
- {registered, []},
- {applications, [
- kernel,
- stdlib
- ]},
- {mod, {$(PROJECT)_app, []}},
- {env, []}
-]}.
-endef
-
-define bs_appsrc_lib
-{application, $(PROJECT), [
- {description, ""},
- {vsn, "0.1.0"},
- {modules, []},
- {registered, []},
- {applications, [
- kernel,
- stdlib
- ]}
-]}.
-endef
-
-define bs_Makefile
-PROJECT = $(PROJECT)
-include erlang.mk
-endef
-
-define bs_app
--module($(PROJECT)_app).
--behaviour(application).
-
--export([start/2]).
--export([stop/1]).
-
-start(_Type, _Args) ->
- $(PROJECT)_sup:start_link().
-
-stop(_State) ->
- ok.
-endef
-
-define bs_relx_config
-{release, {$(PROJECT)_release, "1"}, [$(PROJECT)]}.
-{extended_start_script, true}.
-{sys_config, "rel/sys.config"}.
-{vm_args, "rel/vm.args"}.
-endef
-
-define bs_sys_config
-[
-].
-endef
-
-define bs_vm_args
--name $(PROJECT)@127.0.0.1
--setcookie $(PROJECT)
--heart
-endef
-
-# Normal templates.
-define tpl_supervisor
--module($(n)).
--behaviour(supervisor).
-
--export([start_link/0]).
--export([init/1]).
-
-start_link() ->
- supervisor:start_link({local, ?MODULE}, ?MODULE, []).
-
-init([]) ->
- Procs = [],
- {ok, {{one_for_one, 1, 5}, Procs}}.
-endef
-
-define tpl_gen_server
--module($(n)).
--behaviour(gen_server).
-
-%% API.
--export([start_link/0]).
-
-%% gen_server.
--export([init/1]).
--export([handle_call/3]).
--export([handle_cast/2]).
--export([handle_info/2]).
--export([terminate/2]).
--export([code_change/3]).
-
--record(state, {
-}).
-
-%% API.
-
--spec start_link() -> {ok, pid()}.
-start_link() ->
- gen_server:start_link(?MODULE, [], []).
-
-%% gen_server.
-
-init([]) ->
- {ok, #state{}}.
-
-handle_call(_Request, _From, State) ->
- {reply, ignored, State}.
-
-handle_cast(_Msg, State) ->
- {noreply, State}.
-
-handle_info(_Info, State) ->
- {noreply, State}.
-
-terminate(_Reason, _State) ->
- ok.
-
-code_change(_OldVsn, State, _Extra) ->
- {ok, State}.
-endef
-
-define tpl_cowboy_http
--module($(n)).
--behaviour(cowboy_http_handler).
-
--export([init/3]).
--export([handle/2]).
--export([terminate/3]).
-
--record(state, {
-}).
-
-init(_, Req, _Opts) ->
- {ok, Req, #state{}}.
-
-handle(Req, State=#state{}) ->
- {ok, Req2} = cowboy_req:reply(200, Req),
- {ok, Req2, State}.
-
-terminate(_Reason, _Req, _State) ->
- ok.
-endef
-
-define tpl_cowboy_loop
--module($(n)).
--behaviour(cowboy_loop_handler).
-
--export([init/3]).
--export([info/3]).
--export([terminate/3]).
-
--record(state, {
-}).
-
-init(_, Req, _Opts) ->
- {loop, Req, #state{}, 5000, hibernate}.
-
-info(_Info, Req, State) ->
- {loop, Req, State, hibernate}.
-
-terminate(_Reason, _Req, _State) ->
- ok.
-endef
-
-define tpl_cowboy_rest
--module($(n)).
-
--export([init/3]).
--export([content_types_provided/2]).
--export([get_html/2]).
-
-init(_, _Req, _Opts) ->
- {upgrade, protocol, cowboy_rest}.
-
-content_types_provided(Req, State) ->
- {[{{<<"text">>, <<"html">>, '_'}, get_html}], Req, State}.
-
-get_html(Req, State) ->
- {<<"<html><body>This is REST!</body></html>">>, Req, State}.
-endef
-
-define tpl_cowboy_ws
--module($(n)).
--behaviour(cowboy_websocket_handler).
-
--export([init/3]).
--export([websocket_init/3]).
--export([websocket_handle/3]).
--export([websocket_info/3]).
--export([websocket_terminate/3]).
-
--record(state, {
-}).
-
-init(_, _, _) ->
- {upgrade, protocol, cowboy_websocket}.
-
-websocket_init(_, Req, _Opts) ->
- Req2 = cowboy_req:compact(Req),
- {ok, Req2, #state{}}.
-
-websocket_handle({text, Data}, Req, State) ->
- {reply, {text, Data}, Req, State};
-websocket_handle({binary, Data}, Req, State) ->
- {reply, {binary, Data}, Req, State};
-websocket_handle(_Frame, Req, State) ->
- {ok, Req, State}.
-
-websocket_info(_Info, Req, State) ->
- {ok, Req, State}.
-
-websocket_terminate(_Reason, _Req, _State) ->
- ok.
-endef
-
-define tpl_ranch_protocol
--module($(n)).
--behaviour(ranch_protocol).
-
--export([start_link/4]).
--export([init/4]).
-
--type opts() :: [].
--export_type([opts/0]).
-
--record(state, {
- socket :: inet:socket(),
- transport :: module()
-}).
-
-start_link(Ref, Socket, Transport, Opts) ->
- Pid = spawn_link(?MODULE, init, [Ref, Socket, Transport, Opts]),
- {ok, Pid}.
-
--spec init(ranch:ref(), inet:socket(), module(), opts()) -> ok.
-init(Ref, Socket, Transport, _Opts) ->
- ok = ranch:accept_ack(Ref),
- loop(#state{socket=Socket, transport=Transport}).
-
-loop(State) ->
- loop(State).
-endef
-
-# Plugin-specific targets.
-
-define render_template
- @echo '$(subst $(newline),\n,${1})' > $(2)
-endef
-
-define newline
-
-
-endef
-
-bootstrap:
-ifneq ($(wildcard src/),)
- $(error Error: src/ directory already exists)
-endif
- $(call render_template,$(bs_Makefile),Makefile)
- @mkdir src/
- $(call render_template,$(bs_appsrc),src/$(PROJECT).app.src)
- $(call render_template,$(bs_app),src/$(PROJECT)_app.erl)
- $(eval n := $(PROJECT)_sup)
- $(call render_template,$(tpl_supervisor),src/$(PROJECT)_sup.erl)
-
-bootstrap-lib:
-ifneq ($(wildcard src/),)
- $(error Error: src/ directory already exists)
-endif
- $(call render_template,$(bs_Makefile),Makefile)
- @mkdir src/
- $(call render_template,$(bs_appsrc_lib),src/$(PROJECT).app.src)
-
-bootstrap-rel:
-ifneq ($(wildcard relx.config),)
- $(error Error: relx.config already exists)
-endif
-ifneq ($(wildcard rel/),)
- $(error Error: rel/ directory already exists)
-endif
- $(call render_template,$(bs_relx_config),relx.config)
- @mkdir rel/
- $(call render_template,$(bs_sys_config),rel/sys.config)
- $(call render_template,$(bs_vm_args),rel/vm.args)
-
-new:
-ifeq ($(wildcard src/),)
- $(error Error: src/ directory does not exist)
-endif
-ifndef t
- $(error Usage: make new t=TEMPLATE n=NAME)
-endif
-ifndef tpl_$(t)
- $(error Unknown template)
-endif
-ifndef n
- $(error Usage: make new t=TEMPLATE n=NAME)
-endif
- $(call render_template,$(tpl_$(t)),src/$(n).erl)
-
-list-templates:
- @echo Available templates: $(sort $(patsubst tpl_%,%,$(filter tpl_%,$(.VARIABLES))))
-
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
-# This file is part of erlang.mk and subject to the terms of the ISC License.
-
-.PHONY: build-ct-deps build-ct-suites tests-ct clean-ct distclean-ct
-
-# Configuration.
-
-CT_OPTS ?=
-ifneq ($(wildcard test/),)
- CT_SUITES ?= $(sort $(subst _SUITE.erl,,$(shell find test -type f -name \*_SUITE.erl -exec basename {} \;)))
-else
- CT_SUITES ?=
-endif
-
-TEST_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard
-TEST_ERLC_OPTS += -DTEST=1 -DEXTRA=1 +'{parse_transform, eunit_autoexport}'
-
-# Core targets.
-
-tests:: tests-ct
-
-clean:: clean-ct
-
-distclean:: distclean-ct
-
-help::
- @printf "%s\n" "" \
- "All your common_test suites have their associated targets." \
- "A suite named http_SUITE can be ran using the ct-http target."
-
-# Plugin-specific targets.
-
-ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS))
-
-CT_RUN = ct_run \
- -no_auto_compile \
- -noshell \
- -pa $(realpath ebin) $(DEPS_DIR)/*/ebin \
- -dir test \
- -logdir logs
-
-$(foreach dep,$(TEST_DEPS),$(eval $(call dep_target,$(dep))))
-
-build-ct-deps: $(ALL_TEST_DEPS_DIRS)
- @for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
-
-build-ct-suites: build-ct-deps
- $(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -o test/ \
- $(wildcard test/*.erl test/*/*.erl) -pa ebin/
-
-tests-ct: ERLC_OPTS = $(TEST_ERLC_OPTS)
-tests-ct: clean deps app build-ct-suites
- @if [ -d "test" ] ; \
- then \
- mkdir -p logs/ ; \
- $(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS) ; \
- fi
- $(gen_verbose) rm -f test/*.beam
-
-define ct_suite_target
-ct-$(1): ERLC_OPTS = $(TEST_ERLC_OPTS)
-ct-$(1): clean deps app build-ct-suites
- @if [ -d "test" ] ; \
- then \
- mkdir -p logs/ ; \
- $(CT_RUN) -suite $(addsuffix _SUITE,$(1)) $(CT_OPTS) ; \
- fi
- $(gen_verbose) rm -f test/*.beam
-endef
-
-$(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
-
-clean-ct:
- $(gen_verbose) rm -rf test/*.beam
-
-distclean-ct:
- $(gen_verbose) rm -rf logs/
-
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
-# This file is part of erlang.mk and subject to the terms of the ISC License.
-
-.PHONY: plt distclean-plt dialyze
-
-# Configuration.
-
-DIALYZER_PLT ?= $(CURDIR)/.$(PROJECT).plt
-export DIALYZER_PLT
-
-PLT_APPS ?=
-DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions \
- -Wunmatched_returns # -Wunderspecs
-
-# Core targets.
-
-distclean:: distclean-plt
-
-help::
- @printf "%s\n" "" \
- "Dialyzer targets:" \
- " plt Build a PLT file for this project" \
- " dialyze Analyze the project using Dialyzer"
-
-# Plugin-specific targets.
-
-plt: deps app
- @dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(ALL_DEPS_DIRS)
-
-distclean-plt:
- $(gen_verbose) rm -f $(DIALYZER_PLT)
-
-dialyze:
- @dialyzer --no_native --src -r src $(DIALYZER_OPTS)
-
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
-# This file is part of erlang.mk and subject to the terms of the ISC License.
-
-# Verbosity.
-
-dtl_verbose_0 = @echo " DTL " $(filter %.dtl,$(?F));
-dtl_verbose = $(dtl_verbose_$(V))
-
-# Core targets.
-
-define compile_erlydtl
- $(dtl_verbose) erl -noshell -pa ebin/ $(DEPS_DIR)/erlydtl/ebin/ -eval ' \
- Compile = fun(F) -> \
- Module = list_to_atom( \
- string:to_lower(filename:basename(F, ".dtl")) ++ "_dtl"), \
- erlydtl:compile(F, Module, [{out_dir, "ebin/"}]) \
- end, \
- _ = [Compile(F) || F <- string:tokens("$(1)", " ")], \
- init:stop()'
-endef
-
-ifneq ($(wildcard src/),)
-ebin/$(PROJECT).app:: $(shell find templates -type f -name \*.dtl 2>/dev/null)
- $(if $(strip $?),$(call compile_erlydtl,$?))
-endif
-
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
-# This file is part of erlang.mk and subject to the terms of the ISC License.
-
-.PHONY: distclean-edoc
-
-# Configuration.
-
-EDOC_OPTS ?=
-
-# Core targets.
-
-docs:: distclean-edoc
- $(gen_verbose) erl -noshell \
- -eval 'edoc:application($(PROJECT), ".", [$(EDOC_OPTS)]), init:stop().'
-
-distclean:: distclean-edoc
-
-# Plugin-specific targets.
-
-distclean-edoc:
- $(gen_verbose) rm -f doc/*.css doc/*.html doc/*.png doc/edoc-info
-
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
-# This file is part of erlang.mk and subject to the terms of the ISC License.
-
-.PHONY: distclean-rel
-
-# Configuration.
-
-RELX_CONFIG ?= $(CURDIR)/relx.config
-
-ifneq ($(wildcard $(RELX_CONFIG)),)
-
-RELX ?= $(CURDIR)/relx
-export RELX
-
-RELX_URL ?= https://github.com/erlware/relx/releases/download/v1.0.2/relx
-RELX_OPTS ?=
-RELX_OUTPUT_DIR ?= _rel
-
-ifeq ($(firstword $(RELX_OPTS)),-o)
- RELX_OUTPUT_DIR = $(word 2,$(RELX_OPTS))
-endif
-
-# Core targets.
-
-rel:: distclean-rel $(RELX)
- @$(RELX) -c $(RELX_CONFIG) $(RELX_OPTS)
-
-distclean:: distclean-rel distclean-relx
-
-# Plugin-specific targets.
-
-define relx_fetch
- $(call core_http_get,$(RELX),$(RELX_URL))
- chmod +x $(RELX)
-endef
-
-$(RELX):
- @$(call relx_fetch)
-
-distclean-rel:
- $(gen_verbose) rm -rf $(RELX_OUTPUT_DIR)
-
-distclean-relx:
- $(gen_verbose) rm -rf $(RELX)
-
-endif
+.PHONY: bootstrap
+bootstrap: ;
diff --git a/packages.v1.tsv b/packages.v1.tsv
index 0b2f7d6..b61a607 100644
--- a/packages.v1.tsv
+++ b/packages.v1.tsv
@@ -1,16 +1,67 @@
+apns4erl https://github.com/inaka/apns4erl.git http://inaka.github.com/apns4erl Apple Push Notification Server for Erlang
bullet https://github.com/extend/bullet http://ninenines.eu Simple, reliable, efficient streaming for Cowboy.
+cake https://github.com/darach/cake-erl https://github.com/darach/cake-erl Really simple terminal colorization
+classifier https://github.com/inaka/classifier.git https://github.com/inaka/classifier An Erlang Bayesian Filter and Text Classifier
cowboy https://github.com/ninenines/cowboy http://ninenines.eu Small, fast and modular HTTP server.
cowlib https://github.com/ninenines/cowlib http://ninenines.eu Support library for manipulating Web protocols.
+czmq https://github.com/gar1t/erlang-czmq.git https://github.com/gar1t/erlang-czmq External port bindings for CZMQ.
+debbie https://github.com/crownedgrouse/debbie.git https://github.com/crownedgrouse/debbie .DEB Built In Erlang
+e2 https://github.com/gar1t/e2.git http://e2project.org Library to simply writing correct OTP applications.
+ebitly https://github.com/inaka/ebitly.git http://inaka.github.com/ebitly Bit.ly API wrapper for Erlang
+edgar https://github.com/crownedgrouse/edgar.git https://github.com/crownedgrouse/edgar Erlang Does GNU AR
+edis https://github.com/inaka/edis.git http://inaka.github.com/edis/ An Erlang implementation of Redis KV Store
+eganglia https://github.com/inaka/eganglia.git https://github.com/inaka/eganglia.git Erlang library to interact with Ganglia
+ehsa https://bitbucket.org/a12n/ehsa https://bitbucket.org/a12n/ehsa Erlang HTTP server basic and digest authentication modules
+elvis https://github.com/inaka/elvis.git https://github.com/inaka/elvis.git Erlang Style Reviewer
+emysql https://github.com/Eonblast/Emysql.git https://github.com/Eonblast/Emysql Stable, pure Erlang MySQL driver.
eper https://github.com/massemanet/eper https://github.com/massemanet/eper Erlang performance and debugging tools.
epgsql https://github.com/epgsql/epgsql https://github.com/epgsql/epgsql Erlang PostgreSQL client library.
+eredis https://github.com/wooga/eredis https://github.com/wooga/eredis Non-blocking Redis client with focus on performance and robustness
+erldb https://github.com/erldb/erldb.git http://erldb.org ORM (Object-relational mapping) application implemented in Erlang
+erlexec https://github.com/saleyn/erlexec http://saleyn.github.com/erlexec Execute and control OS processes from Erlang/OTP.
erlydtl https://github.com/erlydtl/erlydtl https://github.com/erlydtl/erlydtl Django Template Language for Erlang.
+erwa https://github.com/bwegh/erwa https://github.com/bwegh/erwa A WAMP router and client written in Erlang.
+exs1024 https://github.com/jj1bdx/exs1024 https://github.com/jj1bdx/exs1024 Xorshift1024star pseudo random number generator for Erlang.
+exs64 https://github.com/jj1bdx/exs64 https://github.com/jj1bdx/exs64 Xorshift64star pseudo random number generator for Erlang.
+exsplus128 https://github.com/jj1bdx/exsplus128 https://github.com/jj1bdx/exsplus128 Xorshift128plus pseudo random number generator for Erlang.
+feeder https://github.com/michaelnisi/feeder https://github.com/michaelnisi/feeder Stream parse RSS and Atom formatted XML feeds.
+geas https://github.com/crownedgrouse/geas.git https://github.com/crownedgrouse/geas Guess Erlang Application Scattering
+getopt https://github.com/jcomellas/getopt.git https://github.com/jcomellas/getopt Module to parse command line arguments using the GNU getopt syntax
+gproc https://github.com/uwiger/gproc.git https://github.com/uwiger/gproc Extended process registry for Erlang
gun https://github.com/extend/gun http//ninenines.eu Asynchronous SPDY, HTTP and Websocket client written in Erlang.
+hanoidb https://github.com/krestenkrab/hanoidb https://github.com/krestenkrab/hanoidb Erlang LSM BTree Storage
+ibrowse https://github.com/cmullaparthi/ibrowse https://github.com/cmullaparthi/ibrowse Erlang HTTP client
+itweet https://github.com/inaka/itweet.git http://inaka.github.com/itweet/ Twitter Stream API on ibrowse
jiffy https://github.com/davisp/jiffy https://github.com/davisp/jiffy JSON NIFs for Erlang.
+jiffy_v https://github.com/shizzard/jiffy-v https://github.com/shizzard/jiffy-v JSON validation utility
+jobs https://github.com/esl/jobs https://github.com/esl/jobs a Job scheduler for load regulation
jsx https://github.com/talentdeficit/jsx https://github.com/talentdeficit/jsx An Erlang application for consuming, producing and manipulating JSON.
+katja https://github.com/nifoc/katja https://github.com/nifoc/katja A simple Riemann client written in Erlang.
lager https://github.com/basho/lager https://github.com/basho/lager A logging framework for Erlang/OTP.
+lasse https://github.com/inaka/lasse.git https://github.com/inaka/lasse.git SSE handler for Cowboy
+leptus https://github.com/s1n4/leptus https://github.com/s1n4/leptus Erlang REST framework
+live https://github.com/ninenines/live http://ninenines.eu Automated module and configuration reloader.
+mekao https://github.com/ddosia/mekao.git https://github.com/ddosia/mekao SQL constructor
+modlib https://github.com/gar1t/modlib.git https://github.com/gar1t/modlib Web framework based on Erlang's inets httpd
neo4j https://github.com/dmitriid/neo4j-erlang https://github.com/dmitriid/neo4j-erlang Erlang client library for Neo4J.
+nodefinder https://github.com/erlanger/nodefinder.git https://github.com/erlanger/nodefinder automatic node discovery via UDP multicast
pegjs https://github.com/dmitriid/pegjs https://github.com/dmitriid/pegjs An implementation of PEG.js grammar for Erlang.
proper https://github.com/manopapad/proper http://proper.softlab.ntua.gr PropEr: a QuickCheck-inspired property-based testing tool for Erlang.
+psycho https://github.com/gar1t/psycho.git https://github.com/gar1t/psycho HTTP server that provides a WSGI-like interface for applications and middleware.
+ptrackerl https://github.com/inaka/ptrackerl.git https://github.com/inaka/ptrackerl.git Pivotal Tracker API Client written in Erlang
+pusherman https://github.com/inaka/pusherman.git https://github.com/inaka/pusherman.git queuing system for push notifications
ranch https://github.com/ninenines/ranch http://ninenines.eu Socket acceptor pool for TCP protocols.
resource_discovery https://github.com/erlware/resource_discovery http://erlware.org/ An application used to dynamically discover resources present in an Erlang node cluster.
+sfmt-erlang https://github.com/jj1bdx/sfmt-erlang https://github.com/jj1bdx/sfmt-erlang SFMT pseudo random number generator for Erlang.
sheriff https://github.com/extend/sheriff http://ninenines.eu Parse transform for type based validation.
+shotgun https://github.com/inaka/shotgun.git https://github.com/inaka/shotgun.git better than just a gun
+sumo_db https://github.com/inaka/sumo_db.git https://github.com/inaka/sumo_db.git Erlang Persistency Framework
+swab https://github.com/crownedgrouse/swab.git https://github.com/crownedgrouse/swab General purpose buffer handling module
+sync https://github.com/rustyio/sync.git https://github.com/rustyio/sync On-the-fly recompiling and reloading in Erlang.
+tddreloader https://github.com/version2beta/tddreloader https://github.com/version2beta/tddreloader Shell utility for recompiling, reloading, and testing code as it changes
+tinymt-erlang https://github.com/jj1bdx/tinymt-erlang https://github.com/jj1bdx/tinymt-erlang TinyMT pseudo random number generator for Erlang.
+unicorn https://github.com/shizzard/unicorn https://github.com/shizzard/unicorn Generic configuration server
+uuid https://github.com/okeuday/uuid https://github.com/okeuday/uuid Erlang UUID Implementation
+worker_pool https://github.com/inaka/worker_pool.git https://github.com/inaka/worker_pool a simple erlang worker pool
+xref_runner https://github.com/inaka/xref_runner.git https://github.com/inaka/xref_runner.git Erlang Xref Runner (inspired in rebar xref)
+zeta https://github.com/s1n4/zeta https://github.com/s1n4/zeta HTTP access log parser in Erlang
diff --git a/packages.v1.txt b/packages.v1.txt
index 0b2f7d6..b61a607 100644
--- a/packages.v1.txt
+++ b/packages.v1.txt
@@ -1,16 +1,67 @@
+apns4erl https://github.com/inaka/apns4erl.git http://inaka.github.com/apns4erl Apple Push Notification Server for Erlang
bullet https://github.com/extend/bullet http://ninenines.eu Simple, reliable, efficient streaming for Cowboy.
+cake https://github.com/darach/cake-erl https://github.com/darach/cake-erl Really simple terminal colorization
+classifier https://github.com/inaka/classifier.git https://github.com/inaka/classifier An Erlang Bayesian Filter and Text Classifier
cowboy https://github.com/ninenines/cowboy http://ninenines.eu Small, fast and modular HTTP server.
cowlib https://github.com/ninenines/cowlib http://ninenines.eu Support library for manipulating Web protocols.
+czmq https://github.com/gar1t/erlang-czmq.git https://github.com/gar1t/erlang-czmq External port bindings for CZMQ.
+debbie https://github.com/crownedgrouse/debbie.git https://github.com/crownedgrouse/debbie .DEB Built In Erlang
+e2 https://github.com/gar1t/e2.git http://e2project.org Library to simply writing correct OTP applications.
+ebitly https://github.com/inaka/ebitly.git http://inaka.github.com/ebitly Bit.ly API wrapper for Erlang
+edgar https://github.com/crownedgrouse/edgar.git https://github.com/crownedgrouse/edgar Erlang Does GNU AR
+edis https://github.com/inaka/edis.git http://inaka.github.com/edis/ An Erlang implementation of Redis KV Store
+eganglia https://github.com/inaka/eganglia.git https://github.com/inaka/eganglia.git Erlang library to interact with Ganglia
+ehsa https://bitbucket.org/a12n/ehsa https://bitbucket.org/a12n/ehsa Erlang HTTP server basic and digest authentication modules
+elvis https://github.com/inaka/elvis.git https://github.com/inaka/elvis.git Erlang Style Reviewer
+emysql https://github.com/Eonblast/Emysql.git https://github.com/Eonblast/Emysql Stable, pure Erlang MySQL driver.
eper https://github.com/massemanet/eper https://github.com/massemanet/eper Erlang performance and debugging tools.
epgsql https://github.com/epgsql/epgsql https://github.com/epgsql/epgsql Erlang PostgreSQL client library.
+eredis https://github.com/wooga/eredis https://github.com/wooga/eredis Non-blocking Redis client with focus on performance and robustness
+erldb https://github.com/erldb/erldb.git http://erldb.org ORM (Object-relational mapping) application implemented in Erlang
+erlexec https://github.com/saleyn/erlexec http://saleyn.github.com/erlexec Execute and control OS processes from Erlang/OTP.
erlydtl https://github.com/erlydtl/erlydtl https://github.com/erlydtl/erlydtl Django Template Language for Erlang.
+erwa https://github.com/bwegh/erwa https://github.com/bwegh/erwa A WAMP router and client written in Erlang.
+exs1024 https://github.com/jj1bdx/exs1024 https://github.com/jj1bdx/exs1024 Xorshift1024star pseudo random number generator for Erlang.
+exs64 https://github.com/jj1bdx/exs64 https://github.com/jj1bdx/exs64 Xorshift64star pseudo random number generator for Erlang.
+exsplus128 https://github.com/jj1bdx/exsplus128 https://github.com/jj1bdx/exsplus128 Xorshift128plus pseudo random number generator for Erlang.
+feeder https://github.com/michaelnisi/feeder https://github.com/michaelnisi/feeder Stream parse RSS and Atom formatted XML feeds.
+geas https://github.com/crownedgrouse/geas.git https://github.com/crownedgrouse/geas Guess Erlang Application Scattering
+getopt https://github.com/jcomellas/getopt.git https://github.com/jcomellas/getopt Module to parse command line arguments using the GNU getopt syntax
+gproc https://github.com/uwiger/gproc.git https://github.com/uwiger/gproc Extended process registry for Erlang
gun https://github.com/extend/gun http//ninenines.eu Asynchronous SPDY, HTTP and Websocket client written in Erlang.
+hanoidb https://github.com/krestenkrab/hanoidb https://github.com/krestenkrab/hanoidb Erlang LSM BTree Storage
+ibrowse https://github.com/cmullaparthi/ibrowse https://github.com/cmullaparthi/ibrowse Erlang HTTP client
+itweet https://github.com/inaka/itweet.git http://inaka.github.com/itweet/ Twitter Stream API on ibrowse
jiffy https://github.com/davisp/jiffy https://github.com/davisp/jiffy JSON NIFs for Erlang.
+jiffy_v https://github.com/shizzard/jiffy-v https://github.com/shizzard/jiffy-v JSON validation utility
+jobs https://github.com/esl/jobs https://github.com/esl/jobs a Job scheduler for load regulation
jsx https://github.com/talentdeficit/jsx https://github.com/talentdeficit/jsx An Erlang application for consuming, producing and manipulating JSON.
+katja https://github.com/nifoc/katja https://github.com/nifoc/katja A simple Riemann client written in Erlang.
lager https://github.com/basho/lager https://github.com/basho/lager A logging framework for Erlang/OTP.
+lasse https://github.com/inaka/lasse.git https://github.com/inaka/lasse.git SSE handler for Cowboy
+leptus https://github.com/s1n4/leptus https://github.com/s1n4/leptus Erlang REST framework
+live https://github.com/ninenines/live http://ninenines.eu Automated module and configuration reloader.
+mekao https://github.com/ddosia/mekao.git https://github.com/ddosia/mekao SQL constructor
+modlib https://github.com/gar1t/modlib.git https://github.com/gar1t/modlib Web framework based on Erlang's inets httpd
neo4j https://github.com/dmitriid/neo4j-erlang https://github.com/dmitriid/neo4j-erlang Erlang client library for Neo4J.
+nodefinder https://github.com/erlanger/nodefinder.git https://github.com/erlanger/nodefinder automatic node discovery via UDP multicast
pegjs https://github.com/dmitriid/pegjs https://github.com/dmitriid/pegjs An implementation of PEG.js grammar for Erlang.
proper https://github.com/manopapad/proper http://proper.softlab.ntua.gr PropEr: a QuickCheck-inspired property-based testing tool for Erlang.
+psycho https://github.com/gar1t/psycho.git https://github.com/gar1t/psycho HTTP server that provides a WSGI-like interface for applications and middleware.
+ptrackerl https://github.com/inaka/ptrackerl.git https://github.com/inaka/ptrackerl.git Pivotal Tracker API Client written in Erlang
+pusherman https://github.com/inaka/pusherman.git https://github.com/inaka/pusherman.git queuing system for push notifications
ranch https://github.com/ninenines/ranch http://ninenines.eu Socket acceptor pool for TCP protocols.
resource_discovery https://github.com/erlware/resource_discovery http://erlware.org/ An application used to dynamically discover resources present in an Erlang node cluster.
+sfmt-erlang https://github.com/jj1bdx/sfmt-erlang https://github.com/jj1bdx/sfmt-erlang SFMT pseudo random number generator for Erlang.
sheriff https://github.com/extend/sheriff http://ninenines.eu Parse transform for type based validation.
+shotgun https://github.com/inaka/shotgun.git https://github.com/inaka/shotgun.git better than just a gun
+sumo_db https://github.com/inaka/sumo_db.git https://github.com/inaka/sumo_db.git Erlang Persistency Framework
+swab https://github.com/crownedgrouse/swab.git https://github.com/crownedgrouse/swab General purpose buffer handling module
+sync https://github.com/rustyio/sync.git https://github.com/rustyio/sync On-the-fly recompiling and reloading in Erlang.
+tddreloader https://github.com/version2beta/tddreloader https://github.com/version2beta/tddreloader Shell utility for recompiling, reloading, and testing code as it changes
+tinymt-erlang https://github.com/jj1bdx/tinymt-erlang https://github.com/jj1bdx/tinymt-erlang TinyMT pseudo random number generator for Erlang.
+unicorn https://github.com/shizzard/unicorn https://github.com/shizzard/unicorn Generic configuration server
+uuid https://github.com/okeuday/uuid https://github.com/okeuday/uuid Erlang UUID Implementation
+worker_pool https://github.com/inaka/worker_pool.git https://github.com/inaka/worker_pool a simple erlang worker pool
+xref_runner https://github.com/inaka/xref_runner.git https://github.com/inaka/xref_runner.git Erlang Xref Runner (inspired in rebar xref)
+zeta https://github.com/s1n4/zeta https://github.com/s1n4/zeta HTTP access log parser in Erlang
diff --git a/packages.v2.tsv b/packages.v2.tsv
index 8d7554c..6dca150 100644
--- a/packages.v2.tsv
+++ b/packages.v2.tsv
@@ -1,16 +1,67 @@
+apns4erl git https://github.com/inaka/apns4erl.git 1.0 http://inaka.github.com/apns4erl Apple Push Notification Server for Erlang
bullet git https://github.com/extend/bullet master http://ninenines.eu Simple, reliable, efficient streaming for Cowboy.
-cowboy git https://github.com/ninenines/cowboy 1.0.0 http://ninenines.eu Small, fast and modular HTTP server.
-cowlib git https://github.com/ninenines/cowlib 1.0.0 http://ninenines.eu Support library for manipulating Web protocols.
+cake git https://github.com/darach/cake-erl v0.1.2 https://github.com/darach/cake-erl Really simple terminal colorization
+classifier git https://github.com/inaka/classifier.git 1 https://github.com/inaka/classifier An Erlang Bayesian Filter and Text Classifier
+cowboy git https://github.com/ninenines/cowboy 1.0.1 http://ninenines.eu Small, fast and modular HTTP server.
+cowlib git https://github.com/ninenines/cowlib 1.0.1 http://ninenines.eu Support library for manipulating Web protocols.
+czmq git https://github.com/gar1t/erlang-czmq.git master https://github.com/gar1t/erlang-czmq External port bindings for CZMQ.
+debbie git https://github.com/crownedgrouse/debbie.git master https://github.com/crownedgrouse/debbie .DEB Built In Erlang
+e2 git https://github.com/gar1t/e2.git master http://e2project.org Library to simply writing correct OTP applications.
+ebitly git https://github.com/inaka/ebitly.git 0.0.1 http://inaka.github.com/ebitly Bit.ly API wrapper for Erlang
+edgar git https://github.com/crownedgrouse/edgar.git master https://github.com/crownedgrouse/edgar Erlang Does GNU AR
+edis git https://github.com/inaka/edis.git 0.2.0 http://inaka.github.com/edis/ An Erlang implementation of Redis KV Store
+eganglia git https://github.com/inaka/eganglia.git 0.9.1 https://github.com/inaka/eganglia.git Erlang library to interact with Ganglia
+ehsa hg https://bitbucket.org/a12n/ehsa 2.0.4 https://bitbucket.org/a12n/ehsa Erlang HTTP server basic and digest authentication modules
+elvis git https://github.com/inaka/elvis.git 0.1.0-alpha https://github.com/inaka/elvis.git Erlang Style Reviewer
+emysql git https://github.com/Eonblast/Emysql.git master https://github.com/Eonblast/Emysql Stable, pure Erlang MySQL driver.
eper git https://github.com/massemanet/eper master https://github.com/massemanet/eper Erlang performance and debugging tools.
epgsql git https://github.com/epgsql/epgsql master https://github.com/epgsql/epgsql Erlang PostgreSQL client library.
+eredis git https://github.com/wooga/eredis master https://github.com/wooga/eredis Non-blocking Redis client with focus on performance and robustness
+erldb git https://github.com/erldb/erldb.git master http://erldb.org ORM (Object-relational mapping) application implemented in Erlang
+erlexec git https://github.com/saleyn/erlexec master http://saleyn.github.com/erlexec Execute and control OS processes from Erlang/OTP.
erlydtl git https://github.com/erlydtl/erlydtl master https://github.com/erlydtl/erlydtl Django Template Language for Erlang.
+erwa git https://github.com/bwegh/erwa 0.1.1 https://github.com/bwegh/erwa A WAMP router and client written in Erlang.
+exs1024 git https://github.com/jj1bdx/exs1024 master https://github.com/jj1bdx/exs1024 Xorshift1024star pseudo random number generator for Erlang.
+exs64 git https://github.com/jj1bdx/exs64 master https://github.com/jj1bdx/exs64 Xorshift64star pseudo random number generator for Erlang.
+exsplus128 git https://github.com/jj1bdx/exsplus128 master https://github.com/jj1bdx/exsplus128 Xorshift128plus pseudo random number generator for Erlang.
+feeder git https://github.com/michaelnisi/feeder 1.4.2 https://github.com/michaelnisi/feeder Stream parse RSS and Atom formatted XML feeds.
+geas git https://github.com/crownedgrouse/geas.git master https://github.com/crownedgrouse/geas Guess Erlang Application Scattering
+getopt git https://github.com/jcomellas/getopt.git master https://github.com/jcomellas/getopt Module to parse command line arguments using the GNU getopt syntax
+gproc git https://github.com/uwiger/gproc.git master https://github.com/uwiger/gproc Extended process registry for Erlang
gun git https://github.com/extend/gun master http//ninenines.eu Asynchronous SPDY, HTTP and Websocket client written in Erlang.
+hanoidb git https://github.com/krestenkrab/hanoidb master https://github.com/krestenkrab/hanoidb Erlang LSM BTree Storage
+ibrowse git https://github.com/cmullaparthi/ibrowse v4.1.1 https://github.com/cmullaparthi/ibrowse Erlang HTTP client
+itweet git https://github.com/inaka/itweet.git 3.0 http://inaka.github.com/itweet/ Twitter Stream API on ibrowse
jiffy git https://github.com/davisp/jiffy master https://github.com/davisp/jiffy JSON NIFs for Erlang.
+jiffy_v git https://github.com/shizzard/jiffy-v 0.3.3 https://github.com/shizzard/jiffy-v JSON validation utility
+jobs git https://github.com/esl/jobs 0.3 https://github.com/esl/jobs a Job scheduler for load regulation
jsx git https://github.com/talentdeficit/jsx master https://github.com/talentdeficit/jsx An Erlang application for consuming, producing and manipulating JSON.
+katja git https://github.com/nifoc/katja master https://github.com/nifoc/katja A simple Riemann client written in Erlang.
lager git https://github.com/basho/lager master https://github.com/basho/lager A logging framework for Erlang/OTP.
+lasse git https://github.com/inaka/lasse.git 0.1.0 https://github.com/inaka/lasse.git SSE handler for Cowboy
+leptus git https://github.com/s1n4/leptus https://github.com/s1n4/leptus Erlang REST framework
+live git https://github.com/ninenines/live master http://ninenines.eu Automated module and configuration reloader.
+mekao git https://github.com/ddosia/mekao.git master https://github.com/ddosia/mekao SQL constructor
+modlib git https://github.com/gar1t/modlib.git master https://github.com/gar1t/modlib Web framework based on Erlang's inets httpd
neo4j git https://github.com/dmitriid/neo4j-erlang master https://github.com/dmitriid/neo4j-erlang Erlang client library for Neo4J.
-pegjs git https://github.com/dmitriid/pegjs 0.2.1 https://github.com/dmitriid/pegjs An implementation of PEG.js grammar for Erlang.
+nodefinder git https://github.com/erlanger/nodefinder.git 0.2.3 https://github.com/erlanger/nodefinder automatic node discovery via UDP multicast
+pegjs git https://github.com/dmitriid/pegjs 0.3 https://github.com/dmitriid/pegjs An implementation of PEG.js grammar for Erlang.
proper git https://github.com/manopapad/proper master http://proper.softlab.ntua.gr PropEr: a QuickCheck-inspired property-based testing tool for Erlang.
-ranch git https://github.com/ninenines/ranch 1.0.0 http://ninenines.eu Socket acceptor pool for TCP protocols.
+psycho git https://github.com/gar1t/psycho.git master https://github.com/gar1t/psycho HTTP server that provides a WSGI-like interface for applications and middleware.
+ptrackerl git https://github.com/inaka/ptrackerl.git 0.2 https://github.com/inaka/ptrackerl.git Pivotal Tracker API Client written in Erlang
+pusherman git https://github.com/inaka/pusherman.git 1 https://github.com/inaka/pusherman.git queuing system for push notifications
+ranch git https://github.com/ninenines/ranch 1.1.0 http://ninenines.eu Socket acceptor pool for TCP protocols.
resource_discovery git https://github.com/erlware/resource_discovery master http://erlware.org/ An application used to dynamically discover resources present in an Erlang node cluster.
+sfmt-erlang git https://github.com/jj1bdx/sfmt-erlang master https://github.com/jj1bdx/sfmt-erlang SFMT pseudo random number generator for Erlang.
sheriff git https://github.com/extend/sheriff master http://ninenines.eu Parse transform for type based validation.
+shotgun git https://github.com/inaka/shotgun.git 0.1.0 https://github.com/inaka/shotgun.git better than just a gun
+sumo_db git https://github.com/inaka/sumo_db.git 1 https://github.com/inaka/sumo_db.git Erlang Persistency Framework
+swab git https://github.com/crownedgrouse/swab.git master https://github.com/crownedgrouse/swab General purpose buffer handling module
+sync git https://github.com/rustyio/sync.git master https://github.com/rustyio/sync On-the-fly recompiling and reloading in Erlang.
+tddreloader git https://github.com/version2beta/tddreloader master https://github.com/version2beta/tddreloader Shell utility for recompiling, reloading, and testing code as it changes
+tinymt-erlang git https://github.com/jj1bdx/tinymt-erlang master https://github.com/jj1bdx/tinymt-erlang TinyMT pseudo random number generator for Erlang.
+unicorn git https://github.com/shizzard/unicorn 0.3.0 https://github.com/shizzard/unicorn Generic configuration server
+uuid git https://github.com/okeuday/uuid v1.4.0 https://github.com/okeuday/uuid Erlang UUID Implementation
+worker_pool git https://github.com/inaka/worker_pool.git 1.0.2 https://github.com/inaka/worker_pool a simple erlang worker pool
+xref_runner git https://github.com/inaka/xref_runner.git 0.2.0 https://github.com/inaka/xref_runner.git Erlang Xref Runner (inspired in rebar xref)
+zeta git https://github.com/s1n4/zeta https://github.com/s1n4/zeta HTTP access log parser in Erlang
diff --git a/pkg_add.sh b/pkg_add.sh
new file mode 100755
index 0000000..9c26baa
--- /dev/null
+++ b/pkg_add.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+PKG_FILE="packages.v2.tsv"
+LINE="$1\t$2\t$3\t$4\t$5\t$6\n"
+COMMIT="Add package $1 to the index"
+
+printf "$LINE" >> $PKG_FILE
+sort $PKG_FILE -o $PKG_FILE
+make
+git commit -m "$COMMIT" packages.*
diff --git a/plugins/asciidoc.mk b/plugins/asciidoc.mk
new file mode 100644
index 0000000..baf4d3b
--- /dev/null
+++ b/plugins/asciidoc.mk
@@ -0,0 +1,46 @@
+# Copyright (c) 2015, Loïc Hoguin <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: asciidoc asciidoc-guide asciidoc-manual install-asciidoc distclean-asciidoc
+
+MAN_INSTALL_PATH ?= /usr/local/share/man
+MAN_SECTIONS ?= 3 7
+
+docs:: asciidoc
+
+asciidoc: distclean-asciidoc doc-deps asciidoc-guide asciidoc-manual
+
+ifeq ($(wildcard doc/src/guide/book.asciidoc),)
+asciidoc-guide:
+else
+asciidoc-guide:
+ a2x -v -f pdf doc/src/guide/book.asciidoc && mv doc/src/guide/book.pdf doc/guide.pdf
+ a2x -v -f chunked doc/src/guide/book.asciidoc && mv doc/src/guide/book.chunked/ doc/html/
+endif
+
+ifeq ($(wildcard doc/src/manual/*.asciidoc),)
+asciidoc-manual:
+else
+asciidoc-manual:
+ for f in doc/src/manual/*.asciidoc ; do \
+ a2x -v -f manpage $$f ; \
+ done
+ for s in $(MAN_SECTIONS); do \
+ mkdir -p doc/man$$s/ ; \
+ mv doc/src/manual/*.$$s doc/man$$s/ ; \
+ gzip doc/man$$s/*.$$s ; \
+ done
+
+install-docs:: install-asciidoc
+
+install-asciidoc: asciidoc-manual
+ for s in $(MAN_SECTIONS); do \
+ mkdir -p $(MAN_INSTALL_PATH)/man$$s/ ; \
+ install -g 0 -o 0 -m 0644 doc/man$$s/*.gz $(MAN_INSTALL_PATH)/man$$s/ ; \
+ done
+endif
+
+distclean:: distclean-asciidoc
+
+distclean-asciidoc:
+ $(gen_verbose) rm -rf doc/html/ doc/guide.pdf doc/man3/ doc/man7/
diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk
index 41b5fa7..6494180 100644
--- a/plugins/bootstrap.mk
+++ b/plugins/bootstrap.mk
@@ -1,4 +1,4 @@
-# Copyright (c) 2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2014-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
.PHONY: bootstrap bootstrap-lib bootstrap-rel new list-templates
@@ -20,6 +20,7 @@ define bs_appsrc
{application, $(PROJECT), [
{description, ""},
{vsn, "0.1.0"},
+ {id, "git"},
{modules, []},
{registered, []},
{applications, [
@@ -35,6 +36,7 @@ define bs_appsrc_lib
{application, $(PROJECT), [
{description, ""},
{vsn, "0.1.0"},
+ {id, "git"},
{modules, []},
{registered, []},
{applications, [
@@ -82,6 +84,7 @@ define bs_vm_args
endef
# Normal templates.
+
define tpl_supervisor
-module($(n)).
-behaviour(supervisor).
@@ -164,6 +167,59 @@ terminate(_Reason, _Req, _State) ->
ok.
endef
+define tpl_gen_fsm
+-module($(n)).
+-behaviour(gen_fsm).
+
+%% API.
+-export([start_link/0]).
+
+%% gen_fsm.
+-export([init/1]).
+-export([state_name/2]).
+-export([handle_event/3]).
+-export([state_name/3]).
+-export([handle_sync_event/4]).
+-export([handle_info/3]).
+-export([terminate/3]).
+-export([code_change/4]).
+
+-record(state, {
+}).
+
+%% API.
+
+-spec start_link() -> {ok, pid()}.
+start_link() ->
+ gen_fsm:start_link(?MODULE, [], []).
+
+%% gen_fsm.
+
+init([]) ->
+ {ok, state_name, #state{}}.
+
+state_name(_Event, StateData) ->
+ {next_state, state_name, StateData}.
+
+handle_event(_Event, StateName, StateData) ->
+ {next_state, StateName, StateData}.
+
+state_name(_Event, _From, StateData) ->
+ {reply, ignored, state_name, StateData}.
+
+handle_sync_event(_Event, _From, StateName, StateData) ->
+ {reply, ignored, StateName, StateData}.
+
+handle_info(_Info, StateName, StateData) ->
+ {next_state, StateName, StateData}.
+
+terminate(_Reason, _StateName, _StateData) ->
+ ok.
+
+code_change(_OldVsn, StateName, StateData, _Extra) ->
+ {ok, StateName, StateData}.
+endef
+
define tpl_cowboy_loop
-module($(n)).
-behaviour(cowboy_loop_handler).
@@ -196,7 +252,7 @@ init(_, _Req, _Opts) ->
{upgrade, protocol, cowboy_rest}.
content_types_provided(Req, State) ->
- {[{{<<"text">>, <<"html">>, '_'}, get_html}], Req, State}.
+ {[{{<<"text">>, <<"html">>, '*'}, get_html}], Req, State}.
get_html(Req, State) ->
{<<"<html><body>This is REST!</body></html>">>, Req, State}.
@@ -267,32 +323,30 @@ endef
# Plugin-specific targets.
define render_template
- @echo '$(subst $(newline),\n,${1})' > $(2)
+ @echo "$${$(1)}" > $(2)
endef
-define newline
-
-
-endef
+$(foreach template,$(filter bs_%,$(.VARIABLES)),$(eval export $(template)))
+$(foreach template,$(filter tpl_%,$(.VARIABLES)),$(eval export $(template)))
bootstrap:
ifneq ($(wildcard src/),)
$(error Error: src/ directory already exists)
endif
- $(call render_template,$(bs_Makefile),Makefile)
+ $(call render_template,bs_Makefile,Makefile)
@mkdir src/
- $(call render_template,$(bs_appsrc),src/$(PROJECT).app.src)
- $(call render_template,$(bs_app),src/$(PROJECT)_app.erl)
+ $(call render_template,bs_appsrc,src/$(PROJECT).app.src)
+ $(call render_template,bs_app,src/$(PROJECT)_app.erl)
$(eval n := $(PROJECT)_sup)
- $(call render_template,$(tpl_supervisor),src/$(PROJECT)_sup.erl)
+ $(call render_template,tpl_supervisor,src/$(PROJECT)_sup.erl)
bootstrap-lib:
ifneq ($(wildcard src/),)
$(error Error: src/ directory already exists)
endif
- $(call render_template,$(bs_Makefile),Makefile)
+ $(call render_template,bs_Makefile,Makefile)
@mkdir src/
- $(call render_template,$(bs_appsrc_lib),src/$(PROJECT).app.src)
+ $(call render_template,bs_appsrc_lib,src/$(PROJECT).app.src)
bootstrap-rel:
ifneq ($(wildcard relx.config),)
@@ -301,10 +355,10 @@ endif
ifneq ($(wildcard rel/),)
$(error Error: rel/ directory already exists)
endif
- $(call render_template,$(bs_relx_config),relx.config)
+ $(call render_template,bs_relx_config,relx.config)
@mkdir rel/
- $(call render_template,$(bs_sys_config),rel/sys.config)
- $(call render_template,$(bs_vm_args),rel/vm.args)
+ $(call render_template,bs_sys_config,rel/sys.config)
+ $(call render_template,bs_vm_args,rel/vm.args)
new:
ifeq ($(wildcard src/),)
@@ -319,7 +373,7 @@ endif
ifndef n
$(error Usage: make new t=TEMPLATE n=NAME)
endif
- $(call render_template,$(tpl_$(t)),src/$(n).erl)
+ $(call render_template,tpl_$(t),src/$(n).erl)
list-templates:
@echo Available templates: $(sort $(patsubst tpl_%,%,$(filter tpl_%,$(.VARIABLES))))
diff --git a/plugins/c_src.mk b/plugins/c_src.mk
index 63ca6bc..e23c7b9 100644
--- a/plugins/c_src.mk
+++ b/plugins/c_src.mk
@@ -1,14 +1,13 @@
-# Copyright (c) 2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2014-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
-.PHONY: clean-c_src
+.PHONY: clean-c_src distclean-c_src-env
# todo
# Configuration.
C_SRC_DIR = $(CURDIR)/c_src
C_SRC_ENV ?= $(C_SRC_DIR)/env.mk
-C_SRC_OPTS ?=
C_SRC_OUTPUT ?= $(CURDIR)/priv/$(PROJECT).so
# System type and C compiler/flags.
@@ -16,50 +15,91 @@ C_SRC_OUTPUT ?= $(CURDIR)/priv/$(PROJECT).so
UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Darwin)
CC ?= cc
- CFLAGS ?= -O3 -std=c99 -arch x86_64 -flat_namespace -undefined suppress -finline-functions -Wall -Wmissing-prototypes
+ CFLAGS ?= -O3 -std=c99 -arch x86_64 -finline-functions -Wall -Wmissing-prototypes
+ CXXFLAGS ?= -O3 -arch x86_64 -finline-functions -Wall
+ LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress
else ifeq ($(UNAME_SYS), FreeBSD)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
+ CXXFLAGS ?= -O3 -finline-functions -Wall
else ifeq ($(UNAME_SYS), Linux)
CC ?= gcc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
+ CXXFLAGS ?= -O3 -finline-functions -Wall
endif
-# Verbosity.
+CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
+CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
-c_src_verbose_0 = @echo " C_SRC " $(?F);
-c_src_verbose = $(appsrc_verbose_$(V))
+LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei
+LDFLAGS += -shared
-# Targets.
+# Verbosity.
-ifeq ($(wildcard $(C_SRC_DIR)/Makefile),)
+c_verbose_0 = @echo " C " $(?F);
+c_verbose = $(c_verbose_$(V))
-app:: $(C_SRC_ENV)
- @mkdir -p priv/
- $(c_src_verbose) $(CC) $(CFLAGS) $(C_SRC_DIR)/*.c -fPIC -shared -o $(C_SRC_OUTPUT) \
- -I $(ERTS_INCLUDE_DIR) $(C_SRC_OPTS)
+cpp_verbose_0 = @echo " CPP " $(?F);
+cpp_verbose = $(cpp_verbose_$(V))
-$(C_SRC_ENV):
- erl -noshell -noinput -eval "file:write_file(\"$(C_SRC_ENV)\", \
- io_lib:format(\"ERTS_INCLUDE_DIR ?= ~s/erts-~s/include/\", \
- [code:root_dir(), erlang:system_info(version)])), \
- init:stop()."
-
--include $(C_SRC_ENV)
+link_verbose_0 = @echo " LD " $(@F);
+link_verbose = $(link_verbose_$(V))
-else
-ifneq ($(wildcard $(C_SRC_DIR),))
+# Targets.
+ifeq ($(wildcard $(C_SRC_DIR)),)
+else ifneq ($(wildcard $(C_SRC_DIR)/Makefile),)
app::
$(MAKE) -C $(C_SRC_DIR)
clean::
$(MAKE) -C $(C_SRC_DIR) clean
-endif
-endif
+else
+SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \))
+OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
+
+COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c
+COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
+
+app:: $(C_SRC_ENV) $(C_SRC_OUTPUT)
+
+$(C_SRC_OUTPUT): $(OBJECTS)
+ @mkdir -p priv/
+ $(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT)
+
+%.o: %.c
+ $(COMPILE_C) $(OUTPUT_OPTION) $<
+
+%.o: %.cc
+ $(COMPILE_CPP) $(OUTPUT_OPTION) $<
+
+%.o: %.C
+ $(COMPILE_CPP) $(OUTPUT_OPTION) $<
+
+%.o: %.cpp
+ $(COMPILE_CPP) $(OUTPUT_OPTION) $<
+
+$(C_SRC_ENV):
+ @$(ERL) -eval "file:write_file(\"$(C_SRC_ENV)\", \
+ io_lib:format( \
+ \"ERTS_INCLUDE_DIR ?= ~s/erts-~s/include/~n\" \
+ \"ERL_INTERFACE_INCLUDE_DIR ?= ~s~n\" \
+ \"ERL_INTERFACE_LIB_DIR ?= ~s~n\", \
+ [code:root_dir(), erlang:system_info(version), \
+ code:lib_dir(erl_interface, include), \
+ code:lib_dir(erl_interface, lib)])), \
+ halt()."
clean:: clean-c_src
clean-c_src:
- $(gen_verbose) rm -f $(C_SRC_ENV) $(C_SRC_OUTPUT)
+ $(gen_verbose) rm -f $(C_SRC_OUTPUT) $(OBJECTS)
+
+distclean:: distclean-c_src-env
+
+distclean-c_src-env:
+ $(gen_verbose) rm -f $(C_SRC_ENV)
+
+-include $(C_SRC_ENV)
+endif
diff --git a/plugins/ci.mk b/plugins/ci.mk
new file mode 100644
index 0000000..e5df48e
--- /dev/null
+++ b/plugins/ci.mk
@@ -0,0 +1,65 @@
+# Copyright (c) 2015, Loïc Hoguin <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: ci ci-setup distclean-kerl
+
+KERL ?= $(CURDIR)/kerl
+export KERL
+
+KERL_URL ?= https://raw.githubusercontent.com/yrashk/kerl/master/kerl
+
+OTP_GIT ?= https://github.com/erlang/otp
+
+CI_INSTALL_DIR ?= $(HOME)/erlang
+CI_OTP ?=
+
+ifeq ($(strip $(CI_OTP)),)
+ci::
+else
+ci:: $(KERL) $(addprefix ci-,$(CI_OTP))
+
+ci-setup::
+
+ci_verbose_0 = @echo " CI " $(1);
+ci_verbose = $(ci_verbose_$(V))
+
+define ci_target
+ci-$(1): $(CI_INSTALL_DIR)/$(1)
+ -$(ci_verbose) \
+ PATH="$(CI_INSTALL_DIR)/$(1)/bin:$(PATH)" \
+ CI_OTP_RELEASE="$(1)" \
+ CT_OPTS="-label $(1)" \
+ $(MAKE) clean ci-setup tests
+endef
+
+$(foreach otp,$(CI_OTP),$(eval $(call ci_target,$(otp))))
+
+define ci_otp_target
+$(CI_INSTALL_DIR)/$(1):
+ $(KERL) build git $(OTP_GIT) $(1) $(1)
+ $(KERL) install $(1) $(CI_INSTALL_DIR)/$(1)
+endef
+
+$(foreach otp,$(CI_OTP),$(eval $(call ci_otp_target,$(otp))))
+
+define kerl_fetch
+ $(call core_http_get,$(KERL),$(KERL_URL))
+ chmod +x $(KERL)
+endef
+
+$(KERL):
+ @$(call kerl_fetch)
+
+help::
+ @printf "%s\n" "" \
+ "Continuous Integration targets:" \
+ " ci Run 'make tests' on all configured Erlang versions." \
+ "" \
+ "The CI_OTP variable must be defined with the Erlang versions" \
+ "that must be tested. For example: CI_OTP = OTP-17.3.4 OTP-17.5.3"
+
+distclean:: distclean-kerl
+
+distclean-kerl:
+ $(gen_verbose) rm -rf $(KERL)
+endif
diff --git a/plugins/cover.mk b/plugins/cover.mk
new file mode 100644
index 0000000..3397dca
--- /dev/null
+++ b/plugins/cover.mk
@@ -0,0 +1,136 @@
+# Copyright 2015, Viktor Söderqvist <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+COVER_REPORT_DIR = cover
+
+# utility variables for representing special symbols
+empty :=
+space := $(empty) $(empty)
+comma := ,
+
+# Hook in coverage to eunit
+
+ifdef COVER
+ifdef EUNIT_RUN
+EUNIT_RUN_BEFORE += -eval \
+ 'case cover:compile_beam_directory("ebin") of \
+ {error, _} -> halt(1); \
+ _ -> ok \
+ end.'
+EUNIT_RUN_AFTER += -eval 'cover:export("eunit.coverdata").'
+endif
+endif
+
+# Hook in coverage to ct
+
+ifdef COVER
+ifdef CT_RUN
+
+# All modules in 'ebin'
+COVER_MODS = $(notdir $(basename $(shell echo ebin/*.beam)))
+
+test-build:: $(TEST_DIR)/ct.cover.spec
+
+$(TEST_DIR)/ct.cover.spec:
+ @echo Cover mods: $(COVER_MODS)
+ $(gen_verbose) printf "%s\n" \
+ '{incl_mods,[$(subst $(space),$(comma),$(COVER_MODS))]}.' \
+ '{export,"$(CURDIR)/ct.coverdata"}.' > $@
+
+CT_RUN += -cover $(TEST_DIR)/ct.cover.spec
+endif
+endif
+
+# Core targets
+
+ifdef COVER
+ifneq ($(COVER_REPORT_DIR),)
+tests::
+ @$(MAKE) make --no-print-directory cover-report
+endif
+endif
+
+clean:: coverdata-clean
+
+ifneq ($(COVER_REPORT_DIR),)
+distclean:: cover-report-clean
+endif
+
+help::
+ @printf "%s\n" "" \
+ "Cover targets:" \
+ " cover-report Generate a HTML coverage report from previously collected" \
+ " cover data." \
+ " all.coverdata Merge {eunit,ct}.coverdata into one coverdata file." \
+ "" \
+ "If COVER=1 is set, coverage data is generated by the targets eunit and ct. The" \
+ "target tests additionally generates a HTML coverage report from the combined" \
+ "coverdata files from each of these testing tools. HTML reports can be disabled" \
+ "by setting COVER_REPORT_DIR to empty."
+
+# Plugin specific targets
+
+COVERDATA = $(filter-out all.coverdata,$(wildcard *.coverdata))
+
+.PHONY: coverdata-clean
+coverdata-clean:
+ $(gen_verbose) rm -f *.coverdata ct.cover.spec
+
+# Merge all coverdata files into one.
+all.coverdata: $(COVERDATA)
+ $(gen_verbose) $(ERL) -eval ' \
+ $(foreach f,$(COVERDATA),cover:import("$(f)") == ok orelse halt(1),) \
+ cover:export("$@"), halt(0).'
+
+# These are only defined if COVER_REPORT_DIR is non-empty. Set COVER_REPORT_DIR to
+# empty if you want the coverdata files but not the HTML report.
+ifneq ($(COVER_REPORT_DIR),)
+
+.PHONY: cover-report-clean cover-report
+
+cover-report-clean:
+ $(gen_verbose) rm -rf $(COVER_REPORT_DIR)
+
+ifeq ($(COVERDATA),)
+cover-report:
+else
+
+# Modules which include eunit.hrl always contain one line without coverage
+# because eunit defines test/0 which is never called. We compensate for this.
+EUNIT_HRL_MODS = $(subst $(space),$(comma),$(shell \
+ grep -e '^\s*-include.*include/eunit\.hrl"' src/*.erl \
+ | sed "s/^src\/\(.*\)\.erl:.*/'\1'/" | uniq))
+
+cover-report:
+ $(gen_verbose) mkdir -p $(COVER_REPORT_DIR)
+ $(gen_verbose) $(ERL) -eval ' \
+ $(foreach f,$(COVERDATA),cover:import("$(f)") == ok orelse halt(1),) \
+ Ms = cover:imported_modules(), \
+ [cover:analyse_to_file(M, "$(COVER_REPORT_DIR)/" ++ atom_to_list(M) \
+ ++ ".COVER.html", [html]) || M <- Ms], \
+ Report = [begin {ok, R} = cover:analyse(M, module), R end || M <- Ms], \
+ EunitHrlMods = [$(EUNIT_HRL_MODS)], \
+ Report1 = [{M, {Y, case lists:member(M, EunitHrlMods) of \
+ true -> N - 1; false -> N end}} || {M, {Y, N}} <- Report], \
+ TotalY = lists:sum([Y || {_, {Y, _}} <- Report1]), \
+ TotalN = lists:sum([N || {_, {_, N}} <- Report1]), \
+ TotalPerc = round(100 * TotalY / (TotalY + TotalN)), \
+ {ok, F} = file:open("$(COVER_REPORT_DIR)/index.html", [write]), \
+ io:format(F, "<!DOCTYPE html><html>~n" \
+ "<head><meta charset=\"UTF-8\">~n" \
+ "<title>Coverage report</title></head>~n" \
+ "<body>~n", []), \
+ io:format(F, "<h1>Coverage</h1>~n<p>Total: ~p%</p>~n", [TotalPerc]),\
+ io:format(F, "<table><tr><th>Module</th><th>Coverage</th></tr>~n", []), \
+ [io:format(F, "<tr><td><a href=\"~p.COVER.html\">~p</a></td>" \
+ "<td>~p%</td></tr>~n", \
+ [M, M, round(100 * Y / (Y + N))]) || {M, {Y, N}} <- Report1], \
+ How = "$(subst $(space),$(comma)$(space),$(basename $(COVERDATA)))", \
+ Date = "$(shell date -u "+%Y-%m-%dT%H:%M:%SZ")", \
+ io:format(F, "</table>~n" \
+ "<p>Generated using ~s and erlang.mk on ~s.</p>~n" \
+ "</body></html>", [How, Date]), \
+ halt().'
+
+endif
+endif # ifneq ($(COVER_REPORT_DIR),)
diff --git a/plugins/ct.mk b/plugins/ct.mk
index a2e64ef..eba0e52 100644
--- a/plugins/ct.mk
+++ b/plugins/ct.mk
@@ -1,77 +1,55 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
-.PHONY: build-ct-deps build-ct-suites tests-ct clean-ct distclean-ct
+.PHONY: ct distclean-ct
# Configuration.
CT_OPTS ?=
-ifneq ($(wildcard test/),)
- CT_SUITES ?= $(sort $(subst _SUITE.erl,,$(shell find test -type f -name \*_SUITE.erl -exec basename {} \;)))
+ifneq ($(wildcard $(TEST_DIR)),)
+ CT_SUITES ?= $(sort $(subst _SUITE.erl,,$(shell find $(TEST_DIR) -type f -name \*_SUITE.erl -exec basename {} \;)))
else
CT_SUITES ?=
endif
-TEST_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard
-TEST_ERLC_OPTS += -DTEST=1 -DEXTRA=1 +'{parse_transform, eunit_autoexport}'
-
# Core targets.
-tests:: tests-ct
-
-clean:: clean-ct
+tests:: ct
distclean:: distclean-ct
help::
@printf "%s\n" "" \
+ "Common_test targets:" \
+ " ct Run all the common_test suites for this project" \
+ "" \
"All your common_test suites have their associated targets." \
"A suite named http_SUITE can be ran using the ct-http target."
# Plugin-specific targets.
-ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS))
-
CT_RUN = ct_run \
-no_auto_compile \
- -noshell \
- -pa $(realpath ebin) $(DEPS_DIR)/*/ebin \
- -dir test \
- -logdir logs
-
-$(foreach dep,$(TEST_DEPS),$(eval $(call dep_target,$(dep))))
-
-build-ct-deps: $(ALL_TEST_DEPS_DIRS)
- @for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
+ -noinput \
+ -pa $(CURDIR)/ebin $(DEPS_DIR)/*/ebin $(TEST_DIR) \
+ -dir $(TEST_DIR) \
+ -logdir $(CURDIR)/logs
-build-ct-suites: build-ct-deps
- $(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -o test/ \
- $(wildcard test/*.erl test/*/*.erl) -pa ebin/
-
-tests-ct: ERLC_OPTS = $(TEST_ERLC_OPTS)
-tests-ct: clean deps app build-ct-suites
- @if [ -d "test" ] ; \
- then \
- mkdir -p logs/ ; \
- $(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS) ; \
- fi
- $(gen_verbose) rm -f test/*.beam
+ifeq ($(CT_SUITES),)
+ct:
+else
+ct: test-build
+ @mkdir -p $(CURDIR)/logs/
+ $(gen_verbose) $(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS)
+endif
define ct_suite_target
-ct-$(1): ERLC_OPTS = $(TEST_ERLC_OPTS)
-ct-$(1): clean deps app build-ct-suites
- @if [ -d "test" ] ; \
- then \
- mkdir -p logs/ ; \
- $(CT_RUN) -suite $(addsuffix _SUITE,$(1)) $(CT_OPTS) ; \
- fi
- $(gen_verbose) rm -f test/*.beam
+ct-$(1): test-build
+ @mkdir -p $(CURDIR)/logs/
+ $(gen_verbose) $(CT_RUN) -suite $(addsuffix _SUITE,$(1)) $(CT_OPTS)
endef
$(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
-clean-ct:
- $(gen_verbose) rm -rf test/*.beam
-
distclean-ct:
- $(gen_verbose) rm -rf logs/
+ $(gen_verbose) rm -rf $(CURDIR)/logs/
diff --git a/plugins/dialyzer.mk b/plugins/dialyzer.mk
index 8e404d1..23d16ee 100644
--- a/plugins/dialyzer.mk
+++ b/plugins/dialyzer.mk
@@ -1,4 +1,4 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
.PHONY: plt distclean-plt dialyze
@@ -9,11 +9,14 @@ DIALYZER_PLT ?= $(CURDIR)/.$(PROJECT).plt
export DIALYZER_PLT
PLT_APPS ?=
+DIALYZER_DIRS ?= --src -r src
DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions \
-Wunmatched_returns # -Wunderspecs
# Core targets.
+check:: dialyze
+
distclean:: distclean-plt
help::
@@ -24,11 +27,17 @@ help::
# Plugin-specific targets.
-plt: deps app
+$(DIALYZER_PLT): deps app
@dialyzer --build_plt --apps erts kernel stdlib $(PLT_APPS) $(ALL_DEPS_DIRS)
+plt: $(DIALYZER_PLT)
+
distclean-plt:
$(gen_verbose) rm -f $(DIALYZER_PLT)
+ifneq ($(wildcard $(DIALYZER_PLT)),)
dialyze:
- @dialyzer --no_native --src -r src $(DIALYZER_OPTS)
+else
+dialyze: $(DIALYZER_PLT)
+endif
+ @dialyzer --no_native $(DIALYZER_DIRS) $(DIALYZER_OPTS)
diff --git a/plugins/edoc.mk b/plugins/edoc.mk
index 5249d08..6f0a82d 100644
--- a/plugins/edoc.mk
+++ b/plugins/edoc.mk
@@ -1,7 +1,7 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
-.PHONY: distclean-edoc
+.PHONY: distclean-edoc edoc
# Configuration.
@@ -9,13 +9,14 @@ EDOC_OPTS ?=
# Core targets.
-docs:: distclean-edoc
- $(gen_verbose) erl -noshell \
- -eval 'edoc:application($(PROJECT), ".", [$(EDOC_OPTS)]), init:stop().'
+docs:: distclean-edoc edoc
distclean:: distclean-edoc
# Plugin-specific targets.
+edoc: doc-deps
+ $(gen_verbose) $(ERL) -eval 'edoc:application($(PROJECT), ".", [$(EDOC_OPTS)]), halt().'
+
distclean-edoc:
$(gen_verbose) rm -f doc/*.css doc/*.html doc/*.png doc/edoc-info
diff --git a/plugins/elvis.mk b/plugins/elvis.mk
new file mode 100644
index 0000000..580e2f5
--- /dev/null
+++ b/plugins/elvis.mk
@@ -0,0 +1,39 @@
+# Copyright (c) 2014, Juan Facorro <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: elvis distclean-elvis
+
+# Configuration.
+
+ELVIS_CONFIG ?= $(CURDIR)/elvis.config
+
+ELVIS ?= $(CURDIR)/elvis
+export ELVIS
+
+ELVIS_URL ?= https://github.com/inaka/elvis/releases/download/0.2.3/elvis
+ELVIS_CONFIG_URL ?= https://github.com/inaka/elvis/releases/download/0.2.3/elvis.config
+ELVIS_OPTS ?=
+
+# Core targets.
+
+help::
+ @printf "%s\n" "" \
+ "Elvis targets:" \
+ " elvis Run Elvis using the local elvis.config or download the default otherwise"
+
+distclean:: distclean-elvis
+
+# Plugin-specific targets.
+
+$(ELVIS):
+ @$(call core_http_get,$(ELVIS),$(ELVIS_URL))
+ @chmod +x $(ELVIS)
+
+$(ELVIS_CONFIG):
+ @$(call core_http_get,$(ELVIS_CONFIG),$(ELVIS_CONFIG_URL))
+
+elvis: $(ELVIS) $(ELVIS_CONFIG)
+ @$(ELVIS) rock -c $(ELVIS_CONFIG) $(ELVIS_OPTS)
+
+distclean-elvis:
+ $(gen_verbose) rm -rf $(ELVIS)
diff --git a/plugins/erlydtl.mk b/plugins/erlydtl.mk
index e288072..d65231d 100644
--- a/plugins/erlydtl.mk
+++ b/plugins/erlydtl.mk
@@ -1,6 +1,10 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
+# Configuration.
+
+DTL_FULL_PATH ?= 0
+
# Verbosity.
dtl_verbose_0 = @echo " DTL " $(filter %.dtl,$(?F));
@@ -9,14 +13,16 @@ dtl_verbose = $(dtl_verbose_$(V))
# Core targets.
define compile_erlydtl
- $(dtl_verbose) erl -noshell -pa ebin/ $(DEPS_DIR)/erlydtl/ebin/ -eval ' \
+ $(dtl_verbose) $(ERL) -pa ebin/ $(DEPS_DIR)/erlydtl/ebin/ -eval ' \
Compile = fun(F) -> \
- Module = list_to_atom( \
- string:to_lower(filename:basename(F, ".dtl")) ++ "_dtl"), \
- erlydtl:compile(F, Module, [{out_dir, "ebin/"}]) \
+ S = fun (1) -> re:replace(filename:rootname(string:sub_string(F, 11), ".dtl"), "/", "_", [{return, list}, global]); \
+ (0) -> filename:basename(F, ".dtl") \
+ end, \
+ Module = list_to_atom(string:to_lower(S($(DTL_FULL_PATH))) ++ "_dtl"), \
+ {ok, _} = erlydtl:compile(F, Module, [{out_dir, "ebin/"}, return_errors, {doc_root, "templates"}]) \
end, \
_ = [Compile(F) || F <- string:tokens("$(1)", " ")], \
- init:stop()'
+ halt().'
endef
ifneq ($(wildcard src/),)
diff --git a/plugins/escript.mk b/plugins/escript.mk
new file mode 100644
index 0000000..534db61
--- /dev/null
+++ b/plugins/escript.mk
@@ -0,0 +1,64 @@
+# Copyright (c) 2014 Dave Cottlehuber <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: distclean-escript escript
+
+# Configuration.
+
+ESCRIPT_NAME ?= $(PROJECT)
+ESCRIPT_COMMENT ?= This is an -*- erlang -*- file
+
+ESCRIPT_BEAMS ?= "ebin/*", "deps/*/ebin/*"
+ESCRIPT_SYS_CONFIG ?= "rel/sys.config"
+ESCRIPT_EMU_ARGS ?= -pa . \
+ -sasl errlog_type error \
+ -escript main $(ESCRIPT_NAME)
+ESCRIPT_SHEBANG ?= /usr/bin/env escript
+ESCRIPT_STATIC ?= "deps/*/priv/**", "priv/**"
+
+# Core targets.
+
+distclean:: distclean-escript
+
+help::
+ @printf "%s\n" "" \
+ "Escript targets:" \
+ " escript Build an executable escript archive" \
+
+# Plugin-specific targets.
+
+# Based on https://github.com/synrc/mad/blob/master/src/mad_bundle.erl
+# Copyright (c) 2013 Maxim Sokhatsky, Synrc Research Center
+# Modified MIT License, https://github.com/synrc/mad/blob/master/LICENSE :
+# Software may only be used for the great good and the true happiness of all
+# sentient beings.
+
+define ESCRIPT_RAW
+'Read = fun(F) -> {ok, B} = file:read_file(filename:absname(F)), B end,'\
+'Files = fun(L) -> A = lists:concat([filelib:wildcard(X)||X<- L ]),'\
+' [F || F <- A, not filelib:is_dir(F) ] end,'\
+'Squash = fun(L) -> [{filename:basename(F), Read(F) } || F <- L ] end,'\
+'Zip = fun(A, L) -> {ok,{_,Z}} = zip:create(A, L, [{compress,all},memory]), Z end,'\
+'Ez = fun(Escript) ->'\
+' Static = Files([$(ESCRIPT_STATIC)]),'\
+' Beams = Squash(Files([$(ESCRIPT_BEAMS), $(ESCRIPT_SYS_CONFIG)])),'\
+' Archive = Beams ++ [{ "static.gz", Zip("static.gz", Static)}],'\
+' escript:create(Escript, [ $(ESCRIPT_OPTIONS)'\
+' {archive, Archive, [memory]},'\
+' {shebang, "$(ESCRIPT_SHEBANG)"},'\
+' {comment, "$(ESCRIPT_COMMENT)"},'\
+' {emu_args, " $(ESCRIPT_EMU_ARGS)"}'\
+' ]),'\
+' file:change_mode(Escript, 8#755)'\
+'end,'\
+'Ez("$(ESCRIPT_NAME)"),'\
+'halt().'
+endef
+
+ESCRIPT_COMMAND = $(subst ' ',,$(ESCRIPT_RAW))
+
+escript:: distclean-escript deps app
+ $(gen_verbose) $(ERL) -eval $(ESCRIPT_COMMAND)
+
+distclean-escript:
+ $(gen_verbose) rm -f $(ESCRIPT_NAME)
diff --git a/plugins/eunit.mk b/plugins/eunit.mk
new file mode 100644
index 0000000..b9f2856
--- /dev/null
+++ b/plugins/eunit.mk
@@ -0,0 +1,54 @@
+# Copyright (c) 2014, Enrique Fernandez <[email protected]>
+# Copyright (c) 2015, Loïc Hoguin <[email protected]>
+# This file is contributed to erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: eunit
+
+# Configuration
+
+# All modules in TEST_DIR
+ifeq ($(strip $(TEST_DIR)),)
+TEST_DIR_MODS =
+else
+TEST_DIR_MODS = $(notdir $(basename $(shell find $(TEST_DIR) -type f -name *.beam)))
+endif
+
+# All modules in 'ebin'
+EUNIT_EBIN_MODS = $(notdir $(basename $(shell find ebin -type f -name *.beam)))
+# Only those modules in TEST_DIR with no matching module in 'ebin'.
+# This is done to avoid some tests being executed twice.
+EUNIT_MODS = $(filter-out $(patsubst %,%_tests,$(EUNIT_EBIN_MODS)),$(TEST_DIR_MODS))
+TAGGED_EUNIT_TESTS = $(foreach mod,$(EUNIT_EBIN_MODS) $(EUNIT_MODS),{module,$(mod)})
+
+EUNIT_OPTS ?=
+
+# Utility functions
+
+define str-join
+ $(shell echo '$(strip $(1))' | sed -e "s/ /,/g")
+endef
+
+# Core targets.
+
+tests:: eunit
+
+help::
+ @printf "%s\n" "" \
+ "EUnit targets:" \
+ " eunit Run all the EUnit tests for this project"
+
+# Plugin-specific targets.
+
+EUNIT_RUN_BEFORE ?=
+EUNIT_RUN_AFTER ?=
+EUNIT_RUN = $(ERL) \
+ -pa $(TEST_DIR) $(DEPS_DIR)/*/ebin \
+ -pz ebin \
+ $(EUNIT_RUN_BEFORE) \
+ -eval 'case eunit:test([$(call str-join,$(TAGGED_EUNIT_TESTS))],\
+ [$(EUNIT_OPTS)]) of ok -> ok; error -> halt(1) end.' \
+ $(EUNIT_RUN_AFTER) \
+ -eval 'halt(0).'
+
+eunit: test-build
+ $(gen_verbose) $(EUNIT_RUN)
diff --git a/plugins/relx.mk b/plugins/relx.mk
index 3f7fd87..43f3d69 100644
--- a/plugins/relx.mk
+++ b/plugins/relx.mk
@@ -1,31 +1,32 @@
-# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
+# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
-.PHONY: distclean-rel
+.PHONY: relx-rel distclean-relx-rel distclean-relx
# Configuration.
RELX_CONFIG ?= $(CURDIR)/relx.config
-ifneq ($(wildcard $(RELX_CONFIG)),)
-
RELX ?= $(CURDIR)/relx
export RELX
-RELX_URL ?= https://github.com/erlware/relx/releases/download/v1.0.2/relx
+RELX_URL ?= https://github.com/erlware/relx/releases/download/v2.0.0/relx
RELX_OPTS ?=
RELX_OUTPUT_DIR ?= _rel
ifeq ($(firstword $(RELX_OPTS)),-o)
RELX_OUTPUT_DIR = $(word 2,$(RELX_OPTS))
+else
+ RELX_OPTS += -o $(RELX_OUTPUT_DIR)
endif
# Core targets.
-rel:: distclean-rel $(RELX)
- @$(RELX) -c $(RELX_CONFIG) $(RELX_OPTS)
+ifneq ($(wildcard $(RELX_CONFIG)),)
+rel:: distclean-relx-rel relx-rel
+endif
-distclean:: distclean-rel distclean-relx
+distclean:: distclean-relx-rel distclean-relx
# Plugin-specific targets.
@@ -37,10 +38,11 @@ endef
$(RELX):
@$(call relx_fetch)
-distclean-rel:
+relx-rel: $(RELX)
+ @$(RELX) -c $(RELX_CONFIG) $(RELX_OPTS)
+
+distclean-relx-rel:
$(gen_verbose) rm -rf $(RELX_OUTPUT_DIR)
distclean-relx:
$(gen_verbose) rm -rf $(RELX)
-
-endif
diff --git a/plugins/shell.mk b/plugins/shell.mk
new file mode 100644
index 0000000..6636b92
--- /dev/null
+++ b/plugins/shell.mk
@@ -0,0 +1,28 @@
+# Copyright (c) 2014, M Robert Martin <[email protected]>
+# This file is contributed to erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: shell
+
+# Configuration.
+
+SHELL_PATH ?= -pa $(CURDIR)/ebin $(DEPS_DIR)/*/ebin
+SHELL_OPTS ?=
+
+ALL_SHELL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(SHELL_DEPS))
+
+# Core targets
+
+help::
+ @printf "%s\n" "" \
+ "Shell targets:" \
+ " shell Run an erlang shell with SHELL_OPTS or reasonable default"
+
+# Plugin-specific targets.
+
+$(foreach dep,$(SHELL_DEPS),$(eval $(call dep_target,$(dep))))
+
+build-shell-deps: $(ALL_SHELL_DEPS_DIRS)
+ @for dep in $(ALL_SHELL_DEPS_DIRS) ; do $(MAKE) -C $$dep ; done
+
+shell: build-shell-deps
+ $(gen_verbose) erl $(SHELL_PATH) $(SHELL_OPTS)
diff --git a/plugins/triq.mk b/plugins/triq.mk
new file mode 100644
index 0000000..2edfdba
--- /dev/null
+++ b/plugins/triq.mk
@@ -0,0 +1,31 @@
+# Copyright (c) 2015, Loïc Hoguin <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+ifneq ($(wildcard $(DEPS_DIR)/triq),)
+.PHONY: triq
+
+# Targets.
+
+tests:: triq
+
+define triq_run
+$(ERL) -pa $(CURDIR)/ebin $(DEPS_DIR)/*/ebin \
+ -eval "try $(1) of true -> halt(0); _ -> halt(1) catch error:undef -> io:format(\"Undefined property or module~n\"), halt() end."
+endef
+
+ifdef t
+ifeq (,$(findstring :,$(t)))
+triq: test-build
+ @$(call triq_run,triq:check($(t)))
+else
+triq: test-build
+ @echo Testing $(t)/0
+ @$(call triq_run,triq:check($(t)()))
+endif
+else
+triq: test-build
+ $(eval MODULES := $(shell find ebin -type f -name \*.beam \
+ | sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//'))
+ $(gen_verbose) $(call triq_run,[true] =:= lists:usort([triq:check(M) || M <- [$(MODULES)]]))
+endif
+endif
diff --git a/plugins/xref.mk b/plugins/xref.mk
new file mode 100644
index 0000000..b6e4d92
--- /dev/null
+++ b/plugins/xref.mk
@@ -0,0 +1,38 @@
+# Copyright (c) 2015, Euen Lopez <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+.PHONY: xref distclean-xref
+
+# Configuration.
+
+ifeq ($(XREF_CONFIG),)
+ XREF_ARGS :=
+else
+ XREF_ARGS := -c $(XREF_CONFIG)
+endif
+
+XREFR ?= $(CURDIR)/xrefr
+export XREFR
+
+XREFR_URL ?= https://github.com/inaka/xref_runner/releases/download/0.2.0/xrefr
+
+# Core targets.
+
+help::
+ @printf "%s\n" "" \
+ "Xref targets:" \
+ " xref Run Xrefr using $XREF_CONFIG as config file if defined"
+
+distclean:: distclean-xref
+
+# Plugin-specific targets.
+
+$(XREFR):
+ @$(call core_http_get,$(XREFR),$(XREFR_URL))
+ @chmod +x $(XREFR)
+
+xref: deps app $(XREFR)
+ $(gen_verbose) $(XREFR) $(XREFR_ARGS)
+
+distclean-xref:
+ $(gen_verbose) rm -rf $(XREFR)
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..180b5a1
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,220 @@
+# Copyright (c) 2014, Viktor Söderqvist <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+# Tests for erlang.mk targets. If any test fails or if you run a target other
+# than 'all', you must probably do 'make clean' before you can test again.
+
+# Verbosity.
+
+V ?= 0
+
+# t = Verbosity control for tests
+# v = Verbosity control for erlang.mk
+# i = Command to display (or suppress) info messages
+ifeq ($V,0)
+ # Show info messages only
+ t = @
+ v = V=0 &>/dev/null
+ i = @echo
+else ifeq ($V,1)
+ # Show test commands
+ t =
+ v = V=0 &>/dev/null
+ i = @echo ==
+else ifeq ($V,2)
+ # Show briefly what erlang.mk is doing
+ t = @echo " TEST " $@;
+ v = V=0
+ i = @echo ==
+else
+ # Show all commands with maximum verbosity
+ t =
+ v = V=1
+ i = @echo ==
+endif
+
+.PHONY: all clean app ct eunit tests-cover docs
+
+all: app ct eunit tests-cover docs clean
+ $i '+---------------------+'
+ $i '| All tests passed. |'
+ $i '+---------------------+'
+
+clean:
+ $t rm -rf app1
+
+app: app1
+ $i "app: Testing the 'app' target."
+ $t make -C app1 app $v
+ $i "Checking the modules line in the generated .app file."
+ $t [ `grep -E "{modules, *\['m'\]}" app1/ebin/app1.app | wc -l` == 1 ]
+ $t [ -e app1/ebin/m.beam ]
+ $i "Checking that 'make clean-app' deletes ebin."
+ $t make -C app1 clean-app $v
+ $t [ ! -e app1/ebin ]
+ $i "Checking that 'make app' returns non-zero on compile errors."
+ $t printf "%s\n" \
+ "-module(syntax_error)." \
+ "foo lorem_ipsum dolor sit amet." \
+ > app1/src/syntax_error.erl
+ $t if make -C app1 app $v ; then false ; fi
+ $t rm app1/src/syntax_error.erl
+ $i "Test 'app' passed."
+
+ct: app1
+ $i "ct: Testing ct and related targets."
+ $i "Setting up test suite."
+ $t mkdir -p app1/test
+ $t printf "%s\n" \
+ "-module(m_SUITE)." \
+ "-export([all/0, testcase1/1])." \
+ "all() -> [testcase1]." \
+ "testcase1(_) -> 2 = m:succ(1)." \
+ > app1/test/m_SUITE.erl
+ $t make -C app1 ct $v
+ $i "Checking files created by 'make ct'."
+ $t [ -e app1/test/m_SUITE.beam ]
+ $t [ -e app1/ebin/m.beam ]
+ $t [ -e app1/logs ]
+ $i "Checking that 'make clean' does not delete logs."
+ $t make -C app1 clean $v
+ $t [ -e app1/logs ]
+ $i "Testing target 'ct-mysuite' where mysuite_SUITE is a test suite."
+ $t make -C app1 ct-m $v
+ $i "Checking that 'make ct' returns non-zero for a failing suite."
+ $t printf "%s\n" \
+ "-module(failing_SUITE)." \
+ "-export([all/0, testcase1/1])." \
+ "all() -> [testcase1]." \
+ "testcase1(_) -> 42 = m:succ(1)." \
+ > app1/test/failing_SUITE.erl
+ $t if make -C app1 ct-failing $v ; then false ; fi
+ $i "Checking that 'make distclean-ct' deletes logs."
+ $t make -C app1 distclean-ct $v
+ $t [ ! -e app1/logs ]
+ $t [ -e app1/ebin/m.beam ]
+ $i "Cleaning up test data."
+ $t rm -rf app1/test
+ $i "Test 'ct' passed."
+
+eunit: app1
+ $i "eunit: Testing the 'eunit' target."
+ $i "Running eunit test case inside module src/t.erl"
+ $t $(call create-module-t)
+ $t make -C app1 eunit $v
+ $i "Checking that the eunit test in module t."
+ $t echo t | cmp app1/test-eunit.log -
+ $t rm app1/test-eunit.log
+ $i "Running eunit tests in a separate directory."
+ $t mkdir -p app1/eunit
+ $t printf '%s\n' \
+ '-module(t_tests).' \
+ '-include_lib("eunit/include/eunit.hrl").' \
+ 'succ_test() ->' \
+ ' ?assertEqual(2, t:succ(1)),' \
+ ' os:cmd("echo t_tests >> test-eunit.log").' \
+ > app1/eunit/t_tests.erl
+ $t printf '%s\n' \
+ '-module(x_tests).' \
+ '-include_lib("eunit/include/eunit.hrl").' \
+ 'succ_test() ->' \
+ ' ?assertEqual(2, t:succ(1)),' \
+ ' os:cmd("echo x_tests >> test-eunit.log").' \
+ > app1/eunit/x_tests.erl
+ $t make -C app1 eunit TEST_DIR=eunit $v
+ $i "Checking that 'make eunit' didn't run the tests in t_tests twice, etc."
+ $t printf "%s\n" t t_tests x_tests | cmp app1/test-eunit.log -
+ $t rm app1/test-eunit.log
+ $i "Checking that 'make eunit' returns non-zero for a failing test."
+ $t rm -f app1/eunit/*
+ $t printf "%s\n" \
+ "-module(t_tests)." \
+ '-include_lib("eunit/include/eunit.hrl").' \
+ "succ_test() ->" \
+ " ?assertEqual(42, t:succ(1))." \
+ > app1/eunit/t_tests.erl
+ $t if make -C app1 eunit TEST_DIR=eunit $v ; then false ; fi
+ $t rm -rf app1/eunit app1/src/t.erl app1/test-eunit.log
+ $i "Test 'eunit' passed."
+
+# TODO: do coverage for 'tests' instead of 'eunit ct' when triq is fixed
+tests-cover: app1
+ $i "tests-cover: Testing 'eunit' and 'ct' with COVER=1"
+ $i "Setting up eunit and ct suites."
+ $t $(call create-module-t)
+ $t mkdir -p app1/test
+ $t printf "%s\n" \
+ "-module(m_SUITE)." \
+ "-export([all/0, testcase1/1])." \
+ "all() -> [testcase1]." \
+ "testcase1(_) -> 2 = m:succ(1)." \
+ > app1/test/m_SUITE.erl
+ $i "Running tests with coverage analysis."
+ $t make -C app1 eunit ct COVER=1 $v
+ $t [ -e app1/test-eunit.log ]
+ $t [ -e app1/eunit.coverdata ]
+ $t [ -e app1/ct.coverdata ]
+ $i "Generating coverage report."
+ $t make -C app1 cover-report COVER=1 $v
+ $t [ -e app1/cover/m.COVER.html ]
+ $t [ -e app1/cover/t.COVER.html ]
+ $t [ -e app1/cover/index.html ]
+ $i "Checking combined coverage from eunit and ct."
+ $t [ `grep 'Total: 100%' app1/cover/index.html | wc -l` -eq 1 ]
+ $i "Checking that cover-clean removes cover data and report."
+ $t make -C app1 cover-clean $v
+ $t [ ! -e app1/cover ] && [ ! -e app1/eunit.coverdata ]
+ @# clean up
+ $t rm -rf app1/src/t.erl app1/test app1/test-eunit.log
+ $t make -C app1 clean $v
+ $i "Test 'tests-cover' passed."
+
+docs: app1
+ $i "docs: Testing EDoc including DOC_DEPS."
+ $t printf "%s\n" \
+ "PROJECT = app1" \
+ "DOC_DEPS = edown" \
+ "dep_edown = git https://github.com/uwiger/edown.git 0.5" \
+ "EDOC_OPTS = {doclet, edown_doclet}" \
+ "include erlang.mk" \
+ "distclean:: distclean-doc-md" \
+ "distclean-doc-md:" \
+ " rm -rf doc/*.md" \
+ > app1/Makefile-doc
+ $i "Downloading doc deps (edown) and building docs."
+ $t make -C app1 -f Makefile-doc docs $v
+ $i "Checking that 'make docs' using edown generated a markdown file."
+ $t [ -e app1/doc/m.md ]
+ $i "Checking that 'make distclean' deletes all generated doc files."
+ $t make -C app1 -f Makefile-doc distclean $v
+ $t [ "`ls app1/doc/`" == "" ]
+ $i "Cleaning up test data."
+ $t rm app1/Makefile-doc
+ $i "Test 'docs' passed."
+
+# Test application used for testing.
+app1:
+ $i "Setting up app."
+ $t mkdir -p app1
+ $t cp ../erlang.mk app1/
+ $t make -C app1 -f erlang.mk bootstrap-lib
+ $t printf "%s\n" \
+ "-module(m)." \
+ "-export([succ/1])." \
+ "succ(N) -> N + 1." \
+ > app1/src/m.erl
+
+# Extra module in app1 used for testing eunit
+define create-module-t
+printf '%s\n' \
+ '-module(t).' \
+ '-export([succ/1]).' \
+ 'succ(N) -> N + 1.' \
+ '-ifdef(TEST).' \
+ '-include_lib("eunit/include/eunit.hrl").' \
+ 'succ_test() ->' \
+ ' ?assertEqual(2, succ(1)),' \
+ ' os:cmd("echo t >> test-eunit.log").' \
+ '-endif.' \
+ > app1/src/t.erl
+endef