Sunday, July 26, 2015

Re: There is a mistake in my « makefile »

On 2015-07-25, aubertin.sylvain wrote:
> Le vendredi 24 juillet 2015 07:59:40 UTC+2, aubertin.sylvain a écrit :
> > I am a beginner, in vim. Something is wrong in my makefile. At the end of my shell, when I type :make it works well. All my shell is compiled. But no trace of the object file, named essai.o
> > My source file is essai. Somewhere « make » or « /bin/bash » says to me : cyclic permutation is no correct. That is something I don't understand.
> > I should like to save my object file. Shall I use « sudo make install » or « sudo essai.o install » ? ?
> > For installing must I use commands put inside the makefile or am I forced to do that in second time, out of my makefile ? ? Here is my makefile :
> > # indiquer quel compilateur utiliser
> > #!/bin/bash
> > #makefile
> > all: essai.o
> > essai.o: essai
> > /bin/bash essai -o essai.o
> > My OS is : xubuntu 14.4.1 My vim version is 7.4. 52 My PC is hp Mini 110 1100
> > THANKS A LOT TO ALL MY REPLIERS
> Here is a copy of "essai" shell.
> #!/bin/bash
> #essai
> clear
> echo " SALUT "
> echo "Ce programme ne s'arrêtera que lorsque vous aurez tapé la lettre o "
> while [ -z $reponse ] [ $reponse != 'o' ] #rep. vide ou rep diffère de o
> do
> read -p 'repondez par o ou par n ' reponse
> done
> exit 0
> I should be very glad if you explain to me the last line of my makefile : TAB /bin/bash essai -o essai.o
> Of course essai is the source file, and essai.o the object file, but what -o means?

The file essai contains a shell script. Shell scripts are executed
by programs called interpreters. They do not need to be compiled
before being executed.

/bin/bash is an interpreter, not a compiler. When the command line

/bin/bash essai -o essai.o

is executed, the program /bin/bash is run with the three arguments

essai -o essai.o

/bin/bash assumes that the first argument is a file containing lines
of commands in the bash scripting language and that the other
arguments are to be passed to the script. /bin/bash proceeds to
interpret and execute the commands of that file. The script essai,
however, does not do anything with any arguments, so nothing is done
with "-o essai.o" by either /bin/bash or essai. Those arguments are
ignored.

Some compilers, such as the C compiler cc, have a -o option that
tells the compiler the name of the output file.

You appear to not understand the difference between interpreted
languages such as bash and compiled languages such as C. The source
code for an interpreted language, often called a script, is read by
a program called an interpreter and executed by the interpreter.
The source code for a compiled language first needs to be compiled
into machine code, then that machine code is loaded into RAM and
executed by the CPU.

The program make is often used as an aid to compiling source code
files to machine-code files. There is usually no need to use make
to run shell scripts.

Your script essai could also be run by setting its executable
permission bits like this,

chmod +x essai

and just giving its path name to the shell like this,

./essai

> Where shall I go for explanations of all these -o -e etc ??

The traditional place to go for explanations of program options such
as -o and -e is the man page for the program. Even with the
availability of the Internet and Google, I think that the man page
is still the best place to go, at least as the first place to go.
To read the man pages for bash and make, for example, you would
execute the following commands at the shell prompt:

man bash
man make

To find out more about using the man command, execute

man man

You should probably find a good beginners book about using Linux.
It will do a better and more complete job than I can of explaining
shell scripts, interpreters, compilers and makefiles.

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: