Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a makefile basically the same thing as a batch file?

I know all about batch files and made them before, but I'm unclear on what a makefile is. It looks like a batch file. What are the similarities and diffferences?

like image 586
neuromancer Avatar asked Nov 15 '09 23:11

neuromancer


People also ask

What type of file is a makefile?

Script written as a Makefile, a developer file type that is used for compiling and linking programs from source code files; stores instructions using the GNU make standard. NOTE: Makefiles more commonly are created with the filename Makefile, which does not have a file extension.

Is makefile a script?

A makefile is a script. It is interpreted by some version of Make. The language of makefiles is designed to be used in build systems, invoking shell commands to build files out of other files.

What do you call a makefile?

Normally you should call your makefile either `makefile' or `Makefile'. (We recommend `Makefile' because it appears prominently near the beginning of a directory listing, right near other important files such as `README'.) The first name checked, `GNUmakefile', is not recommended for most makefiles.

What is a batch file called?

One of the best-known DOS batch files is Autoexec. bat that initializes DOS at system startup. In Unix operating systems a batch file is called a shell script. To run typical commands, such as to modify system settings, start apps or launch a website, batch files can be run using command prompt.


2 Answers

Similar, yes, except for the dependencies, the topological sort, the macro processing, and the expert system

If you do nothing but put shell commands in a Makefile then it is in fact a lot like a catalog of "batch files," and it executes each one when its associated named target is specified.

However, it is more typical to specify a graph of dependencies in a makefile, in which case make does a topological sort of all the dependencies in order to cleverly build everything only once and in the right order starting with the earliest prerequisites.

And to be complete, I should add that make is also a macro processor. It's oriented towards software build systems, so it provides handles on symbolic elements in its problem domain, such as the names of sources and targets.

Now, make is not specifically a general purpose expert system,1 but it does do more than just package up shellcode, and technically it does fit the expert system definition.

Make contains an inference engine. All versions of make have suffix rules, some versions also implement pattern rules. When combined with your specification (more rules, typically ones defining a software application) the result is an expert system which will decide what needs to be compiled, linked, purchased on eBay, whatever, all depending on the data and commands you have provided.


1. It's an *easy-to-use* expert system, instead. Skynet will probably not emerge from an accidental typo in a complicated Makefile.
like image 132
DigitalRoss Avatar answered Sep 22 '22 16:09

DigitalRoss


No. A makefile has special rules which relate how files depend on each other. It does not necessarily execute in the order it is written.

A batch file is a sequence of commands and control statements.

Makefiles often contain the same things as batch files, but batch files do not have a direct way of indicating dependencies or provide an inferred method of processing one kind of file into another kind.

like image 36
wallyk Avatar answered Sep 22 '22 16:09

wallyk