0

I see some make files in this repository which makes me wonder if Make can build itself by using make files or it needs to be installed first via some other mechanism? I am a beginner at this so this question is educational.

Michael Munta
  • 207
  • 2
  • 16

1 Answers1

1

Can Make build itself by using its own functionality

There are many implementations of Make.

GNU Make can be compiled with shell and compiler. GNU Make can also invoke compiler with Make.

if Make can build itself by using make files

Yes, it "can".

it needs to be installed first via some other mechanism?

No.

This all is unrelated to CMake. Make and CMake are separate programs. In general, it's way more fragmented.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • Can you elaborate please? How can it do that before first compiling itself so the functionality is even available? – Michael Munta Nov 25 '21 at 13:54
  • `How can it do that` Do "what"? `first compiling itself` What does "itself" refer to? To compile GNU Make invoke a shell script called `./bootstrap` available from its sources. – KamilCuk Nov 25 '21 at 14:11
  • Yes, but I am asking about the functionality that make provides to other programs. Can it use that same functionality to build its own source code? – Michael Munta Nov 25 '21 at 14:38
  • `Can it use that same functionality to build its own source code?` Yes, it can. – KamilCuk Nov 25 '21 at 14:39
  • That's what I was asking. But I don't understand how. Say you have source code for make, but you never compiled it, how can you then compile it using make if it itself is not compiled yet by some other method like `./bootstrap` you mentioned? – Michael Munta Nov 25 '21 at 14:55
  • I do not understand. You can drive to work with a car and with a bike. You do not need to have a car to drive a bike. You do not need Make to invoke `./bootstrap` shells script. You can use Make to compile Make. I do not understand how supporting one method excludes the other. `how can you then compile it using make if it itself is not compiled yet by some other method like ./bootstrap you mentioned?` What does first and second "it" refers to. Please kindly try to be specific. If you do not have Make compiled, you can compile Make with `./bootstrap` script. – KamilCuk Nov 25 '21 at 15:22
  • You can also invoke compiler yourself, you do not need to use any script. – KamilCuk Nov 25 '21 at 15:27
  • Let's put it like this. How can a program that provides a compiling functionality compile itself using that functionality? You have a computer that you download make source code to for the first time ever. Now you can't compile this make source code by using make, you need to compile it some other way before being able to use make-like compilation. Does it make sense now? – Michael Munta Nov 26 '21 at 08:10
  • `How can a program that provides a compiling functionality compile itself using that functionality?` Make does not provide any "compiling funcionality". Make only runs other programs, like compilers, and tracks dependencies. Compiler != build system. As for "compiler bootstraping", it's a known paradox, and you can google search that term, and you basically start with the first compiler written in assembly. Also https://stackoverflow.com/questions/9429491/how-are-gcc-and-g-bootstrapped – KamilCuk Nov 26 '21 at 08:59
  • Isn't compiling a part of the build system? – Michael Munta Nov 26 '21 at 09:19
  • Is "driving" part of a street? Build system is a "dependency tracking" mechanisms - build system knows that such and such command from these input files produces those output files. Make calls compiler, compiler translates source files. As stated, `it's way more fragmented`. There is one tool that does one job. – KamilCuk Nov 26 '21 at 09:30
  • The repository you linked states `If you have an existing version of GNU make available you _should_ be able to run: make -f Basic.mk`. I'm saying if you don't have existing version you can't invoke the build process of that repository by using make, you need to compile that repository first by some other method. – Michael Munta Nov 26 '21 at 10:44
  • Project documentations are out of date, especially in open source projects. Source is the ultimate documentation. You can compile it with ./bootstrap script. You can invoke compiler directly. `I'm saying if you don't have existing version you can't invoke the build process of that repository **by using make**` Yes, so you can use some other method. I do not understand your confusion. – KamilCuk Nov 26 '21 at 10:47
  • I was confused because I saw those makefiles that one can invoke it for the first time ever without an existing version of make. That was the intent of my question, was probably not using correct terminology. – Michael Munta Nov 27 '21 at 06:56