start and stop a program by make

View: New views
4 Messages — Rating Filter:   Alert me  

start and stop a program by make

by Martin Mensch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hello,
 
I was posting this already in help-make, and Paul Smith advised me to try it here. So first my original posting and then a part of the answer of Paul which is related to UNIX. Maybe someone knows how things are with WinXP.
 
my original posting:
I would like to start a program by using a make rule. I know that compilers and so on are all programs. The ones that I want to start do not finish and so don't send an error code back and as much as I have seen make then just waits for the error code to come. Here is an example:
 
my_rule:
    program1.exe arg1 arg2
    program2.exe arg1 arg2
 
This should start program1 and leave it running and then start program2 and leave it running.
But what I see is this:
program1 starts and nothing else happens. When I manually stop program1 then program2 starts.
 
Another very good thing would be to have a rule like this:
 
my_rule:
    stop program1
    stop program2
 
If they are not running it should do nothing, maybe the '-' prefix will do this?
 
(using make 3.81 under WinXP)
 
 
part of Pauls answer:
There is no way for make to not wait for a program.
 
If you had a UNIX system with a normal shell, you could put the process
into the background, like this:
 
 foo:
  program1 &
  program2 &
 
(the "&" tells the shell to put the program into the background).  You
mentioned you're using Windows, but I don't know if you're using Cygwin
(which has, I believe, a UNIX-style shell) or MingW or whatever.  I
don't know how to put a program into the background on Windows.
 
I don't use Cygwin, as much as I know my GNU stuff is based on MinGW. But I am not an expert on this.
 
Thank you for any help
 
Martin

_______________________________________________
Make-w32 mailing list
Make-w32@...
http://lists.gnu.org/mailman/listinfo/make-w32

Parent Message unknown Re: start and stop a program by make

by Johan Bezem :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Martin,

you may take a look at the "start" command in Windows, http://ss64.com/nt/start.html
Unless you specify the option "/wait", it will do what you seem to need.
If your program doesn't provide its own window, you may need to add a separate CMD shell, like in
  start cmd.exe /c "dir c:\ /P"
And since "Start" seems to be a built-in command for CMD.EXE, for make to perform the operation you may need an extra CMD call in the make rule or provide a batch file for the commands in the make rule:
MyRule:
  cmd /c "start myprogram.exe"
Combinations possible, and possibly necesary.

HTH,

Johan
--
JB Enterprises - Johan Bezem         Tel:   +49 172 5463210
Software Architect - Project Manager Fax:   +49 172 50 5463210
Realtime / Embedded Consultant       Email: j.bezem@...
Design - Development - Test - QA     Web:   http://www.bezem.de

----- original message --------

Subject: start and stop a program by make
Sent: Mon, 19 Oct 2009
From: Martin Mensch

Hello, I was posting this already in help-make, and Paul Smith advised me to try it here. So first my original posting and then a part of the answer of Paul which is related to UNIX. Maybe someone knows how things are with WinXP. my original posting:I would like to start a program by using a make rule. I know that compilers and so on are all programs. The ones that I want to start do not finish and so don't send an error code back and as much as I have seen make then just waits for the error code to come. Here is an example: my_rule:
    program1.exe arg1 arg2
    program2.exe arg1 arg2 This should start program1 and leave it running and then start program2 and leave it running.
But what I see is this:
program1 starts and nothing else happens. When I manually stop program1 then program2 starts. Another very good thing would be to have a rule like this: my_rule:
    stop program1
    stop program2 If they are not running it should do nothing, maybe the '-' prefix will do this? (using make 3.81 under WinXP)  part of Pauls answer:There is no way for make to not wait for a program. If you had a UNIX system with a normal shell, you could put the process
into the background, like this:  foo:
  program1 &
  program2 & (the "&" tells the shell to put the program into the background).  You
mentioned you're using Windows, but I don't know if you're using Cygwin
(which has, I believe, a UNIX-style shell) or MingW or whatever.  I
don't know how to put a program into the background on Windows.
 I don't use Cygwin, as much as I know my GNU stuff is based on MinGW. But I am not an expert on this. Thank you for any help Martin

--- original message end ----



_______________________________________________
Make-w32 mailing list
Make-w32@...
http://lists.gnu.org/mailman/listinfo/make-w32

Parent Message unknown Re: start and stop a program by make

by Martin Mensch, mm-uC-systems :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi Duane,
 
thank you for your answer. Here is what I tried
 
> Get help on the start command by using the command: start /?
 
> Mind you, it's rather a contortion of make to start things and not finish them.

> (I'd be curious what you're up to).
 
Nothing special, I want to start OpenOCD, a GDB server for debugging and programing microcontrollers and then start insight and command it to flash the program.
 
>That said...
 
>This might work ...
>my_rule:
>    start "" program1.exe arg1 arg2
>    start "" program2.exe arg1 arg2
 
No, it produces:
usr/bin/sh: start: command not found
 
>If the above doesn't work you might try either this...
>my_rule:
>    start "" cmd /c program1.exe arg1 arg2
>    start "" cmd /c program2.exe arg1 arg2
 
Also
usr/bin/sh: start: command not found
 
>or this...
>my_rule:
>    cmd /c start "" program1.exe arg1 arg2
>    cmd /c start "" program2.exe arg1 arg2
 
This starts a new process cmd.exe but also does not return. Further program1 is not started, at least I can't see it in the windows task manager.
 
So, no success so far. But I have learned that this is not the usual way make is used.
....
Now I tried one more thing and this works (it is a bit of a workaround but anyway..)
 
my_rule:
    @rm -f start.bat
    @echo start program1.exe arg1 arg2 >> start.bat
    @echo start program2.exe arg1 arg2 >> start.bat
    start.bat
 
This writes the commands to a batch file start.bat and then executes this.
 
 
Thank you for your help
 
Martin
 
 

_______________________________________________
Make-w32 mailing list
Make-w32@...
http://lists.gnu.org/mailman/listinfo/make-w32

Parent Message unknown Re: start and stop a program by make

by Martin Mensch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hello,
 
I received an email on my posting, I thought it would automatically be in the thread, but it isn't.
So here is the contents of this email (I left the name out, maybe the writer wants to be anonymous)
 
#####
 
Get help on the start command by using the command: start /?
 
Mind you, it's rather a contortion of make to start things and not finish them.
(I'd be curious what you're up to).
 
That said...
 
This might work ...
my_rule:
    start "" program1.exe arg1 arg2
    start "" program2.exe arg1 arg2
 
If the above doesn't work you might try either this...
my_rule:
    start "" cmd /c program1.exe arg1 arg2
    start "" cmd /c program2.exe arg1 arg2
 
or this...
my_rule:
    cmd /c start "" program1.exe arg1 arg2
    cmd /c start "" program2.exe arg1 arg2
 
Good luck,
#####
 
 

_______________________________________________
Make-w32 mailing list
Make-w32@...
http://lists.gnu.org/mailman/listinfo/make-w32