batch file ?

Discussion in 'Programmer's Corner' started by Mathematics!, Mar 31, 2010.

  1. Mathematics!

    Thread Starter Senior Member

    Jul 21, 2008
    I am have a little trouble figureing out how to get this batch file to work?

    Code ( (Unknown Language)):
    2. [FONT=Courier]set compiler = gcc[/FONT]
    3. [FONT=Courier]set linker   = ld[/FONT]
    4. [FONT=Courier]set cflags  = -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -c[/FONT]
    5. [FONT=Courier]set lflags   = -T link.ld[/FONT]
    6. [FONT=Courier]set bin      = kernel.bin[/FONT]
    8. [FONT=Courier]for /f %%e IN ('dir /b *.c') do %compiler% %cflags% %%e[/FONT]
    10. [FONT=Courier]rem for /f %%d IN ('dir /b *.o') do %linker% %lflags% %%d[/FONT]
    13. [FONT=Courier]echo Cleaning up object files...[/FONT]
    14. [FONT=Courier]rem del *.o[/FONT]
    15. [FONT=Courier]echo Done![/FONT]
    16. [FONT=Courier]pause[/FONT]
    What is not working is after the do command in the for loop I want to use my set varibles to compile all the .c files in the current directory.
    I have tried %%var and %var% ...
    I know I am missing something curious if anybody knows how to fix it.
    It should be a quick fix hopefully.
    After I get the compiled for working I want to beable to get the linker for loop working I know their has to be a way to concatenate all the .o files..
    Basically this batch file is just for compiling and linking all .c and .o files together into a bin for my os kernel

    Thanks for any help
    Last edited: Mar 31, 2010