Testing for 32bit or 64bit Cygwin in Makefile?

Dimitry Andric dimitry@unified-streaming.com
Sat Nov 9 11:20:25 GMT 2024


On 9 Nov 2024, at 11:42, Sebastian Feld via Cygwin <cygwin@cygwin.com> wrote:
> 
> On Wed, Nov 6, 2024 at 4:30 PM Dimitry Andric
> <dimitry@unified-streaming.com> wrote:
>> 
>> On 6 Nov 2024, at 16:11, Sebastian Feld via Cygwin <cygwin@cygwin.com> wrote:
>>> 
>>> How can I test in a /usr/bin/make Makefile whether I am running on a
>>> 32bit or 64bit Cygwin (not Windows kernel)?
>> 
>> Usually in a shell you use "uname -m", or with bash specifically, the $HOSTTYPE variable.
>> 
>> However in GNU make you should be able to use the internal variable $(MAKE_HOST). On my Cygwin installation, this gives the value "x86_64-pc-cygwin". Since I do not have any 32-bit Cygwin installation, I cannot tell you what the exact value is, but my guess would be "i386-pc-cygwin", or something like that.
> 
> I need something which works with bsdmake (/usr/bin/bmake in Cygwin)
> and GNU /usr/bin/make. Moreover, how would a test statement for this
> look like in the Makefile? bmake doesn't have ifeq ()

BSD make has a different style for conditionals, using ".if", ".else", and so on. These use a more familiar logical operator syntax than GNU make.

It also has a built-in variable MACHINE corresponding to "uname -m" output. So with bmake you can do:

.if ${MACHINE} == "x86_64"
.info Go here
.else
.info Go there
.endif

However, supporting both GNU make and BSD make in one Makefile is not really possible unless you use the lowest common denominator syntax, which is just variable assignments and basic rules.

Otherwise, you would have to write two files, one called GNUmakefile for GNU make, and one called Makefile for BSD make.

-Dimitry



More information about the Cygwin mailing list