User:Timothee Flutre/Notebook/Postdoc/2012/11/27: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
(→‎How to make a GNU package?: test git repo with git clone)
(fix raw html notebook nav)
 
(10 intermediate revisions by one other user not shown)
Line 2: Line 2:
|-
|-
|style="background-color: #EEE"|[[Image:owwnotebook_icon.png|128px]]<span style="font-size:22px;"> Project name</span>
|style="background-color: #EEE"|[[Image:owwnotebook_icon.png|128px]]<span style="font-size:22px;"> Project name</span>
|style="background-color: #F2F2F2" align="center"|<html><img src="/images/9/94/Report.png" border="0" /></html> [[{{#sub:{{FULLPAGENAME}}|0|-11}}|Main project page]]<br />{{#if:{{#lnpreventry:{{FULLPAGENAME}}}}|<html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>[[{{#lnpreventry:{{FULLPAGENAME}}}}{{!}}Previous entry]]<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html>}}{{#if:{{#lnnextentry:{{FULLPAGENAME}}}}|[[{{#lnnextentry:{{FULLPAGENAME}}}}{{!}}Next entry]]<html><img src="/images/5/5c/Resultset_next.png" border="0" /></html>}}
|style="background-color: #F2F2F2" align="center"|[[File:Report.png|frameless|link={{#sub:{{FULLPAGENAME}}|0|-11}}]][[{{#sub:{{FULLPAGENAME}}|0|-11}}|Main project page]]<br />{{#if:{{#lnpreventry:{{FULLPAGENAME}}}}|[[File:Resultset_previous.png|frameless|link={{#lnpreventry:{{FULLPAGENAME}}}}]][[{{#lnpreventry:{{FULLPAGENAME}}}}{{!}}Previous entry]]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}{{#if:{{#lnnextentry:{{FULLPAGENAME}}}}|[[{{#lnnextentry:{{FULLPAGENAME}}}}{{!}}Next entry]][[File:Resultset_next.png|frameless|link={{#lnnextentry:{{FULLPAGENAME}}}}]]}}
|-
|-
| colspan="2"|
| colspan="2"|
Line 8: Line 8:
==How to make a GNU package?==
==How to make a GNU package?==


* find a name for the package, for instance "hello"
* 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.


* structure the package directory:
* find a name for the package, for instance "mypkg"
  mkdir mypkg; cd mypkg
  mkdir mypkg; cd mypkg
touch COPYING README INSTALL NEWS AUTHORS ChangeLog
mkdir src build-aux doc tests # you can also add other directories, e.g. lib scripts


* populate the <code>src/</code> directory with your code, e.g. <code>hello.cpp</code>
* create some initial files:
touch AUTHORS BUGS ChangeLog NEWS README


* retrieve the license, for instance [http://www.gnu.org/licenses/gpl.html GPLv3]:
* retrieve the license, for instance [http://www.gnu.org/licenses/gpl.html GPLv3]:
  wget -O COPYING http://www.gnu.org/licenses/gpl-3.0.txt
  wget -O COPYING http://www.gnu.org/licenses/gpl-3.0.txt


* fill the information files, such as README ([http://bzr.savannah.gnu.org/lh/gsl/trunk/annotate/head:/README example]), INSTALL ([http://bzr.savannah.gnu.org/lh/gsl/trunk/annotate/head:/INSTALL example])...
* fill the README file ([http://bzr.savannah.gnu.org/lh/gsl/trunk/annotate/head:/README example])


* use [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]):
* create the directory which will contain the source code, and populate it:
  touch configure.ac Makefile.am src/Makefile.am doc/Makefile.am # and edit these files
mkdir src
  autoreconf --install # use autoreconf --force the next times you want re-build configure
touch src/mytemplate.cpp
./configure # can be followed by --prefix=~/bin, LDFLAGS=-L/usr/local/lib, etc
 
  make
* 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]:
  make check # to automatically execute the tests
  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=gnustand
  wget -O fdl.texi http://cvs.savannah.gnu.org/viewvc/*checkout*/gnustandards/fdl.texi?root=gnustandards&content-type=text%2Fplain
ards&content-type=text%2Fplain
  touch manual_mypkg.texi # and edit it
  touch manual_hello.texi # and edit
  make pdf
  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:
Line 62: Line 80:


* share your code, for instance on [http://en.wikipedia.org/wiki/GitHub GitHub] (read the [http://help.github.com/ help]!)
* 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. ##### -->

Latest revision as of 22:17, 26 September 2017

Project name Main project page
Previous entry      

How to make a GNU package?

  • To understand why using Autotools is a good idea, see these slides by Ludovic Courtès.
  • A very good tutorial by Martin Mann is available 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
  • create some initial files:
touch AUTHORS BUGS ChangeLog NEWS README
  • retrieve the license, for instance GPLv3:
wget -O COPYING http://www.gnu.org/licenses/gpl-3.0.txt
  • create the directory which will contain the source code, and populate it:
mkdir src
touch src/mytemplate.cpp
touch configure.ac # and edit it
  • create the second necessary file, and fill it with 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 tests, possibly using CppUnit, and update AC_CONFIG_FILES:
mkdir test; cd test/
touch test/Makefile.am
  • write some documentation in Texinfo:
 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 your package available to anyone:
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
  • version your code, for instance with Git (read the 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 GitHub (read the help!)
  • Tips:
    • if your package uses libtool, you need to use gdb like this: $ libtool --mode=execute gdb --args myprogram -i input.txt