4

Given two computers A and B with the same specifications, both with the same Linux distribution, is it possible to 'make' compile in computer A and copy the directory to computer B and 'make install' without problems?

2
  • 3
    if two computers same specifications, yes
    – Baba
    Apr 5, 2015 at 6:20
  • 1
    Why would you not? Have you tried? Apr 5, 2015 at 6:21

2 Answers 2

3

In general it should be possible, if both hosts really have the same specifications (i.e. same processor architecture, same libraries in same versions installed, same kernel installed, same file system structure for referred config files/libraries, ...). But since you can do nasty things in Makefiles there might be situations where this is not possible.

The make command normally just compiles all the sources, links it against the installed libraries and the kernel, and then generates the binary output file.

3
  • These might situations could be a case in where the make command creates files outside the directory where the sources are? Is this technically the process which some tarballs are installed in certain distributions like Arch? (when upon extracting the tarball files, you already get some binaries)
    – Kolt Penny
    Apr 5, 2015 at 6:30
  • Well, normally you should execute make with user (non-root) rights, which means that the script should not be able to create arbitrary files in that step, but should stay in its build environment. make install is then executed as root, so that it can copy the files to the root file system. These might situations may be: "hard coding of some hardware aspects" (i.e. MAC of nic) or "hard cording of configuration" (i.e. hostname), etc. Apr 5, 2015 at 6:33
  • Perfect. I'll have that in mind.
    – Kolt Penny
    Apr 5, 2015 at 6:36
2

Recently, I had to compile a 2010 version of qemu, which was difficult on modern Ubuntu 16.04 operating system because of dependency issues. So, I was forced to do a make (compilation) in a Ubuntu 10.04, and then a make install in Ubuntu 16.04.

make uses timestamps to decide which actions need to be taken. Thus, as long as timestamps are preserved when the compiled files are transferred from the computer on which compilation was done to the computer on which install is to be done, it should work. There are various tools for saving and restoring meta-data of files in a directory tree, such as metastore, and git-cache-meta. The latter is for use with git repositories, as git doesn't preserve timestamps. Other tools like rsync, and cp allow you to transfer files while preserving timestamps, and don't require you to explicitly save and restore them, as in previous two tools.

If, like me you are using a git server to transfer files between the two computers (git push, and git pull). Here are the steps required for it.

#Computer 1 (where compilation is to be done)
make
git-cache-meta --store #this will create a .git_cache_meta file in the current directory
git add .
git commit -m "installed binaries; preserving timestamps"
git push origin master #or whatever may be your remote repository, and branch


#Computer 2 (where install is to be done)
git pull origin master #or use git clone <remote repository URL> <branch name>
git-cache-meta --apply
make install

In your case rsync looks like a simpler solution, as it can copy files, at the same time preserving timestamps (-t option), without worrying about remote git repositories, etc.

Here is how you'll do it with rsync.

rsync -a <source> <destination>

Similarly, with cp command.

cp -a <source> <destination>

Note: Although in your case the computer, and OS are the same, it might not be so for someone else, and in that case dynamic dependencies (run time dependencies) must be taken care of. For example, in my case I had to install libz.so.1 , on my Ubuntu 16.04 machine(sudo apt-get install lib32z1).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .