Skip to content

Commit

Permalink
Handle compiler issues in makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
iVishalr committed Oct 8, 2024
1 parent 966d3af commit c5f3699
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,45 @@ BUILD_DIR = build
LIBRARY_NAME = gpt
PLATFORM = $(shell uname -s)

ifeq "$(CC)" "gcc"
# check if gcc is clang as in the case of macos
GCC_IS_CLANG=$(shell $(CC) --version | grep -i clang >/dev/null && echo yes || echo no)
CLANG_IS_GCC=$(shell $(CC) --version | grep -i GCC >/dev/null && echo yes || echo no)
ifeq ($(CC), gcc)
ifeq ($(GCC_IS_CLANG), yes)
$(info Using clang instead of gcc. gcc is aliased to clang on your system.)
CC = clang
endif
endif

ifeq ($(CC), clang)
ifeq ($(CLANG_IS_GCC), yes)
$(info Using gcc instead of clang. clang is aliased to gcc on your system.)
CC = clang
endif
endif

ifeq ($(CC),gcc)
CFLAGS_RELEASE += -fopenmp -DOMP
CFLAGS_DEBUG += -fopenmp -DOMP
LDFLAGS += -lgomp
endif

ifeq "$(CC)" "clang"
ifeq ($(CC),clang)
LDFLAGS += -lomp
endif

ifeq "$(PLATFORM)" "Darwin"
ifeq ($(PLATFORM),Darwin)
SHARED_SUFFIX=dylib
BREW_PATH=$(shell brew --prefix)
INCLUDES += -I $(BREW_PATH)/opt/libomp/include -I $(BREW_PATH)/opt/argp-standalone/include
LDFLAGS += -L $(BREW_PATH)/opt/libomp/lib -L $(BREW_PATH)/opt/argp-standalone/lib
endif

ifeq "$(PLATFORM)" "Linux"
ifeq ($(PLATFORM),Linux)
SHARED_SUFFIX=so
ifeq "$(CC)" "clang"
CFLAGS_RELEASE += -fopenmp -DOMP
CFLAGS_DEBUG += -fopenmp -DOMP
ifeq ($(CC),clang)
CFLAGS_RELEASE += -Xclang -fopenmp -DOMP
CFLAGS_DEBUG += -Xclang -fopenmp -DOMP
endif
endif

Expand Down

0 comments on commit c5f3699

Please sign in to comment.