niobio / chromium-compact-language-detector

Automatically exported from code.google.com/p/chromium-compact-language-detector
0 stars 0 forks source link

Better packaging with autotools. #9

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

as discussed by email, I am improving the packaging of the CLD.
I broke down my patch into 3 patches.

* packaging1.diff: add or rename a bunch of files to comply with GNU standards.

* packaging2.diff: small minor fix on a comparison between an int and unsigned 
int (was making a warning when compiling with -Wall).

* packaging3.diff: add the autotools files.
Now the library can be installed by the common commands:
$ ./configure
NOTE: the maintainer has to run ./autogen.sh first in order to generate the 
configure file. But users don't have to run autogen.sh
$ make
$ make install

The C++ library will be installed (shared lib by default, static lib can be 
installed as well with the configure option --enable-static) with libtool and 
available through pkg-config as well (so very easy to use and use in a project).
Also the example.cc has been transformed into a package test (though a full 
test as for the Python wrapper would be nicer, but did not take the time to 
make this yet). In other words, it is run by:

$ make check

There are still a few things I'd like to do, like moving code into a src/ 
directory (and python wrapper into a separate one), including the run of 
setup.py in the same Makefile (to install all in one command as an option, not 
mandatory), some test, review some code, maybe make some binary package for 
Linux distributions, etc. But that's a first step. :-)

Thanks for this extraction. :-)

Original issue reported on code.google.com by je...@mygengo.com on 17 May 2012 at 8:59

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks Jehan!

I applied the patches (there were some conflicts; I resolved by hand).

But, when I run ./autogen.sh I seem to get errors:

mike@vine:~/src/pycld$ ./autogen.sh 
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./config.guess'
libtoolize: copying file `./config.sub'
libtoolize: copying file `./install-sh'
libtoolize: copying file `./ltmain.sh'
libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
Makefile.am: required file `./NEWS' not found
configure.ac:18: required file `cld.pc.in' not found
autoreconf: automake failed with exit status: 1

Despite the non-zero exit status, it did write a ./configure, so I tried 
running it but got another error (after lots of normal-looking configure 
output):

config.status: error: cannot find input file: `Makefile.in'

Any ideas?

Original comment by luc...@mikemccandless.com on 17 May 2012 at 11:30

GoogleCodeExporter commented 9 years ago
Hi,

(1) for NEWS (as I said, autotools are quite strict with otherwise inoffensive 
files), I just checked, it looks like it was indeed not in packaging1.diff, 
even though I added it! My guess is that mercurial does not accept empty files 
(as it was indeed empty!).
2 possible fixes: either create NEWS and make it non empty (add a link to the 
website for instance, so that people looking for news about the project may 
know where to get them); or add a "touch NEWS" in autogen.sh before the 
autoreconf line.
I opted for the first solution in my 4th patch.

(2) For cld.pc.in, that was a rule "cld.pc" in my .hgignore which made 
mercurial ignore the file! I replaced the rule by "^cld.pc$. And now I have 
been able to add it.

Attached the patch which fixes both issues.

Hopefully now the autogen.sh will work good. Tell me if you have any other 
issue.

Original comment by je...@mygengo.com on 17 May 2012 at 11:57

Attachments:

GoogleCodeExporter commented 9 years ago
OK I think I managed to get things working, but.... which files should I "hg 
add"?  I added configure, install-sh, cld.pc.in, etc.... but it's still missing 
some (missing, depcomp, etc.).  So now I'm confused!

Original comment by luc...@mikemccandless.com on 17 May 2012 at 12:19

GoogleCodeExporter commented 9 years ago
Hi,

don't add configure, install-sh.
Basically the only files to add are:
- autogen.sh
- Makefile.am
- configure.ac
- cld.pc.in
- COPYING
- INSTALL
- NEWS
- README
- ChangeLog

Remove: 
- LICENSE (replaced by COPYING)
- INSTALL.txt (replaced by INSTALL)
- README.txt (replaced by README)
- build.sh

I believe that's it. All the rest should be generated, when you run 
./autogen.sh then ./configure. That's basically the idea. The configure script 
is generated by autogen.sh just before a release (according to rules you set 
for your package). Then the actual Makefile is generated on the user's machine 
(hence each Makefile is specific to a customized installation) when this user 
runs the configure script.
This is what makes the autotools powerful and able to adapt to any kind of 
machine and installation.

Original comment by je...@mygengo.com on 17 May 2012 at 3:32

GoogleCodeExporter commented 9 years ago
OK super I think I removed/added the right files!  Can you confirm?  Thanks 
Jehan!

Original comment by luc...@mikemccandless.com on 17 May 2012 at 4:13

GoogleCodeExporter commented 9 years ago
Hi,

I had a look, that's just perfect.
I wonder if build.win.cmd is useful anymore as well because I *think* the 
configure+Makefile should also work on Windows platforms. But I am not sure, so 
let's keep it here until someone under Windows tests the Makefile and confirms 
it works well there as well.

Also I attached a new patch which fixes the distribution release process.

So basically from now on, here is the process to release a new version:
(1) edit configure.ac and change the following lines:
 - AC_INIT([libcld], [0.1], ...
 - AC_SUBST([CLD_API_VERSION], [0.1])
 -> replace the 0.1 (I used this version number rather than 0.031415 that I saw in setup.py by the way. But I did not know if there was any rational behind this long number. If there is, feel free to revert back and sorry for this!) by the release version.
 - AC_SUBST([CLD_LT_VERSION], [0:0:0])
 -> replace 0:0:0 by the next number in Libtool logics (both "public" and Libtool version numbers are unrelated): http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html

(2) run:
$ ./autogen.sh
$ ./configure
$ make dist

It will have created an archive called compact-language-detector-0.1.tar.gz 
(0.1 will be replaced by the public version number that you just set earlier) 
containing all the necessary files for end users (it includes "configure" for 
instance, but not the Makefile).

(3) Copy this archive somewhere else, uncompress it, and test it as a normal 
user would do:
$ tar xzf compact-language-detector-0.1.tar.gz
$ cd compact-language-detector-0.1/
$ ./configure --prefix=/home/jehan/testcld/
$ make
$ make check
$ make install

Check that /home/jehan/testcld/lib contains the library files, and 
/home/jehan/include/ contains the headers.

If all goes well. Youpiyouplaboum! Release it as a ready-to-go archive! :-)

NOTE: other things may not be perfect yet in the generated archive. But I'm 
going to bed now (2:20 AM in my timezone). I'll check tomorrow. :-)

Original comment by je...@mygengo.com on 17 May 2012 at 5:19

Attachments: