Page 1 of 1

Makefile generators

Posted: Mon Sep 28, 2020 7:21 pm
by Jarod42
I'm on Windows, using Msys.

I tried different makefile generator, but only the Default works for me:

- CMake and NMakefile for visual are out of scope, I use neither one.

-GNU makefile one step build : Fail

C:\WINDOWS\system32\cmd.exe /C ""C:/msys64/mingw64/bin/mingw32-make.exe" -j8 -e -f Makefile"

Code: Select all

----------Building project:[ MyProject - Release ]----------
mingw32-make[1]: *** No rule to make target 'Release/up_up_src_mylib.c.o', needed by 'Release/libmylib.dll'.  Stop.
mingw32-make[1]: Entering directory 'C:/Code/MyProject/project/codelite'
mingw32-make[1]: Leaving directory 'C:/Code/MyProject/project/codelite'
mingw32-make: *** [Makefile:5: All] Error 2
====0 errors, 0 warnings====
- Codelite make generator: Fail

Code: Select all

C:\WINDOWS\system32\cmd.exe /C ""C:/msys64/mingw64/bin/mingw32-make.exe" -j8 -e -f  Makefile"
----------Building project:[ MyProject - Release ]----------
mingw32-make[1]: Entering directory 'C:/Code/MyProject/project/codelite'
/usr/bin/sh: -c: line 1: syntax error: unexpected end of file
mingw32-make[1]: *** [MyProject.mk:88: MakeIntermediateDirs] Error 1
mingw32-make[1]: *** Waiting for unfinished jobs....
<built-in>: fatal error: opening dependency file ./build-Release//up_up_src_mylib.c.o.d: No such file or directory
compilation terminated.
mingw32-make[1]: *** [MyProject.mk:103: build-Release//up_up_src_mylib.c.o.d] Error 1
mingw32-make[1]: Leaving directory 'C:/Code/MyProject/project/codelite'
mingw32-make: *** [Makefile:5: All] Error 2
====0 errors, 0 warnings====
With (strange) Projecct.mk line 87-92

Code: Select all

MakeIntermediateDirs:
	@if not exist ".\build-$(ConfigurationName)\" mkdir ".\build-$(ConfigurationName)\"
	@if not exist "".\build-$(ConfigurationName)\lib"" mkdir "".\build-$(ConfigurationName)\lib""

:
	@if not exist ".\build-$(ConfigurationName)\" mkdir ".\build-$(ConfigurationName)\"
- mixed \ and / for paths in Makefile
- double "
- empty makefile rule

Are they some doc about generator?
Are there some configuration needed for those generators?
Are they restricted to other OS/compiler/...

Re: Makefile generators

Posted: Thu Oct 01, 2020 9:58 pm
by eranif
The problem is that you are using MSYS on Windows (not the terminal, but the gcc that comes with it)
This configuration is not "native" and was not tested.

You can:
1. Install MinGW compiler
2. Use the "default" (although I personally prefer the "CodeLite Make Generator")

The main problem is that the SHELL used is /usr/bin/bash by default under MSYS, which does not work with
the mkdir command of Windows for several reasons:

- mkdir on Windows does not have the -p option, so the syntax must be in the form of @if not exist path\to\dir mkdir path\to\dir
- mkdir on Windows does not work with /... this is why you see the mixed "\" and "/"

I will add a new builder for Windows: "CodeLite Makefile Generator - UNIX", which is identical to the "CodeLite Make Generator", but uses mkdir -p and forward slashes

Eran

Re: Makefile generators

Posted: Thu Oct 01, 2020 11:57 pm
by eranif
I just added new builder "CodeLite Makefile Generator - UNIX" that will generate UNIX compatible Makefile on Windows
It's committed in git master

Re: Makefile generators

Posted: Sat Oct 03, 2020 8:03 pm
by Jarod42
> You can:
> 1. Install MinGW compiler

Not sure what you mean, as mingw tools are installed for msys2 through pacman.
I would prefer to not install a new toolset.

> 2. Use the "default"

It is what I used (by accident) for my projects.
but I try to build Codelite which uses another generator :-)
And changing of generator require some tweak (default adjustment seems to change from static lib to shared one, and manual requires some paths fixes).

> (although I personally prefer the "CodeLite Make Generator")

In which ways is it better?

> I just added new builder "CodeLite Makefile Generator - UNIX" that will generate UNIX compatible Makefile on Windows

Name might be misleading if it is for Windows (only?).
Maybe "posix makefile", but not sure it is correct (as it might just be disabled extensions for Makefile and issues are tools used IIUC),
so maybe "Unix tools".

Switching to that one might be easier, but not ideal anyway.

Unclear for me all those generators do. As I understand:

CMake: use CMakeLists.txt instead of Codelite configuration
NMake: for msvc (don't know if other makefile generators can handle that compiler)
Default: ??? The one we provide in configuration
GNU makefile one step build: ???
Codelite make generator: ??? Makefile using windows tools
CodeLite Makefile Generator - UNIX: ??? Makefile using gnu/unix tools

Re: Makefile generators

Posted: Sat Oct 03, 2020 8:11 pm
by eranif
When you install via MSYS, the compiler is using /usr/bin/bash as the default terminal (this is the main reason for the errors)
because SHELL is set to bash and not CMD

The more new 'CodeLite Makefile Generator' is better in a way that it places all the build artefacts under a single directory, usually it will be placed under the workspace folder with a name that matches the current build configuration:

WORKSPACE_PATH/build-Debug/...
WORKSPACE_PATH/build-Release/...

This allows a complete separation from various build configuration and it follows the concept of 'building outside of the source tree' (and it also does not pollute it with different intermediate files and folders)

For clarification:
Default -> is the original makefile generator that I wrote
CodeLite Makefile Generator -> is the newer one which uses the out-of-source tree build concept
CMake -> is coming from the CMake plugin (if you disable this plugin it will be removed)
CodeLite Makefile Generator - UNIX -> is similar to CodeLite Makefile Generator, but it assumes UNIX tools (e.g. mkdir -p) on Windows environment

Re: Makefile generators

Posted: Sun Oct 04, 2020 10:16 pm
by Jarod42
> The more new 'CodeLite Makefile Generator' is better in a way that it places all the build artefacts under a single directory

Is it configurable for Default, so seems better ;-) (And I configure Codelite projects via premake).

Thanks for clarification.