[Gambas-user] Executing make from a Gambas program

Cedron Dawg cedron at exede.net
Sat Mar 9 16:38:13 CET 2019


I've got a stumper here.

Emboldened by the fact I can edit .c files in the Gambas IDE, I thought it would be really neat if I could have my test program run a "make" on the .c code, capture the results in a string.  I could then have the progarm proceed for a clean compile and halt if there are errors.

Okay, so I'd me running make a whole lot times unnecessarily when I am working on the test program, but I can always temporarily comment out the compiling call.

So, I found "EXEC Command TO Variable" in the help.  Perfect.  Or so I thought.  I am getting unexpected (to me) results.

In my Gambas program:
--------------------------
   Exec ["make", "~/Gambas/libGambas/NiceTerminal/"]
   Exec ["/usr/bin/make", "~/Gambas/libGambas/NiceTerminal/makefile"]
   Shell "make ~/Gambas/libGambas/NiceTerminal/makefile"
--------------------------

the output I get:

--------------------------
make: Nothing to be done for `<path to home>/Gambas/libGambas/NiceTerminal/makefile'.
make: Nothing to be done for `<path to home>/Gambas/libGambas/NiceTerminal/'.
make: Nothing to be done for `<path to home>/Gambas/libGambas/NiceTerminal/makefile'.
--------------------------

The "<path to home>" is my actual directory. 

When I rename the makefile to "makefil", I get:

--------------------------
make: *** No rule to make target `<path to home>/Gambas/libGambas/NiceTerminal/makefile'.  Stop.
make: Nothing to be done for `<path to home>/Gambas/libGambas/NiceTerminal/'.
make: *** No rule to make target `<path to home>/Gambas/libGambas/NiceTerminal/makefile'.  Stop.
--------------------------

When I check the little check at [Debug/Use terminal emulator], I get

--------------------------
make: Nothing to be done for `/home/hans/Gambas/libGambas/NiceTerminal/'.
make: *** No rule to make target `/home/hans/Gambas/libGambas/NiceTerminal/makefile'.  Stop.
make: *** No rule to make target `/home/hans/Gambas/libGambas/NiceTerminal/makefile'.  Stop.
--------------------------

When I run "make from the [Tools/Open Terminal] or use a system terminal, for make,  I get:

--------------------------
make: *** No targets specified and no makefile found.  Stop.     <-- System terminal
make: *** No targets specified and no makefile found.  Stop.     <-- Tool opened when Emulate on
make: *** No targets specified and no makefile found.  Stop.     <-- Tool opened when Emulate off
--------------------------

Finally, I rename the file back to "makefile", when I run make in the terminal I get

-----------------------------------------------------------------
cc -c -Wall -Werror -fpic ./libGambas_NiceTerminal.c 
./libGambas_NiceTerminal.c: In function ‘NT_GetData’:
./libGambas_NiceTerminal.c:46:1: error: ‘dfddfd’ undeclared (first use in this function)
 dfddfd
 ^
./libGambas_NiceTerminal.c:46:1: note: each undeclared identifier is reported only once for each function it appears in
./libGambas_NiceTerminal.c:50:1: error: expected ‘;’ before ‘}’ token
 }
 ^
make: *** [libGambas_NiceTerminal.o] Error 1
-----------------------------------------------------------------

Which clearly shows my deliberately mucked up file.  Same happens in the terminals open up from within Gambas.

My makefile looks like this:
----------------------------------
./libGambas_NiceTerminal.so: ./libGambas_NiceTerminal.o 
<tab>gcc -shared -o ./libGambas_NiceTerminal.so ./libGambas_NiceTerminal.o

./libGambas_NiceTerminal.o: ./libGambas_NiceTerminal.c 
<tab>gcc -c -Wall -Werror -fpic ./libGambas_NiceTerminal.c 
----------------------------------

Where I have inserted the <tab> where there is a tab character.

Weird, different output from make in different contexts.  Any clues?

Has anybody else tried this and perhaps know a "correct way"?

Thanks,

Ced



More information about the User mailing list