J.Joe J.Joe - 1 year ago 137
Linux Question

Makefile and Shell Script (Bash)

What is the relationship between Makefile and Bash?

Example in Makefile you have:

CC = gcc

But if you type this in the shell, you get error:

~# CC = gcc
-bash: CC: command not found

Understandably, because there are spaces. But it works in Makefile.

Also, in Makefile you use command substitution

$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

which should be variable substitution
in bash.

So Makefile syntax and bash syntax are different, but they do seem related, for example

Answer Source

There's no relationship - make and bash are two separate programs that parse distinct syntaxes. That they have similar or overlapping syntactic elements is likely due to having been developed around the same time and for some similar purposes, but they don't rely on the same parser or grammar.

Many distinct languages have shared language features either for ease of adoption or from imitation. Most languages use + to mean addition, for example, but that doesn't make the languages related.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download