make coomand in Batch file

Discussion in 'Programmer's Corner' started by prj1901, Aug 12, 2015.

  1. prj1901

    Thread Starter New Member

    Aug 12, 2015
    2
    0
    what is meaning of in batch file

    %MAKEDIR%\cmd\make %1 %2 %3 %4 %5 %6 %7 %8 %9

    What are this numbers 1,2, 3 etc.

    What mean by command line parameters? Any example?
     
  2. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    Yes, the %1 %2, etc are parameters passed into the batch file. It appears that each parameter is going to be a directory that the user wants to create. This looks to be part of a larger batch file, no? Could you post the whole thing?

    You call the batch file and add parameters as follows:

    Code (Text):
    1. call <batchFileName> param1 param2 param3 param4.....
    %1 would be "param1", %2 would be "param2", etc.

    Matt
     
  3. nerdegutta

    Moderator

    Dec 15, 2009
    2,517
    785
    A command line parameter is a variable/parameter after the executable file.

    I'm on a Linux system, and the notepad program I use is called gedit. If I want to open a textfile called notes.txt with notepad. I can open a terminal window and write :
    Code (Text):
    1. gedit notes.txt
    2.  
    notes.txt is in this example the parameter or %1
     
  4. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,812
    834
    Trying to understand your example... Are you trying to create a program in C? (or some other programming language?) Also, do you understand what %MAKEDIR% is?
     
  5. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    I think he's looking at a previously written batch file.

    MAKEDIR is a variable that must have been declared and set previously, which is why I asked if there was more to the code.
     
    Last edited: Aug 12, 2015
  6. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,812
    834
    I agree with you. That's why I asked the TS if he understood what %MAKEDIR% is.
     
  7. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    Sorry, the second part of my post was more aimed at the OP, not at you. Let me add a line break to make it a bit clearer.... :p
     
  8. prj1901

    Thread Starter New Member

    Aug 12, 2015
    2
    0
    Yes

    Hi, first Sorry for late reply.

    Yes MAKEDIR is path variable.

    For your reference as you asked.

    [QUOTE
    @echo off
    rem *****************************************************************************
    rem * MAKEDIR has to be set to Make root directory
    rem * There MUSTN'T be any blanks between the '=' sign and the path string
    rem * Example:
    rem * set MAKEDIR =..\..\Make
    rem *****************************************************************************

    cd ..\
    set MAKEDIR =..\..\..\Make

    rem *****************************************************************************
    rem * DO NOT EDIT ANYTHING BELOW THIS
    rem *****************************************************************************

    if "%MAKEDIR % "==" " goto ErrorNotSet
    if not exist %MAKEDIR % goto ErrorWrongPath


    set PATH_OLD=%PATH%
    set PATH=%MAKEDIR %\cmd;%PATH%
    set CYGWIN=nodosfilewarning

    %MAKEDIR %\cmd\make %1 %2 %3 %4 %5 %6 %7 %8 %9

    set PATH=%PATH_OLD%
    set PATH_OLD=

    goto End

    :ErrorNotSet
    echo ************************************************************************
    echo warning: MAKEDIR has to be set to Make\cmd directory!
    echo ************************************************************************
    goto End

    :ErrorWrongPath
    echo ************************************************************************
    echo warning: %MAKEDIR % does not exist
    echo ************************************************************************
    goto End

    :End
    set MAKEDIR =

    [/QUOTE]

    Here we pass a make command to this batch file, named exam.bat -j8 rebuild.

    So from where this parameter is coming.
    From make file? I did not find rebuild phony in make file also.
    Actually i want to understand how this building process is happening.[/QUOTE]
     
  9. WBahn

    Moderator

    Mar 31, 2012
    17,777
    4,805
    The "make" command is a utility that can take a number of arguments. All the string of %1 to %9 is doing is passing up to nine arguments that were provided on the command line when the batch file was called and passing them to the call to the "make" utility. If you have fewer than nine arguments, the rest are blank. If you have more than nine, then the additional ones get lost.

    The %MAKEDIR% is simply replacing that string with what MAKEDIR is currently equal to. There is a DOS command called makedir -- for make directory -- which I think let DerStrom8 a bit astray. In this case, MAKEDIR is just an environment variable that stores the root directory for the make command. The executable for the make utility is located in the "cmd" directory underneath the directory pointed to by MAKEDIR.
     
  10. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    Nope, did not lead me astray at all. %MAKEDIR% is a variable (not a command), and I was asking where it was declared.
     
  11. WBahn

    Moderator

    Mar 31, 2012
    17,777
    4,805
    I was referring to the statement, "It appears that each parameter is going to be a directory that the user wants to create." What led you to this conclusion (out of curiosity)?
     
  12. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    It was a complete guess, to be honest. Judging by the name, I expected the program was going to be used for creating directories, and parameters containing locations would be the most obvious. I couldn't say for sure, though, without seeing the rest of the code (which the OP eventually posted).
     
  13. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,812
    834
    Makes sense when you're not familiar with the program "make".
     
    DerStrom8 likes this.
  14. DerStrom8

    Well-Known Member

    Feb 20, 2011
    2,428
    1,328
    Which I am not :p
     
Loading...