0
votes

I have a project which uses the windows API on windows, and pthreads on every other platform.

How do I have my makefile add -pthread to my CFLAGS if I'm NOT targetting for windows? For compiling, I use [gcc (mingw and native), clang, icc], and for targets I have [GNU/Linux, BSD, Darwin, Windows].

2

2 Answers

1
votes

Assuming that you have mingw installed and are using GNUmake:

OPERATING_SYSTEM:=        $(shell uname | sed 's/-.*//')
ifneq ($(OPERATING_SYSTEM),MINGW32_NT)
CFLAGS+=                  -pthread
LDFLAGS+=                 -pthread
endif
0
votes

I ended up doing...

uname_S = $(shell sh -c 'uname -s 2>/dev/null || echo not')
ifeq (,$(findstring MINGW,$(uname_S)))
    CFLAGS += -pthread
endif

which was totally ripped from the git source tree.