Take the 2-minute tour ×

I've written a C++ program (command line, portable code) and I'm trying to release a Linux version at the same time as the Windows version. I've written a makefile as follows:

ayane: *.cpp *.h
    g++ -Wno-write-strings -oayane *.cpp

Straightforward enough so far; but I'm given to understand it's customary to have a second step, make install. So when I put the install: target in the makefile... what command should be associated with it? (If possible I'd prefer it to work on all Unix systems as well as Linux.)

share|improve this question
add comment

3 Answers

up vote 21 down vote accepted


A less trivial installer will copy several things into place, first insuring that the appropriate paths exists (using mkdir -p or similar). Typically something like this:

  • the executable goes in $INSTALL_PATH/bin
  • any libraries built for external consumption go in $INSTALL_PATH/lib or $INSTALL_PATH/lib/yourappname
  • man pages go in $INSTALL_PATH/share/man/man1 and possibly other sections if appropriate
  • other docs go in $INSTALL_PATH/share/yourappname
  • default configuration files go in $INSTALL_PATH/etc/yourappname
  • headers for other to link against go in $INSTALL_PATH/include/yourappname

Installation path

The INSTALL_PATH is an input to the build system, and usually defaults to /usr/local. This gives your user the flexibility to install under their $HOME without needing elevated permission.

In the simplest case just use


at the top of the makefile. Then the user can override it by setting an environment variable in their shell.


You also occasionally see make installs that build a manifest to help with de-installation. The manifest can even be written as a script to do the work.

Another approach is just to have a make uninstall that looks for the things make install places, and removes them if they exist.

share|improve this answer
It's also important that 'make install' should be the only step that requires root permission. –  Martin Beckett Feb 9 '09 at 18:31
A (not very well respected convention) is to use DESTDIR as the name of the staging directory, and install in $(DESTDIR)$(prefix), where prefix is defined during the configuration and DESTDIR is set when make is run (often left empty). –  William Pursell Nov 26 '11 at 12:09
add comment

In the simplest case you just copy the newly created executable into the /usr/local/bin path. Of course, it's usually more complicated than that.

Notice that most of these operations require special rights, which is why make install is usually invoked using sudo.

share|improve this answer
i dont have sudo installed, and actually, i dont compile anything outside of outside of the arch linux build system (ABS). To install the package, you need to be root (or such privelages), so i agree –  theman_on_vista Feb 9 '09 at 14:49
Of course, those without sudo can use "su -c". But they should use it to install sudo... –  dmckee Feb 9 '09 at 16:32
add comment

make install is usually the step that "installs" the binary into the correct place.

For example, when compiling Vim, make install may place it in /usr/local/bin

Not all Makefiles have a make install

share|improve this answer
The OP asked about what make install should consist of, not what it is. He clearly had knowledge of what make install did, just not how to do it. Read the question before answering as if the OP is a complete beginner. –  Joe D Apr 11 '10 at 18:03
add comment

Your Answer


