User:Timothee Flutre/Notebook/Postdoc/2012/11/27: Difference between revisions
From OpenWetWare
(→How to make a GNU package?: add info about documentation) |
(→How to make a GNU package?: add link to hello) |
||
(16 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
==How to make a GNU package?== | ==How to make a GNU package?== | ||
* | * To understand why using Autotools is a good idea, see these [http://sed.bordeaux.inria.fr/seminars/autotools_20140715.pdf slides] by Ludovic Courtès. | ||
* A very good tutorial by Martin Mann is available [http://www.bioinf.uni-freiburg.de/~mmann/HowTo/automake.html here]. | |||
* Make sure that you have an updated version of the Autotools on your system. | |||
* | * find a name for the package, for instance "mypkg" | ||
mkdir mypkg; cd mypkg | |||
mkdir | |||
* | * create some initial files: | ||
touch AUTHORS BUGS ChangeLog NEWS README | |||
* | * retrieve the license, for instance [http://www.gnu.org/licenses/gpl.html GPLv3]: | ||
touch configure.ac | wget -O COPYING http://www.gnu.org/licenses/gpl-3.0.txt | ||
autoreconf --install | |||
./ | * fill the README file ([http://bzr.savannah.gnu.org/lh/gsl/trunk/annotate/head:/README example]) | ||
* create the directory which will contain the source code, and populate it: | |||
mkdir src | |||
touch src/mytemplate.cpp | |||
* create the first necessary file, and fill it with [https://www.gnu.org/software/autoconf/manual/html_node/Initializing-configure.html AC_INIT], [https://www.gnu.org/software/autoconf/manual/html_node/Input.html AC_CONFIG_SRCDIR], [https://www.gnu.org/software/automake/manual/html_node/Public-Macros.html AM_INIT_AUTOMAKE], [https://www.gnu.org/software/autoconf/manual/html_node/C_002b_002b-Compiler.html AC_PROG_CXX], [https://www.gnu.org/software/automake/manual/html_node/Requirements.html AC_CONFIG_FILES], and [https://www.gnu.org/software/autoconf/manual/html_node/Output.html AC_OUTPUT]: | |||
touch configure.ac # and edit it | |||
* create the second necessary file, and fill it with [https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html SUBDIRS]: | |||
touch Makefile.am # and edit it | |||
* get the missing files via the Autotools, such as INSTALL: | |||
autoreconf --install # use autoreconf --force the next times | |||
#if needed, use: 'automake --add-missing' and 'libtoolize --force' | |||
* write your code (follow the techniques gathered under the name [https://pragprog.com/magazines/2012-04/the-pragmatic-defense Pragmatic Defense], look at the [http://www.gnu.org/software/hello/manual/hello.html hello program]) | |||
* write tests, possibly using [http://freedesktop.org/wiki/Software/cppunit/ CppUnit], and update AC_CONFIG_FILES: | |||
mkdir test; cd test/ | |||
touch test/Makefile.am | |||
* write some documentation in [http://en.wikipedia.org/wiki/Texinfo Texinfo]: | * write some documentation in [http://en.wikipedia.org/wiki/Texinfo Texinfo]: | ||
<nowiki> | <nowiki> | ||
cd doc | mkdir doc; cd doc/ | ||
wget -O fdl.texi http://cvs.savannah.gnu.org/viewvc/*checkout*/gnustandards/fdl.texi?root= | wget -O fdl.texi http://cvs.savannah.gnu.org/viewvc/*checkout*/gnustandards/fdl.texi?root=gnustandards&content-type=text%2Fplain | ||
touch manual_mypkg.texi # and edit it | |||
touch | make pdf | ||
</nowiki> | </nowiki> | ||
* compile the code with the [http://en.wikipedia.org/wiki/GNU_build_system Autotools] (see the [http://www.gnu.org/software/automake/manual/automake.html manual] and this [http://www.lrde.epita.fr/~adl/autotools.html tutorial]; for the tests, have a look [http://www.sourceware.org/autobook/autobook/autobook_98.html here]): | |||
./configure # can be followed by --prefix=$HOME, LDFLAGS=-L/usr/local/lib, 'CXXFLAGS=-O0 -g', etc | |||
make # can be followed by LDFLAGS="-L/usr/local/lib -static" as well as CXXFLAGS="-DDEBUG -Wall" | |||
make check # to automatically execute the tests | |||
* make your package available to anyone: | * make your package available to anyone: | ||
make install | make install | ||
make | make distcheck # can be followed by DISTCHECK_CONFIGURE_FLAGS=LDFLAGS=-L/usr/local/lib for instance | ||
make | tar tzvf mypkg-0.1.tar.gz # to check what is in the release | ||
* version your code, for instance with [http://en.wikipedia.org/wiki/Git_%28software%29 Git] (read the [http://git-scm.com/book book]!): | |||
git init | |||
git add AUTHORS COPYING ChangeLog INSTALL Makefile.am NEWS README TODO build-aux/* configure.ac | |||
git add src/Makefile.am src/hello.cpp | |||
git add doc/Makefile.am doc/manual_hello.texi doc/fdl.texi | |||
git add tests/Makefile.am tests/test1.bash | |||
git commit -m "first commit" | |||
# and edit .git/info/exclude or .gitignore, tag your release, etc | |||
And check that you have all required files in your repo: | |||
cd ~/tmp; git clone ~/<path_to_original_repo>/hello | |||
autoreconf --force | |||
./configure | |||
make | |||
make check | |||
make install | |||
make distcheck | |||
* share your code, for instance on [http://en.wikipedia.org/wiki/GitHub GitHub] (read the [http://help.github.com/ help]!) | |||
* | * '''Tips:''' | ||
** if your package uses [http://www.gnu.org/software/libtool/manual/html_node/index.html libtool], you need to use gdb like this: <code>$ libtool --mode=execute gdb --args myprogram -i input.txt</code> | |||
<!-- ##### DO NOT edit below this line unless you know what you are doing. ##### --> | <!-- ##### DO NOT edit below this line unless you know what you are doing. ##### --> |
Revision as of 17:10, 28 January 2015
Project name | <html><img src="/images/9/94/Report.png" border="0" /></html> Main project page <html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>Previous entry<html> </html> |
How to make a GNU package?
mkdir mypkg; cd mypkg
touch AUTHORS BUGS ChangeLog NEWS README
wget -O COPYING http://www.gnu.org/licenses/gpl-3.0.txt
mkdir src touch src/mytemplate.cpp
touch configure.ac # and edit it
touch Makefile.am # and edit it
autoreconf --install # use autoreconf --force the next times #if needed, use: 'automake --add-missing' and 'libtoolize --force'
mkdir test; cd test/ touch test/Makefile.am
mkdir doc; cd doc/ wget -O fdl.texi http://cvs.savannah.gnu.org/viewvc/*checkout*/gnustandards/fdl.texi?root=gnustandards&content-type=text%2Fplain touch manual_mypkg.texi # and edit it make pdf
./configure # can be followed by --prefix=$HOME, LDFLAGS=-L/usr/local/lib, 'CXXFLAGS=-O0 -g', etc make # can be followed by LDFLAGS="-L/usr/local/lib -static" as well as CXXFLAGS="-DDEBUG -Wall" make check # to automatically execute the tests
make install make distcheck # can be followed by DISTCHECK_CONFIGURE_FLAGS=LDFLAGS=-L/usr/local/lib for instance tar tzvf mypkg-0.1.tar.gz # to check what is in the release git init git add AUTHORS COPYING ChangeLog INSTALL Makefile.am NEWS README TODO build-aux/* configure.ac git add src/Makefile.am src/hello.cpp git add doc/Makefile.am doc/manual_hello.texi doc/fdl.texi git add tests/Makefile.am tests/test1.bash git commit -m "first commit" # and edit .git/info/exclude or .gitignore, tag your release, etc And check that you have all required files in your repo: cd ~/tmp; git clone ~/<path_to_original_repo>/hello autoreconf --force ./configure make make check make install make distcheck
|