LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-19-2021, 03:31 PM   #1
fabulousUnicorn
LQ Newbie
 
Registered: Nov 2021
Location: United States
Distribution: Linux Mint
Posts: 2

Rep: Reputation: Disabled
How does 'make install' work?


I have a number of rather odd questions about the 'make install' command.

1) What utility does it use to install the files to their final location on the system? Does it use 'cp', 'mv, 'install' or something else?

2) What happens if it is installing a file to the system, and a that file already exists on the system?

3) What if the file already exists on the system, and that file is currently being read or written to by another program?

Thank you for any replies. I am writing a set of python scripts to help manage my packages on an LFS installation I am doing. I want a deeper understanding of the 'make install' tool to help guide my design decisions for these scripts. This is my first question on this forum, so if I have done anything incorrectly, let me know.

Last edited by fabulousUnicorn; 11-19-2021 at 03:35 PM. Reason: Adding more context
 
Old 11-19-2021, 04:08 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,152
Blog Entries: 6

Rep: Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835
https://www.gnu.org/software/make/
https://www.gnu.org/software/make/manual/make.html

make install does whatever the Makefile author wants it to do.
https://superuser.com/questions/3601...ake-install-do
 
2 members found this post helpful.
Old 11-19-2021, 05:23 PM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Quote:
Originally Posted by fabulousUnicorn View Post
2) What happens if it is installing a file to the system, and a that file already exists on the system?
It's overwritten.
 
Old 11-19-2021, 05:44 PM   #4
enigma9o7
Senior Member
 
Registered: Jul 2018
Location: Silicon Valley
Distribution: Bodhi Linux
Posts: 1,404

Rep: Reputation: 563Reputation: 563Reputation: 563Reputation: 563Reputation: 563Reputation: 563
Quote:
Originally Posted by dugan View Post
It's overwritten.
That depends on what command and switches author of Makefile made... and possibly any defaults the shell is set for on your system if no switches used in Makefile, etc...

OP is basically asking what a script does, so nobody knows without seeing a copy of the script, in this case the Makefile.
 
1 members found this post helpful.
Old 11-19-2021, 06:08 PM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
You should read the Makefile. Each one is unique, depending on how it was written.

See the references provided by teckk to learn about Make and Makefiles.

Regarding your specific questions, it can use cp and it can overwrite files, if there are access problems it can fail.
 
1 members found this post helpful.
Old 11-19-2021, 09:50 PM   #6
kermitdafrog8
Member
 
Registered: Dec 2018
Location: Orlando, FL
Distribution: Slackware AARCH64 and X86_64
Posts: 340

Rep: Reputation: Disabled
How does 'make install' work?

You can also do 'make install DESTDIR=/tmp'. It will create an installation of the program to say /tmp/$prefix. Like /tmp/usr/bin. Hope that makes sense.
 
Old 11-20-2021, 12:08 AM   #7
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
must learn make script language which is Makefile, find line: install: as target in its syntax

also learn cp, mv, install, by follow it --help

install just cp with chmod option can be in CLI argument
 
Old 11-20-2021, 12:56 PM   #8
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,678

Rep: Reputation: Disabled
Quote:
Originally Posted by kermitdafrog8 View Post
You can also do 'make install DESTDIR=/tmp'. It will create an installation of the program to say /tmp/$prefix. Like /tmp/usr/bin.
This will only work if author of Makefile provided for DESTDIR. Not all authors do.

A common case where this will work is a Makefile generated by GNU Autotools.

But ultimately, the only way to know for sure what make install does is examining the contents of the Makefile.
 
Old 11-20-2021, 06:12 PM   #9
kermitdafrog8
Member
 
Registered: Dec 2018
Location: Orlando, FL
Distribution: Slackware AARCH64 and X86_64
Posts: 340

Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
This will only work if author of Makefile provided for DESTDIR. Not all authors do.

A common case where this will work is a Makefile generated by GNU Autotools.

But ultimately, the only way to know for sure what make install does is examining the contents of the Makefile.
Well true. Most Makefile is generated after running configure. And yes you are correct about checking the Makefile for how it handles the install.
 
Old 11-21-2021, 06:18 PM   #10
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,691
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
Let me try to step back here and provide a little "big picture background" information – before or after you begin to self-educate yourself about the "make" command.

"make" is a very-clever command whose syntax is: make [targetname]

These "targets" (including the default one, which is used if you don't specify one ...) are spelled out in a file that ... amazingly enough ... is named "Makefile"

For each "target," the Makefile says exactly what "make" must do in order to "make it." The actual sequence can become quite complicated, so I need to stop my discussion this point.

However, if you examine the contents of "Makefile", which is actually an ordinary text file, you will customarily find in it definitions for targets such as install, as well as other ones such as "uninstall" or "reinstall."

You can expect the Makefile authors to have anticipated that a file might already exist, but you should yourself make sure that an application is not in use before changing it. (Makefile authors cannot anticipate everything.)

"HTH!!"

Last edited by sundialsvcs; 11-21-2021 at 06:21 PM.
 
Old 11-22-2021, 08:09 AM   #11
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,152
Blog Entries: 6

Rep: Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835
For the OP

hellomake.c
Code:
#include <hellomake.h>

int main() 
{
  myPrintHelloMake();
  return(0);
}
hellomake.h
Code:
void myPrintHelloMake(void);
hellofunc.c
Code:
#include <stdio.h>
#include <hellomake.h>

void myPrintHelloMake(void) 
{
  printf("This is for Makefiles!!!\n");
  return;
}
You could compile that with
Code:
gcc -o hellomake hellomake.c hellofunc.c -I.
Run the executable.

Lets make a simple makefile
Code:
CC=gcc
CFLAGS=-I.
DEPS = hellomake.h

%.o: %.c $(DEPS)
	$(CC) -c -o $@ $< $(CFLAGS)
	
hellomake: hellomake.o hellofunc.o 
	$(CC) -o hellomake hellomake.o hellofunc.o
Run make in that directory. Run the executable.

Then go from there.

Example:
Code:
CC = gcc
CFLAGS = `pkg-config --cflags pangocairo sdl gl`
LIBS = `pkg-config --libs pangocairo sdl gl`

build:
	$(CC) $(CFLAGS) $(LIBS) something.c -o something

run:
	./something

clean:
	rm something
You make the Makefile or, use one of the tools that make a Makefile for you.

Last edited by teckk; 11-22-2021 at 08:12 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Does it really make a difference to use make -jK instead only "make" while compiling? angel'le Linux - General 1 04-26-2014 01:14 AM
make Xconfig doesn't work, make menuconfig does work Debian/KDE bucovaina78 Linux - Kernel 1 10-15-2008 01:26 PM
1st time installing redhat - Make and Make Install does not work runlikeanantelope Linux - Newbie 4 02-19-2007 03:58 PM
make install -vs- make then make install duncanbball Linux - Newbie 3 12-15-2005 12:44 PM
./configure , make and make install does not work mobassir Linux - Software 7 07-30-2003 09:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration