Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just recently started learning different Linux commands but I still don't understand how to use the make command. Please is there anyone that understands how to use make?

share

migration rejected from stackoverflow.com Jan 13 at 5:28

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as too broad by JakeGould, nc4pk, DavidPostill, mdpc, Deltik Jan 13 at 5:28

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

13  
Nobody knows how to use make. It's been a mystery since day one... – Mark Rushakoff Jun 6 '10 at 22:18
1  
sudo magic-smoke-mirrors – Urda Jun 6 '10 at 22:25
2  
sudo: magic-smoke-mirrors: command not found – Oli Jun 6 '10 at 22:26
1  
If you just started learning linux commands you probably don't need make anyway... :) – Unknown Jun 7 '10 at 6:38
2  
Learning make is like looking into the eyes of God. Half of the people go insane, the rest of us become programmers and sysadmins. What are you trying to do with 'make'? If you tell us, we might be able to provide a better answer for you. Make is very powerful and complex, and may be beyond what you are trying to learn at the moment. I was a Linux user for many years before I ever seriously started to use 'make' for anything except compiling software (We had to do that often, back in the day. These days, most people use a package management system like 'rpm', 'yum' and 'apt'). – Stefan Lasiewski Jun 7 '10 at 18:51

make(1) is an extremely powerful tool.

Generally, when a program is distributed as source code, the archive containing the code will also include Makefiles. make can read these files and turn the source code into an executable program.

Despite the fact that you'll most often see make used to turn .c files into .o files and .o files into executables, make is often useful in any case where you need to do one or more of the following:

  • Transform or process one or more files as input to produce one or more files of output.
  • Define actions that may depend on one or more other actions being triggered first (potentially requiring make to calculate the order in which to execute a hierarchy of dependent actions).
  • Automatically perform or skip actions based on the criteria of file modification since the last time make was run.
share
    
This is very helpful. I have taken source from github and tried running make, after this i do not know how to use the program further. Can you give one example please? Git: github.com/hilbix/vdidiag – Mohit Nov 8 '15 at 6:40

If you just want to use it (to build and install something) you can usually get along with:

cd source_dir
./configure
make
sudo make install

Of course this depends on the project following "traditional" rules and you having the required dependencies installed. A review of the README and/or INSTALL file should help you out.

share

Normally common users "use" make just calling it in a sequence like

./configure
make
make install

so that what you need to know is not too much about this program. If you mean instead you want to learn how to create a Makefile to do something, then you have to read at least the manual, e.g. the GNU make manual

share

There are many flavors of make tools (Gnu make, cmake, ...) and make files. Usually you need to create a make file (using a configure script or manually). Then calling make in the root project directory will build the software, usually make install will install it. Take care to specify the options you want during the configuration step.

How to create a configure script is another silly game (autotools) but there are better alternatives like using cmake instead.

man make
info make

Will give you detailled information about possible options of the tool itself like making a dry-run or set a verbosity level.

share

'Make' for the monkey-say-monkey-do Ubuntu installation instructions must always work. If not the installation instructor is careless or the Git package provider is careless.

For example concerning the openOCD Github versions up to version 6.1.0 you can exactly follow the instructions:

sudo apt-get install libftdi-dev
cd <path to the untared openocd tarball>
./configure --enable-ft2232_libftdi --enable-stlink
make
sudo make install 

... and everything will work out nice.

HOWEVER! openOCD version 9.0 is trouble. 'Make' suddenly demands source and target file (which actually is logic!) but apparently the openOCD developers changed something and the crowd has to follow. That is why Linux is still failing big time and is still incrowding itself too much.

share

Make reads commands form MakeFile. You must specify directory, where MakeFile exist.

Example:

make -D /home/developer/Documents/developing/projects/SuperProject.c/

Make will change current directory onto /home/developer/Documents/developing/projects/SuperProject.c/, reads MakeFile and do all think specified in makefile

share

"The make utility executes a list of shell commands associated with each target, typically to create or update a file of the same name. makefile contains entries that describe how to bring a target up to date with respect to those on which it depends, which are called dependencies."

http://www.computerhope.com/unix/umake.htm

share

protected by JakeGould Jan 9 at 1:11

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?