From e759d1f2b73d3a88c5344b9ba9af30c0a24fac78 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sat, 21 Dec 2013 01:03:59 -0500 Subject: [PATCH] Now using automake and autoconf This implements recommendations by Brandon Invergo for the GNU submission process, some of which is required by the GNU Coding Standards; I thank him for his help and swift responses during this time. --- .gitignore | 22 +++++++++- Makefile | 113 --------------------------------------------------- Makefile.am | 107 ++++++++++++++++++++++++++++++++++++++++++++++++ README | 43 ++++++++++++++++++++ configure.ac | 93 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 263 insertions(+), 115 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 README create mode 100644 configure.ac diff --git a/.gitignore b/.gitignore index 273eeb6..0165d6f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,26 @@ build node_modules -# downloaded by minification build -tools/compiler.jar +# generated by dist target +AUTHORS +NEWS +ChangeLog + +# autotools- and configure-generated +aclocal.m4 +Makefile.in +Makefile +*.cache/ +configure +config.* + +# should be added using automake --add-missing +INSTALL +tools/install-sh +tools/missing + +# downloaded manually by user +tools/closure-compiler.jar # website branch webroot/ diff --git a/Makefile b/Makefile deleted file mode 100644 index d8d6e7e..0000000 --- a/Makefile +++ /dev/null @@ -1,113 +0,0 @@ -## -# ease.js Makefile -# -# Copyright (C) 2010, 2011, 2012 Mike Gerwitz -# -# This file is part of ease.js. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -## - -path_build=./build -path_tools=./tools -path_lib=./lib -path_combine_output=${path_build}/ease.js -path_combine_output_full=${path_build}/ease-full.js -path_browser_test=${path_tools}/browser-test.html -path_test=./test -path_perf_test=${path_test}/perf - -perf_tests := $(shell find "$(path_perf_test)" -name 'perf-*.js') - -src_js := index.js $(wildcard $(path_lib)/*.js) -src_tests := index.js $(shell find "$(path_test)" -name test-* \ - -o -name *Test* \ - -o -name inc-*.js ) - -path_doc := ./doc - -combine := $(path_tools)/combine -compiler := $(path_tools)/compiler.jar -path_externs_internal := $(path_build)/externs-internal.js - -.PHONY: combine min doc test test-combine clean distclean - - -default: combine min -all: combine min doc - -mkbuild: $(path_build) - -# create build dir -$(path_build): - mkdir -p "$(path_build)" - -# combine all modules into easily redistributable ease.js file (intended for -# browser) -$(path_combine_output): $(src_js) | mkbuild - ${combine} > "$(path_combine_output)" -$(path_combine_output_full): $(src_js) $(src_tests) | mkbuild - INC_TEST=1 "$(combine)" > "${path_combine_output_full}" -$(path_build)/browser-test.html: $(path_browser_test) | $(path_combine_output_full) - cp "$(path_browser_test)" $@ -$(path_build)/browser-test-min.html: $(path_browser_test) | $(path_combine_output_full) - cat "$(path_browser_test)" | sed 's/ease-full\.js/ease-full\.min\.js/' > $@ -combine: $(path_combine_output) $(path_build)/browser-test.html - -doc: - $(MAKE) -C $(path_doc) -doc-html: - $(MAKE) -C $(path_doc) html - -test: default - $(MAKE) -C $(path_test) - -# performance tests -perf: default $(perf_tests) -perf-%.js: default - @node $@ - -# externs for compilation process -$(path_externs_internal): | mkbuild - $(path_tools)/mkexterns > $@ - -# minification process uses Google Closure compiler -min: build/ease.min.js build/ease-full.min.js $(path_build)/browser-test-min.html \ - | combine -$(compiler): - wget -O- http://closure-compiler.googlecode.com/files/compiler-latest.tar.gz \ - | tar -C $(path_tools) -xzv compiler.jar -build/%.min.js: build/%.js $(path_tools)/externs-global.js $(path_externs_internal) \ - $(compiler) - cat $(path_tools)/license-min.tpl > $@ - java -jar $(compiler) \ - --externs $(path_tools)/externs-global.js \ - --externs $(path_build)/externs-internal.js \ - --js $< >> $@ || rm $@ - -install: doc-info - [ -d $(path_info_install) ] || mkdir -p $(path_info_install) - cp $(path_doc_output_info) $(path_info_install) - -uninstall: - rm $(path_info_install)/easejs.info - -# clean up build dir -clean: - $(MAKE) -C $(path_doc) clean - rm -rf "${path_build}" - -distclean: clean - rm $(compiler) - diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..4b54ceb --- /dev/null +++ b/Makefile.am @@ -0,0 +1,107 @@ +## ease.js Makefile.am + +# see README +EXTRA_DIST = AUTHORS NEWS ChangeLog + +path_build = $(top_builddir)/build +path_tools = $(top_builddir)/tools +path_lib = $(top_builddir)/lib +path_test = $(top_builddir)/test +path_doc = $(top_builddir)/doc + +path_perf_test = $(path_test)/perf +path_combine_output = $(path_build)/ease.js +path_combine_output_full = $(path_build)/ease-full.js +path_browser_test = $(path_tools)/browser-test.html + +src_js = @SRC_JS@ +perf_tests = @PERF_TESTS@ +path_externs_internal = $(path_build)/externs-internal.js + +combine = $(path_tools)/combine +compiler = $(path_tools)/closure-compiler.jar + + +.PHONY: mkbuild combine min doc test perf + +default: all-local +all-local: combine min + +mkbuild: $(path_build) + +# create build dir +$(path_build): + mkdir -p "$(path_build)" + + +combine: $(path_combine_output) $(path_build)/browser-test.html + +# combine all modules into easily redistributable ease.js file (intended for +# browser) +$(path_combine_output): $(src_js) | mkbuild + $(combine) > "$(path_combine_output)" +$(path_combine_output_full): $(src_js) $(src_tests) | mkbuild + INC_TEST=1 "$(combine)" > "${path_combine_output_full}" +$(path_build)/browser-test.html: $(path_browser_test) | $(path_combine_output_full) + cp -f "$(path_browser_test)" $@ +$(path_build)/browser-test-min.html: $(path_browser_test) | $(path_combine_output_full) + cat "$(path_browser_test)" | sed 's/ease-full\.js/ease-full\.min\.js/' > $@ + +# minification process uses Google Closure compiler +min: $(path_build)/ease.min.js $(path_build)/ease-full.min.js \ +$(path_build)/browser-test-min.html | combine +build/%.min.js: build/%.js $(path_tools)/externs-global.js $(path_externs_internal) +if HAS_JAVA +if HAS_CCJAR + cat $(path_tools)/license-min.tpl > $@ + $(JAVA) -jar $(compiler) \ + --externs $(path_tools)/externs-global.js \ + --externs $(path_build)/externs-internal.js \ + --js $< >> $@ || rm $@ +else + @echo "cannot create $@:" + @echo " please download closure-compiler.jar and re-run ./configure" + @exit 1 +endif +else + @echo "Please install a Java virtual machine (e.g. openjdk)" + @exit 1 +endif + +# externs for compilation process +$(path_externs_internal): | mkbuild + $(path_tools)/mkexterns > $@ + +doc: + $(MAKE) -C "$(path_doc)" + +test: check +check: default + $(MAKE) -C "$(path_test)" + +# performance tests +perf: default $(perf_tests) +perf-%.js: default +if HAS_NODE + @$(NODE) $@ +else + @echo "Node.js must be installed in order to run performance tests" + @exit 1 +endif + +# generate the familiar files that automake normally checks for +dist-hook: + $(path_tools)/gitlog-to-authors > $(distdir)/AUTHORS + $(path_tools)/gitlog-to-news > $(distdir)/NEWS + $(path_tools)/gitlog-to-changelog \ + --strip-cherry-pick \ + --format=%s \ + -- \ + --no-merges \ + > $(distdir)/ChangeLog + +clean-local: + -rm -rf "$(path_build)" + +maintainer-clean-local: + -rm -f "$(compiler)" diff --git a/README b/README new file mode 100644 index 0000000..3eb6c35 --- /dev/null +++ b/README @@ -0,0 +1,43 @@ +Configuring ease.js +******************* + + Copyright (C) 2013 Mike Gerwitz + + This file is part of ease.js. + + Copying and distribution of this file, with or without modification, are + permitted in any medium without royalty provided the copyright notice and + this notice are preserved. This file is offered as-is, without warranty + of any kind. + + +This file contains information on configuring and building ease.js; for +information on using the library, please see the Markdown-formatted +README.md file or the Texinfo manual. + + +Installing +========== + +For information on installing ease.js on your system, see INSTALL. +Alternatively, you may install the software using npm by issuing the +following command: + + $ npm install easejs + + + +Configuring +=========== + +If your distribution contains a `configure' file in the project root, you +may jump immediately to INSTALL. + +Otherwise, you likely have the sources as they exist in the project +repository, which does not contain the generature `configure' script; you +may generate it by issuing the following commands: + + $ aclocal && automake --foreign && autoconf + +Please note that the --foreign argument is necessary to `automake' to ignore +certain missing files (such as ChangeLog) that are generated at build time. diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..166152b --- /dev/null +++ b/configure.ac @@ -0,0 +1,93 @@ +# For use by automake and autoconf +# +# Copyright (C) 2013 Mike Gerwitz +# +# This file is part of ease.js. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +## + +AC_INIT([ease.js], [1.0.0-dev], [bugs@easejs.org]) +AC_CONFIG_AUX_DIR([tools]) +AM_INIT_AUTOMAKE + +AC_CONFIG_FILES([Makefile]) + +# check for node, which is required for nearly every operation +AC_CHECK_PROGS(NODE, [node nodejs]) +AM_CONDITIONAL(HAS_NODE, [test "$NODE"]) + +# certain portions of the build process require that node be installed (in the +# future, we may be able to allow alternatives, such as SpiderMonkey) +test "$NODE" || AC_MSG_WARN([ + + Node.js is not installed; certain make targets have been disabled. +]) + +# yes, this isn't necessarily a good practice, however the directory itself can +# be loaded and used without being built, so it's important that our resulting +# file includes exactly what is contained within the dir and is rebuilt if /any/ +# of the files change +AC_MSG_CHECKING([for source js files]) +SRC_JS_LIB="$(find lib/*.js | tr '\n' ' ' )" +SRC_JS="index.js $SRC_JS_LIB" +AC_SUBST(SRC_JS) +if test -n "$SRC_JS_LIB"; then + AC_MSG_RESULT(ok) +else + AC_MSG_ERROR(failed!) +fi + +# unit tests +AC_MSG_CHECKING([for unit tests]) +SRC_TESTS="$( find test/ -name test-* \ + -o -name *Test* \ + -o -name inc-*.js \ + | tr '\n' ' ' \ +)" +AC_SUBST(SRC_TESTS) +if test "$SRC_TESTS"; then + AC_MSG_RESULT(ok) +else + AC_MSG_WARN(none found) +fi + +# check for performance tests +AC_MSG_CHECKING([for performance tests]) +PERF_TESTS=$( find test/perf -name 'perf-*.js' | tr '\n' ' ' ) +AC_SUBST(PERF_TESTS) +if test "$PERF_TESTS"; then + AC_MSG_RESULT(ok) +else + AC_MSG_WARN(none found) +fi + +# Java is used for Closure Compiler +AC_CHECK_PROGS(JAVA, [java]) +AM_CONDITIONAL(HAS_JAVA, [test "$JAVA"]) + +ccjar= +if test "$JAVA"; then + AC_CHECK_FILE([tools/closure-compiler.jar], [ccjar=1], [AC_MSG_NOTICE([ + + If you wish perform minification of the combined source file, you must + download closure-compiler.jar into the tools directory; it is available + here: + + https://developers.google.com/closure/compiler/ + ])]) +fi +AM_CONDITIONAL(HAS_CCJAR, [test "$ccjar"]) + +AC_OUTPUT