schiggn
schiggn

Reputation: 63

what is the exact purpose of the cross compile option "--prefix"

It might sound like a google first or consult --help kinda question, but I did both and still dint really get a satisfing answer.

Imagine the following scenario: I have a cross-compiled RootFileSystem on my i686 harddrive under /tftpboot/rfs. I am booting this RFS over NFS with my ARM-Platform. I would now like to compile libxml, sqlite and php to the ARM-RFS to extend the already installed thttpd server. In my understanding, --prefix defines a different place for /, so in my case my configs should be as below:

//libxml

./configure --build=i686-linux --host=arm-926ejs-linux-gnueabi --prefix=/tftpboot/rfs
make
make install


//sqlite
./configure --build=i686-linux --host=arm-926ejs-linux-gnueabi --prefix=/tftpboot/rfs   CFLAGS="-lpthread -lrt -Os -ldl" CPPFLAGS="-DSQLITe_THREADSAFE=1 -DSQLITE_TEMP_STORAGE=3"
make
make install

//php
./configure --build=i686-linux --host=arm-926ejs-linux-gnueabi --target=arm-926ejs-linux-gnueabi --prefix=/tftpboot/rfs
    --with-thttpd=/usr/local/sbin --without-pear --with-pdo-sqlite=/usr/local --disable-all --enable-pdo 
    --with-sqlite3=/usr/local --with-config-file-path=/data --enable-libxml --with-libxml-dir=/usr/local
make
make install

because:

so I have to admit that I have absolutely no idea where I have to take absolute and where I have to work with relative paths. Or am I getting this all completely wrong?

Upvotes: 2

Views: 1483

Answers (1)

ams
ams

Reputation: 25589

--prefix tells configure where to install the programs, and where the installed program should look for its files when you run it.

If a specific project/program does not use the prefix at run-time (many don't) then it is simply the install location, and you can ignore the following. You can usually tell if the prefix is used by the compiled program by greping the installed binaries for the directory name (try doing an experimental install in a distinctive prefix), but that may not work if the files have debug info.

Otherwise, if you want to run it from a different location that you compiled it then here's the trick:

Assumptions:

  • You want to run it from /usr/bin in the target system's view.
  • You want to install it under /tftpboot/rfs/usr/bin in the build system's view.

Steps:

./configure --prefix=/usr --build=i686-linux --host=arm-926ejs-linux-gnueabi
make
make DESTDIR=/tftpboot/rfs install

Warning: DESTDIR is a conventional name, but some projects may choose something else (or nothing at all, in which case happy makefile hacking).

Upvotes: 1

Related Questions