How to get debug and release build working with a custom makefile?

How to get debug and release build working with a custom makefile?

Basic UserBasic User

    Sep 20, 2015#1

    Hi UEStudio experts,

    I am a newbie. I was able to create a custom makefile using mingw32-make.exe instead of the internal mymake.exe. When I created the project in UEStudio, I had to pick either the debug directory or the release directory for my build. I also configured the MakeTool = MyMakeTool.bat option correctly in the select compiler section. However, when I try to build using the custom makefile, the build and rebuild only work if I put all my source files and my custom makefile in either the debug directory or the release directory (depending on how I wanted to build). But if I kept my source files and my custom makefile in the project directory instead, the build complains it cannot find the makefile and the source files. I know there must be an easy solution without putting some awkward syntaxes in the makefile such as ..\filename etc., please help. Finally, my custom compiler is in the c:\MinGW\ and c:\MinGW\bin\ and are also configured correctly. Thanks in advance.

    All my source files and the custom makefile is stored in the directory c:\idddbmp\

    MyMakeTool.bat contains the following lines:

    Code: Select all

    @echo off
    Path=c:\idddbmp;C:\Program Files (x86)\IDM Computer Solutions\UEStudio\;%PATH%
    my custom makefile contain the following lines:

    Code: Select all

    default: tsapnd.exe
    tsapnd.exe: tsapnd.c
    	g++ -Wall tsapnd.c -lm -o tsapnd
    glbxapnd: glbxapnd.c
    	gcc -Wall glbxapnd.c -lm -o glbxapnd
    ibkapnd: ibkapnd.c
    	gcc -Wall ibkapnd.c -lm -o ibkapnd
    glbxcmd: glbxcmd.c
    	gcc -Wall glbxcmd.c -lm -o glbxcmd
    glbxrun: glbxrun.c
    	gcc -Wall glbxrun.c -lm -o glbxrun

    Grand MasterGrand Master

      Sep 20, 2015#2

      UEStudio makes the debug or the release directory the current directory before starting the build. This is done to get all the files created by compiler and linker (object files, etc.) stored in the appropriate directory. The makefile created by UEStudio itself contains the source files (*.c, *.h, ...) with full paths.

      As your makefile just contains the file names without full path or with correct relative path, you could do following:
      1. Open Build - Set Compiler Options and specify for Debug directory and for Release directory just . as directory.

        This means the debug and release directory is the project directory with your source files. Of course this means also all files produced by the compiler and linker are generated in the project files directory containing also the source files. (I don't like that.)

        And if your makefile contains different compiler and linker options depending on debug or release build, you need to run a rebuild after switching configuration.
      2. You modify your custom make tool to create the makefile with source and header files referenced with full path or with correct relative path which would mean all source and header files start with C:\idddbmp\ respectively ..\ to get a successful build.
      3. You edit the compiler configuration file of the project by replacing the line Cmd0 = in section [Build] to call a batch file (with appropriate parameters).

        The batch file copies all *.c and *.h from parent directory to current directory (debug or release directory), runs the entire build, and finally deletes all *.c and *.h files in current directory. As just 2 commands are necessary to copy all *.c and *.h files from parent to current directory before build and also only 1 command is necessary to delete all *.c and *.h files in current directory after build, it would be also possible to rename Cmd0 = to Cmd2 = and insert

        Cmd0 = copy /B /Y ..\*.c . >nul
        Cmd1 = copy /B /Y ..\*.h . >nul
        Cmd2 = build command
        Cmd3 = del /Q *.c *.h

        But I don't recommend this solution as the warnings and error messages created by compiler/linker reference the files in debug/release directory not existing anymore. Well, if the compiler/linker outputs the file names without full path, the captured warnings and error messages could be nevertheless processed by UEStudio because UES would find the files referenced with file name only in project directory.

        For Cmd0 = in section [.C] nothing must be changed as UES passes the name of active .c file with full path to the compiler.
      Best regards from an UC/UE/UES for Windows user from Austria

      Basic UserBasic User

        Sep 20, 2015#3

        Wow. Your knowledge in UEStudio is exceptional. Thank you for sharing! First and second options worked immediately for me, haven't tried the third one yet. Thanks. :)