Skip to content

Makefile: Use install command to install#34

Open
JohnAZoidberg wants to merge 1 commit intodeadpixi:masterfrom
JohnAZoidberg:install
Open

Makefile: Use install command to install#34
JohnAZoidberg wants to merge 1 commit intodeadpixi:masterfrom
JohnAZoidberg:install

Conversation

@JohnAZoidberg
Copy link

It creates the parent directories of the target if they are not there.

This is especially useful if you want to install it into a non-standard location.

@0mp
Copy link

0mp commented Aug 6, 2019

-t is not a standard option of install. It will probably cause trouble for users and package maintainers.

@JohnAZoidberg
Copy link
Author

Oh, you're right. It seems to be a GNU extension.
I'm not sure I understand the manual correctly. It works on GNU, would that do it?

	install -m755 mtm -D $(DESTDIR)/bin/mtm
	install -m644 mtm.1 -D $(MANDIR)/mtm.1

@0mp
Copy link

0mp commented Aug 6, 2019

I believe that GNU install's -D is not portable. See GNU install and FreeBSD install manuals, for example.

@JohnAZoidberg
Copy link
Author

Hmm. It seems like install isn't more helpful in this use-case than mkdir -p and cp, right?

@0mp
Copy link

0mp commented Aug 8, 2019

I think that I'd go for mkdir -p and install -m XXX. That seems to be fairly standard across different operating systems.

To be extra careful maybe we could go for mkdir, cp and chmod but I am not sure if that's smart.

Cheers!

When installing to a non-standard DESTDIR, the entire target tree might
not be there.
@HalosGhost
Copy link

HalosGhost commented Aug 24, 2019

Note that mkdir -p is actually also non-portable. It is not uncommon for makefiles attempting to be maximally portable to define MKDIR ?= mkdir -p and leverage $(MKDIR) throughout the script (so that if -p is not possible / would cause problems, the user can declare the use of a different program or script that will handle it properly).

@JohnAZoidberg
Copy link
Author

Which systems do not support mkdir -p?
Since it's part of the POSIX standard I think it's safe to use.

@HalosGhost
Copy link

@JohnAZoidberg, for reference: https://www.gnu.org/software/make/manual/html_node/Utilities-in-Makefiles.html

Though -p is specified by POSIX, it is underspecified in certain cases which can cause portability issues. It's a minor thing though; and can be easily changed should anyone actually run into it as a problem.

@HalosGhost
Copy link

Just to clarify, I do not think you should worry about providing an alternative to mkdir -p yourself in this PR. Instead, if no one objects, I think it would be ideal to define MKDIR ?= mkdir -p so that people can override it if they need to for their platform, and then use $(MKDIR) instead of mkdir -p throughout the script.

That lets the portability question be dealt with by users of platforms affected, but still empowers them to overcome the issue with minimal extra effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants