March 2009
Say you need e.g. a statically linked mkdosfs
under Debian (see ).
$ dpkg -S $(which
mkdosfs
)
dosfstools: /sbin/mkdosfs
$ sudo apt-get build-dep dosfstools
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
$ find dosfstools-2.11/ -iname mkdosfs -exec file {} \;
dosfstools-2.11/mkdosfs/mkdosfs: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), not stripped
$ cd dosfstools-2.11/mkdosfs/
$ export CFLAGS=-static
$ export LDFLAGS=-static
$ export CPPFLAGS=-static
$ make mkdosfs
cc -static mkdosfs.o -o mkdosfs
$ file mkdosfs
mkdosfs: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, statically linked, not stripped
As an alternative, you may be lucky seeing that setting the compiler/linker flags before running the apt-get source delivers statically linked binaries immediately:
$ export CFLAGS=-static
$ export LDFLAGS=-static
$ export CPPFLAGS=-static
$ export CFLAGS_APPEND=-static
$ export LDFLAGS_APPEND=-static
$ export CPPFLAGS_APPEND=-static
$ apt-get source --build dosfstools
<snip>
$ find -iname mkdosfs -type f -exec file {} \;