Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change environment path into the makefile with MinGW32-make.exe on Windows

I have a makefile that I want to compile a DLL with MinGW on Windows.

This project I want to compile into 32 & 64 bits.

I have MinGW32 installed into C:\MinGW32 with the x86 compiler and C:\MinGW64 with the x64 compiler.

The makefile, uses one or another path depending of the target, but the problem I have is that I need to specify C:\MinGWxx\bin on global environvment path, because it needs some of the DLLs of the bin directory.

I tried some solutions like Specifying path in makefile (GNU make on Windows), but it doesn't work.

It seems that exports is not reconogized in this version of operating system (or not supported for make).

I tried to put

SET Path=$(PATH_DVL_x86)\bin;$(PATH_DVL_x86)\msys\1.0\bin;${PATH}

This doesn't return error, but no changes on environment path.

like image 327
surfzone.org Avatar asked Dec 29 '25 10:12

surfzone.org


1 Answers

You will need to use the .ONESHELL special target to force the recipes to run all commands in one shell:

.ONESHELL:

.PHONY: all anotherRule

all:
    @ECHO OFF
    ECHO %PATH% # Will echo your PATH environment variable content
    SET PATH=%PATH%;toto
    ECHO %PATH% # Will echo your PATH + ";toto" appended to it

anotherRule:
    @ECHO OFF
    ECHO %PATH% # Will echo your PATH without ";toto", as expected

Now it is easy to write specific rules to use with different compilers:

all-x86: CC := mingw32-gcc
all-x86: ...
    ...

all-64: CC := mingw64-gcc
all-64: ...
    ...
like image 57
Chnossos Avatar answered Dec 30 '25 23:12

Chnossos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!