Make is a general purpose workflow program, usually used for compilation. But it can be used for anything.
When you do something like "make all", the make program executes a rule named "all" from a file in current directory named "Makefile". This rule usually calls the compiler to compile some source code into binaries.
When you do "make install", the make program takes the binaries from the previous step and copies them into some appropriate locations so that they can be accessed. Unlike on Windows, installation just requires copying some libraries and executables and there is no registry requirement as such. In short, "make install" just copies compiled files into appropriate locations.
Answer from sharjeel on Stack ExchangeMake is a general purpose workflow program, usually used for compilation. But it can be used for anything.
When you do something like "make all", the make program executes a rule named "all" from a file in current directory named "Makefile". This rule usually calls the compiler to compile some source code into binaries.
When you do "make install", the make program takes the binaries from the previous step and copies them into some appropriate locations so that they can be accessed. Unlike on Windows, installation just requires copying some libraries and executables and there is no registry requirement as such. In short, "make install" just copies compiled files into appropriate locations.
make install does whatever the Makefile author wants it to do. Typically, by this point, it is too late to change the install directory, as it is often known earlier, during the build, so help files and configuration files can be referenced with the correct pathnames.
Many projects use the GNU Autotools to try to improve their portability among hardware and operating system differences. (Different Unix variants use slightly different headers for declarations of functions that are slightly off the usual path -- except most programs need one or another of the ones declared in different locations.)
When a project does use the Autotools, the normal mantra to install it is:
./configure
make
make install
The ./configure typically allows you to use a command line option like --prefix /opt/apache or something similar to specify a different pathname. /usr/local/ is a common default prefix. It is far easier for locally built software to live in one place and distribution-provided software to live in the "main directories": /usr/ /bin/, and so on. (Packagers are very careful to never touch files in /usr/local/ -- they know it is exclusively for system administrators.)
Anyway, the ./configure --prefix /path/to/new/prefix will set a variable in the Makefile that is available when compiling the program, modifying the manual pages so they point to the correct locations for files, modifying configuration files, etc. So make will build the software specifically for the install location you want and make install will install it into that location.
Most programs can run even without the final make install step -- just ./program_name will often start them up. This is definitely a per-project thing -- some, like postfix, qmail, etc., are made up of many different moving pieces and rely on them all working together. Others, like ls or su might be self-contained enough to execute fine from the directory they were built in. (This is not often useful -- but sometimes very useful.)
However, not all projects use the Autotools -- they are huge, complicated, and miserable to maintain. Hand-written Makefiles are much simpler to write, and I personally think just distributing a simple Makefile with configuration variables available is a lot easier on developers and users both. (Though the ./configure ; make ; make install mantra is really easy on users when it works.)
makefile - How can I install and use "make" in Windows? - Stack Overflow
c - How to implement "make install" in a Makefile? - Stack Overflow
install command in makefile - Stack Overflow
make - What is the purpose of the 'install' command? - Unix & Linux Stack Exchange
Videos
make is a GNU command, so the only way you can get it on Windows is installing a Windows version like the one provided by GNUWin32. Anyway, there are several options for getting that:
Directly download from Make for Windows
Using Chocolatey. First, you need to install this package manager. Once installed, you simply need to install
make(you may need to run it in an elevated/administrator command prompt):choco install makeAnother recommended option is installing a Windows Subsystem for Linux (WSL or WSL 2), so you'll have a Linux distribution of your choice embedded in Windows 10, where you'll be able to install
make,gcc, and all the tools you need to build C programs.For older Windows versions (Microsoft Windows 2000, Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, or Windows 7 with msvcrt.dll) you can use GnuWin32.
An outdated alternative was MinGW, but the project seems to be abandoned, so it's better to go for one of the previous choices.
GNU Make is available on Chocolatey.
Install Chocolatey from here.
Then,
choco install make.
Now you will be able to use Make on Windows. I've tried using it on MinGW, but it should work on CMD as well.
The OP ask long time ago, but I will guess it can be useful for others.
Since your make install command try to install files in directory requiring root privileges (ex: /usr/local/bin) you can either:
- Become root before launching your command (as you stated in your description: using
sudofor example)
OR
Install it in another directory that do not require specific privilege. For this purpose you can use a specific parameter named 'DESTDIR' that is usually supported in makefile, so that your command looks like:
make DESTDIR=/home/myuser/my_dest_dir installThis is named Staged Installs.
You can either tweak the Makefile (or use a configure script) to have it install the program in your home directory... or become root.
Run the command:
sudo apt-get install build-essential
Chances are you will need things like gcc to actually do the building so you might as well install those as well. The build-essential package will install other tools used along with make.
sudo apt-get update
sudo apt-get -y install make
(-y = answer 'yes' to any prompts)
Check the installed version:
make -v
install not only copies files but also changes its ownership and permissions and optionally removes debugging symbols from executables. It combines cp with chown, chmod and strip. It's a convenient higher-level tool to that accomplishes a common sequence of elementary tasks.
An advantage of install over cp for installing executables is that if the target already exists, it removes the target file and creates a new one. This gets rid of any current properties such as access control lists and capabilities, which can be seen both as an upside and as a downside. When updating executables, if there are running instances of this executable, they keep running unaffected. In contrast, cp updates the file in place if there is one. On most Unix variants, this fails with the error EBUSY¹ if the target is a running executable; on some it can cause the target to crash because it loads code sections dynamically and modifying the file causes nonsensical code to be loaded.
install is a BSD command (added in 4.2BSD, i.e. in the early 1980s). It has not been adopted by POSIX.
¹ “Text file busy”. In this context, “text file” means “binary executable file”, for obscure historical reasons.
It provides a standardized way of manipulating a file's or directory's ownership and permissions while copying the file or creating the directory, in a single command.
./configure is a program that looks at your system configuration and builds some of the system dependencies for your program.
make is a program that looks at your Makefile (which was probably built by configure) and uses the rules in there to build your program. The Makefile can have multiple "targets" which are rule sets to do different things - the default is usually just to compile and link your program. When you say make with no arguments, it runs the default target. When you say make install you're running the install target, which usually installs the binaries or libraries built by the default target in their final locations. clean is another common Makefile target that deletes all the generated files like intermediate object files.
make is part of the build system commonly used in Unix-type systems - binutils.
It looks at make files which hold configuration information and build targets.
Specifically -
- ./configure - this is a script that sets up the environment for the build
- make - calls
makewith the default build target. Normally builds the application. - make install - calls
makewith theinstallbuild target. Normally installs the application.