Mailinglist Archive: opensuse-programming (42 mails)

< Previous Next >
Re: [suse-programming-e] Creating static binaries with autotools
  • From: "William A. Mahaffey III" <wam@xxxxxxxxxx>
  • Date: Mon, 03 May 2004 08:10:47 -0500
  • Message-id: <409644D7.20507@xxxxxxxxxx>
Davi de Castro Reis wrote:

William A. Mahaffey III wrote:

Davi de Castro Reis wrote:

Hi guys,

Does someone know how can I create static binaries using autotools? I have a program that uses several dynamic libraries and I want to distribute it as a single static binary. Everytime I want to distribute it, I do a make (the Makefile is generated from configure), then I delete the binary, and do the last linking step myself, using the static flag. This is quite boring. Does someone know a way to create a 'make static'?

Thanks in advance,
Davi de Castro Reis

You should be able to put an entry in your Makefile to do whatever you do to manually make the static binary. Static versions of all the dynamic libraries must exist, of course.


Yes I can do, but it is not simple command line and it depends on a lot of user-specified variables (LDFLAGS, CXXFLAGS, CPPFLAGS, CC), and I do it with several different packages. What I want to know if there is some way that I can tell autoconf or automake to generate this entry in the Makefile for me. Something like a STATIC_PROGRAMS = xxxx or AC_CONFIG_STATIC().

Thanks,
Davi de Castro Reis



I believe the autoconf tools use a Makefile.in or some such as the template to generate a Makefile. Put an entry in that file, just as you would in the actual Makefile, to do whatever you want. The various variables you mention are available within the Makefile execution & you should be able to construct your command(s) using them. You could put several entries, 1 per package if required, etc. I don't know more about your specific case, but I have some code (a CAD/grid-generator) which I maintain on SGI (home), Linux (port) & WIN32 (port), all using the same makefile. I could use autoconf if I wanted, but I don't :-). You should be able to put the various entries in the Makefile.in & get things working. All you would really need is different names for your executables & a different link command to link exe.static (and static versions of all the libraries).


< Previous Next >
List Navigation