This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

makefile

Hi

I am not very familiar with "makefiles". I read that is a way to tell the compiler the order and organization of the files; I guess it is like creating a project in uvision, but i am not sure. Anyway, i have a set of files that were created with a makefile, and i don't know hot to create the project from it, can anybody help me?

Thanks

  • i have a set of files that were created with a makefile, and i don't know hot to create the project from it, can anybody help me?
    Post the makefile. I use them

    Erik

  • here is the make file, it is kind of big:

    
    WIN32OBJ=       __out__\w32C51OBJ  =       __out__\c51
    KEILROOT=D:\DEVELOP\KEIL
    
    CC	=	wpp386
    CXX	=	wpp386
    CFLAGS	=	-zq -w1 -bm -bt=NT -d2 -d__WEMU__ -dNO_KEYSOFT -d_CPU_X86 -fh=$(WIN32OBJ)stdafx.pch
    CXXFLAGS=	$(CFLAGS)
    LINK	=	wlink
    LFLAGS	=	op quiet op c sys nt debug all
    
    .EXTENSIONS:
    .EXTENSIONS: .exe .hex .obj .cpp .c
    
    
    
    OBJECTS=wemu.obj ipcmapping.obj  snifftxrx.obj KBUWB00.obj KBU00004.obj KBU00011.obj sku20003.obj sku20004.obj cmkey_s.obj #cmkey_e.obj
    
    
    TARGET	=	wemu.exe
    TARGET2 = KBU00004.hex KBU00011.hex sku20003.hex sku20004.hex cmkeyS00.hex cmkeyE00.hex kbuwb00.hex display_hex
    TMPLIST =	wemu.xxx
    
    ####### Build rules
    
    #all: MAKEDIR  $(TARGET2) .SYMBOLIC
    all: MAKEDIR $(TARGET2) .SYMBOLIC
    
             @pause
    
    MAKEDIR: .SYMBOLIC
      @if not exist $(WIN32OBJ) @mkdir $(WIN32OBJ)
      @if not exist $(C51OBJ) @mkdir $(C51OBJ)
      @if exist wemu.exe @del wemu.exe
    
    $(TARGET): $(OBJECTS)
            @if exist *.*~ del *.*~
    	@%create $(TMPLIST)
    	@%append $(TMPLIST) NAME wemu
            @for %w in ($(OBJECTS)) do @%append $(TMPLIST) FILE $(WIN32OBJ)%w
    	@$(LINK) $(LFLAGS) @$(TMPLIST)
    	@del $(TMPLIST)
            @echo ======BUILD: $(TARGET) done.=======
    
    
    display_hex: .SYMBOLIC
        -agrep IDATA $(C51OBJ)*.m51
        -agrep "CODE SIZE" $(C51OBJ)*.lst
    
    
    ####### Compile
    
    .obj: $(WIN32OBJ)
    .cpp: ..c  : ..c.obj: .AUTODEPEND
     @echo --------win32 compiling $^&-----------------------
     @$(CXX) $(CXXFLAGS) $(INCPATH) -fo=$(WIN32OBJ)$^&.obj $^&.c
    
    .cpp.obj: .AUTODEPEND
     @echo --------win32 compiling $^&-----------------------
     @$(CXX) $(CXXFLAGS) $(INCPATH) -fo=$(WIN32OBJ)$^&.obj $^&.cpp
    
    cmkeyS00.obj: msc\cmkey_s.cpp .AUTODEPEND
     @echo --------win32 compiling $^&-----------------------
     @$(CXX) $(CXXFLAGS)/DCMKEY_S $(INCPATH) -fo=$(WIN32OBJ)$^&.obj msc\cmkey_s.cpp
    
    #cmkeyE00.obj: cmkey000.c .AUTODEPEND
    # @echo --------win32 compiling $^&-----------------------
    # $(CXX) $(CXXFLAGS) /DCMKEY_E $(INCPATH) -fo=$(WIN32OBJ)$^&.obj $[&.c
    
    
    
    
    
    C51DEFINES=DEFINE(_CPU_8051) OPTIMIZE(SIZE)
    
    #OUTPUTLOG=output.lg
    OUTPUTLOG=con
    
    .hex: $(C51OBJ)
    
    KBU00004.hex: KBU00004.c
     @echo --------compiling $^&-----------------------
     @SET PATH=$(KEILROOT)\C51\BIN;$(%PATH)
     @SET TMP=C:\TEMP
     @SET C51INC=$(KEILROOT)\C51\INC\Atmel
     @SET C51LIB=$(KEILROOT)\C51\LIB
     @C51.EXE $^&.c $(C51DEFINES) PRINT($(C51OBJ)$^&.lst) OBJECT($(C51OBJ)$^&.obj)  #SMALL ROM(SMALL)
     @-bl51.EXE $(C51OBJ)$^&.obj TO $(C51OBJ)$^&.bl REGFILE ($(C51OBJ)$^&.ORC) PRINT ($(C51OBJ)$^&.m51) CODE (0X0000-0X0FFF)
     @OH51.EXE $(C51OBJ)$^&.bl HEX($(C51OBJ)$^&.hex)
     @echo C51: HEX $^& done.
     @del $(C51OBJ)$^&.bl
     @del $(C51OBJ)$^&.obj
     @del $(C51OBJ)$^&.orc
    # @-lpp $(C51OBJ)$^&.lst indent(30)
     @hexc 4051 $(C51OBJ)$^&.hex Y:\atprog\$^&.hex
    
    
    sku20003.hex: sku20003.c
     @echo --------compiling $^&-----------------------
     @SET PATH=$(KEILROOT)\C51\BIN;$(%PATH)
     @SET TMP=C:\TEMP
     @SET C51INC=$(KEILROOT)\C51\INC\Atmel
     @SET C51LIB=$(KEILROOT)\C51\LIB
    
     @C51.EXE $^&.c $(C51DEFINES) PRINT($(C51OBJ)$^&.lst) OBJECT($(C51OBJ)$^&.obj)  #SMALL ROM(SMALL)
     @-bl51.EXE $(C51OBJ)$^&.obj TO $(C51OBJ)$^&.bl REGFILE ($(C51OBJ)$^&.ORC) PRINT ($(C51OBJ)$^&.m51) CODE (0X0000-0X0FFF)
     @OH51.EXE $(C51OBJ)$^&.bl HEX($(C51OBJ)$^&.hex)
     @echo C51: HEX $^& done.
     @del $(C51OBJ)$^&.bl
     @del $(C51OBJ)$^&.obj
     @del $(C51OBJ)$^&.orc
    # @-lpp $(C51OBJ)$^&.lst indent(30)
     @hexc 4051 $(C51OBJ)$^&.hex Y:\atprog\$^&.hex
    
    
    
    KBU00011.hex: KBU00011.c
     @echo --------compiling $^&-----------------------
     @SET PATH=$(KEILROOT)\C51\BIN;$(%PATH)
    
     @SET TMP=C:\TEMP
     @SET C51INC=$(KEILROOT)\C51\INC\Atmel
     @SET C51LIB=$(KEILROOT)\C51\LIB
     @C51.EXE $^&.c $(C51DEFINES) PRINT($(C51OBJ)$^&.lst) &
            OBJECT($(C51OBJ)$^&.obj)  #SMALL ROM(SMALL)
     @-bl51.EXE $(C51OBJ)$^&.obj TO $(C51OBJ)$^&.bl REGFILE ($(C51OBJ)$^&.ORC) PRINT ($(C51OBJ)$^&.m51) CODE (0X0000-0X0FFF)
     @OH51.EXE $(C51OBJ)$^&.bl HEX($(C51OBJ)$^&.hex)
     @echo C51: HEX $^& done.
     @del $(C51OBJ)$^&.bl
     @del $(C51OBJ)$^&.obj
     @del $(C51OBJ)$^&.orc
    # @-lpp $(C51OBJ)$^&.lst indent(30)
     @hexc 4051 $(C51OBJ)$^&.hex Y:\atprog\$^&.hex
    
    
    sku20004.hex: sku20004.c
     @echo --------compiling $^&-----------------------
     @SET PATH=$(KEILROOT)\C51\BIN;$(%PATH)
     @SET TMP=C:\TEMP
     @SET C51INC=$(KEILROOT)\C51\INC\Atmel
     @SET C51LIB=$(KEILROOT)\C51\LIB
     @C51.EXE $^&.c $(C51DEFINES) PRINT($(C51OBJ)$^&.lst) OBJECT($(C51OBJ)$^&.obj)  #SMALL ROM(SMALL)
     @-bl51.EXE $(C51OBJ)$^&.obj TO $(C51OBJ)$^&.bl REGFILE ($(C51OBJ)$^&.ORC) PRINT ($(C51OBJ)$^&.m51) CODE (0X0000-0X0FFF)
     @OH51.EXE $(C51OBJ)$^&.bl HEX($(C51OBJ)$^&.hex)
     @echo C51: HEX $^& done.
     @del $(C51OBJ)$^&.bl
     @del $(C51OBJ)$^&.obj
     @del $(C51OBJ)$^&.orc
    # @-lpp $(C51OBJ)$^&.lst indent(30)
     @hexc 4051 $(C51OBJ)$^&.hex Y:\atprog\$^&.hex
    
    
    cmkeyS00.hex: cmkey000.c
     @echo --------compiling $^&-----------------------
     @SET PATH=$(KEILROOT)\C51\BIN;$(%PATH)
     @SET TMP=C:\TEMP
     @SET C51INC=$(KEILROOT)\C51\INC\Atmel
     @SET C51LIB=$(KEILROOT)\C51\LIB
     C51.EXE $[&.c $(C51DEFINES) DEFINE(CMKEY_S) PRINT($(C51OBJ)$^&.lst) OBJECT($(C51OBJ)$^&.obj)  #SMALL ROM(SMALL)
     @-bl51.EXE $(C51OBJ)$^&.obj TO $(C51OBJ)$^&.bl REGFILE ($(C51OBJ)$^&.ORC) PRINT ($(C51OBJ)$^&.m51) CODE (0X0000-0X0FFF)
     @OH51.EXE $(C51OBJ)$^&.bl HEX($(C51OBJ)$^&.hex)
     @echo C51: HEX $^& done.
     @del $(C51OBJ)$^&.bl
     @del $(C51OBJ)$^&.obj
     @del $(C51OBJ)$^&.orc
    # @-lpp $(C51OBJ)$^&.lst indent(30)
     @hexc 4051 $(C51OBJ)$^&.hex Y:\atprog\$^&.hex
    
    cmkeyE00.hex: cmkey000.c
     @echo --------compiling $^&-----------------------
     @SET PATH=$(KEILROOT)\C51\BIN;$(%PATH)
     @SET TMP=C:\TEMP
     @SET C51INC=$(KEILROOT)\C51\INC\Atmel
     @SET C51LIB=$(KEILROOT)\C51\LIB
     C51.EXE $[&.c $(C51DEFINES) DEFINE(CMKEY_E) PRINT($(C51OBJ)$^&.lst) OBJECT($(C51OBJ)$^&.obj)  #SMALL ROM(SMALL)
     @-bl51.EXE $(C51OBJ)$^&.obj TO $(C51OBJ)$^&.bl REGFILE ($(C51OBJ)$^&.ORC) PRINT ($(C51OBJ)$^&.m51) CODE (0X0000-0X0FFF)
     @OH51.EXE $(C51OBJ)$^&.bl HEX($(C51OBJ)$^&.hex)
     @echo C51: HEX $^& done.
     @del $(C51OBJ)$^&.bl
     @del $(C51OBJ)$^&.obj
     @del $(C51OBJ)$^&.orc
    # @-lpp $(C51OBJ)$^&.lst indent(30)
     @hexc 4051 $(C51OBJ)$^&.hex Y:\atprog\$^&.hex
    
    
    
    
    kbuWB00.hex: kbuWB00.c
     @echo --------compiling $^&-----------------------
     @SET PATH=$(KEILROOT)\C51\BIN;$(%PATH)
     @SET TMP=C:\TEMP
     @SET C51INC=$(KEILROOT)\C51\INC\Atmel
     @SET C51LIB=$(KEILROOT)\C51\LIB
     C51.EXE $[&.c $(C51DEFINES) PRINT($(C51OBJ)$^&.lst) OBJECT($(C51OBJ)$^&.obj)  #SMALL ROM(SMALL)
     @-bl51.EXE $(C51OBJ)$^&.obj TO $(C51OBJ)$^&.bl REGFILE ($(C51OBJ)$^&.ORC) PRINT ($(C51OBJ)$^&.m51) CODE (0X0000-0XFFFF)
     @OH51.EXE $(C51OBJ)$^&.bl HEX($(C51OBJ)$^&.hex)
     @echo C51: HEX $^& done.
     @del $(C51OBJ)$^&.bl
     @del $(C51OBJ)$^&.obj
     @del $(C51OBJ)$^&.orc
    
    

  • as far as I can see It will run if you have the tools at a KEILROOT directory.

    It is, as made quite a blabbermouth, I prefer commandfiles that only "speak" when trouble or completely done.

    Erik

  • The full workings of that makefile won't be easily reproducible in uVision (at least not in uVision2), because that won't make multiple targets in a single run.

    To build those .hex files in uVision would be quite trivial: it won't take more than creating a project, adding one .c file to it, maybe selecting a few options, and that's it. Then hit "build" and compare the .lst files to those you got from the makefile build. Lather, rinse, repeat until they're identical.

  • because that won't make multiple targets in a single run.

    I do that routinely with .bat files

    an example:

    if "%1"=="s" goto gams
    call makp ar %2
    call makp br %2
    call makp as %2
    call makp bs %2
    if "%1"=="p" goto end
    :gams
    call maks a	 %2
    call maks aa %2
    call maks b	 %2
    call maks ba %2
    call maks l	 %2
    rem call maks t	 %2
    :end
    if anyone is interested in seing makp and maks, just ask

    Erik

  • "that [uVision] won't make multiple targets in a single run"

    Yes, that can be a pain.
    uVision could really do with a "Build ALL Targets" option.

  • I created a project and included one of the files (which I think it is the main file) and the compilation did not show any errors, hopefully that will work.

    I will simulate it later and see if that works, but anyway i still don't know how the makefile works.

    William

  • Yes, that can be a pain.
    uVision could really do with a "Build ALL Targets" option.


    I have several "build multiple" cases and I really doubt there is any way to make an IDE such as uVision do it.

    1) I mostly build just one - after all you can only debug one build at a time and use a file like the above to build them all for buildability test or release.
    2) the "external variables" to create the individual build of the multiples can have many different formats. Some cases it is file select and some cases it is #ifdef control and sometimes it file select and rename and sometimes .... .

    So, I would say "forget IDE multibuild, but make the uVision components run smoothly from the commandline (basically they do)" and leave the multibuild to our build files. Just please, pretty please stop bugging us with "why do you not use the IDE".

    Should anyone have any illusions about multibuild being "simple" I'll gladly post the .bats

    Erik

  • I have several "build multiple" cases and I really doubt there is any way to make an IDE such as uVision do it.

    Sure there is. All it takes is to allow targets to be added as "things to be built" to other targets. Then all you have to do is to have a main target that includes all others, and building that will build them all, one after the other. uVision already gets the rest of the job right (easier than with makefiles, actually): it recognizes that if you change targets, all previous .obj files have to be recompiled, so "change target, build target" is automatically equivalent to "change target, rebuild target from scratch".

  • Hans-Bernhard,
    You just totally bypass the "target switching"

    an example from a .bat

    IF "%1"=="a"  goto lca
    IF "%1"=="aa" goto lcaa
    IF "%1"=="b"  goto lcb
    IF "%1"=="ba" goto lcba
    IF "%1"=="l"  goto lcl
    IF "%1"=="t"  goto lct
    :lca
    copy ..\sc\cond\sfa.h  condit.h		>..\trash\trashbin
    copy ..\ss\usmaina.c   usmain.x		>..\trash\trashbin
    copy ..\ss\usledst1.c  usledstb.x	>..\trash\trashbin
    copy ..\ss\ussgndv1.c  ussgndvr.x	>..\trash\trashbin
    goto lxx

    Erik