There is a mistake in my « makefile »

50 views
Skip to first unread message

aubertin.sylvain

unread,
Jul 24, 2015, 1:59:40 AM7/24/15
to vim_use
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

Eric Christopherson

unread,
Jul 24, 2015, 10:04:48 AM7/24/15
to vim...@googlegroups.com
I don't think this is Vim-related, but you can find out by just
executing make from the command line outside of Vim. Really there's no
way of knowing what the problem is without seeing the essai file. The
way your makefile is written, bash runs essai, and essai needs to
understand how to process `-o essai.o` itself.

I'm wondering if there's been a mixup; if you're using a makefile
anyway, I don't see a reason to have it call a shell script that
compiles something into a .o file.

--
Eric Christopherson

Gary Johnson

unread,
Jul 24, 2015, 11:26:54 AM7/24/15
to vim_use
A makefile is just a set of rules that 'make' uses to determine
when and how to execute other programs. In your makefile, you
are telling 'make' that the target essai.o depends on the file
essai and that essai.o is created by executing

/bin/bash essai -o essai.o

What happens when you execute that command at the shell prompt?

Why do you think your makefile should contain the line
"#!/bin/bash"?

One does not install an object file, so it's not clear to me what
you are trying to accomplish.

Regards,
Gary

aubertin.sylvain

unread,
Jul 25, 2015, 4:09:04 AM7/25/15
to vim_use, aubertin...@sfr.fr
I deleted lines on my makefile. I kept only the 3 last lines. If I type make outside of vim it runs well my file "essai". By curiosity I should like to run my object file as easily I do with "alsamixer". Yet I don't know what to do for saving my object file; Thanks again

Gary Johnson

unread,
Jul 25, 2015, 4:49:05 AM7/25/15
to vim_use
I know nothing about alsamixer and the alsamixer man page said
nothing about object files, so I can't help you with that. It's way
off-topic for the vim_use list as well. You will probably have
better luck asking about alsamixer on superuser.

The make program, though, should run just as well from Vim as it
does from the shell. So, if you can run

make

successfully from the shell, then you should be able to start vim
from the shell like this,

vim -N -u NONE

and execute

:make

with the same results as you got running make from the shell. (Of
course, you may have to remove the target, essai.o, to have make run
your bash command.)

If the results of running make from the shell and from vim as
described above are the same, then there is something in your
~/.vimrc or in one of your plugins causing the problem.

If the results are still different, it could be because the
shell environments are different. The shell invoked by vim to run
make typically does not source ~/.bashrc, so any environment
settings made but not exported by your terminal session's bash will
not be visible to the make run by vim.

Regards,
Gary

aubertin.sylvain

unread,
Jul 25, 2015, 2:34:28 PM7/25/15
to vim_use, aubertin...@sfr.fr
Le vendredi 24 juillet 2015 07:59:40 UTC+2, aubertin.sylvain a écrit :
I type make on the terminal , I type :make on vim, essai runs the same way. Is it norma ?I treid your vim -N -u NONE always the same results. The object file is somewhere on the RAM. Can I not tranfer it on my disk ? Isn't there some « install » to do ?
Many regards

Gary Johnson

unread,
Jul 25, 2015, 3:17:44 PM7/25/15
to vim_use
I'm sorry, I misunderstood your question. Somehow I got it in my
head that your make command worked from the shell but not from
within Vim. I think I also misunderstood what you meant by
"install". I think I understand now.

An object file is normally created on-disk, either in the current
working directory or in a sub-directory for object files. I don't
know of any build processes that leave an image of the object file
in RAM. Since you gave the object file a name, essai.o, I would
expect it to be written to the current working directory.

Since I don't know anything about what your essai script is doing,
it's hard to do more than guess about what happened to the object
file.

You wrote that your essai script runs fine, but that you see a
message about the cyclic permutation not being correct. Could it be
that there is an error in one of your files that is preventing the
essai.o file from being created?

Is your essai script short enough that you could post it?


If there is no difference between the behavior of your makefile when
run from the shell and when run from Vim, then this is not a Vim
issue and probably should not be discussed further on this list.
Unless anyone on this list objects, I think we should take this
discussion off the list and continue it by personal e-mail.

Regards,
Gary

aubertin.sylvain

unread,
Jul 26, 2015, 1:50:09 AM7/26/15
to vim_use, aubertin...@sfr.fr
Le vendredi 24 juillet 2015 07:59:40 UTC+2, aubertin.sylvain a écrit :
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?
Where shall I go for explanations of all these -o -e etc ?? Many Thanks
Regards


Gary Johnson

unread,
Jul 26, 2015, 6:04:27 AM7/26/15
to vim_use
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

aubertin.sylvain

unread,
Jul 26, 2015, 8:30:46 AM7/26/15
to vim_use, aubertin...@sfr.fr
Le vendredi 24 juillet 2015 07:59:40 UTC+2, aubertin.sylvain a écrit :
So interpreters go step by step. So what I have to do is to use compiler for shells. I will try that:
http://www.system-linux.eu/index.php?post/2009/01/17/Compiler-script-shell
THANKS TO ALL OF YOU

Christian Brabandt

unread,
Jul 26, 2015, 10:41:27 AM7/26/15
to vim_use
Hi aubertin.sylvain!
Why do you want to compile a shell script?

Best,
Christian
--
Der Empirismus, zur Unbedingtheit { erhöht, / erweitert, } ist
ja Naturphilosophie. (Schelling.)
-- Goethe, Maximen und Reflektionen, Nr. 1323

aubertin.sylvain

unread,
Jul 27, 2015, 1:49:12 AM7/27/15
to vim_use, aubertin...@sfr.fr
Le vendredi 24 juillet 2015 07:59:40 UTC+2, aubertin.sylvain a écrit :
I do all that in order to learn how it works. Compiling shells is good for the secrets. Please,if you know well makefiles, tell me if this one seems good to you. I'll try that once I installed my shell compiler.
#makefile
all: essai.o
essai.o: essai
compiler essai essai.o
MANY THANKS



Eric Christopherson

unread,
Jul 27, 2015, 2:14:09 AM7/27/15
to vim...@googlegroups.com

The web page whose address you posted was clear about how to invoke shc. Please refer back to it, and then try the command in the shell (and by that I mean *not* inside of Vim or in a makefile) until you're comfortable with how it works.

Then see if you can apply that knowledge in a makefile. You have a good start already; but you might want to consult a makefile tutorial.

When you have it working so you can just type `make` on the command line, the :make command in Vim should also work. This really is all about general commands line/shell usage and not about Vim at all.

Gary Johnson

unread,
Jul 27, 2015, 2:26:54 AM7/27/15
to vim_use
This has nothing to do with Vim.

The compiler command and the makefile rules are going to depend on
the compiler. For shc, for example, you specify only the script
file name and the compiler creates a binary file and a C source file
whose names are derived from the script file name. You can probably
override the default binary file name, but I'll leave that for you
to discover.

Rather than ask further off-topic questions here, you can get better
answers by searching the Internet for "bash compiler" and "make
tutorial".

Regards,
Gary

John Little

unread,
Jul 27, 2015, 6:33:22 AM7/27/15
to vim_use, echrist...@gmail.com
I certainly agree with Eric and Gary in their advice, but I will mention a tip about vim and traditional makefiles: setting these vim options

:set list
:set listchars+=tab:>.

Makes visible the crucial tab character that makefiles must have at the beginning of command lines. You can put these two lines in

$HOME/.vim/after/ftplugin/make.vim

to have them invoked automatically.

Regards, John Little

Reply all
Reply to author
Forward
0 new messages