'Using gmake on Mac with CLion (with an ArchLinux makefile)

I am trying to use a make file that my professor provided, but that make file is made to work in an Arch Linux VM, and not my Mac environment. To solve this, I've downloaded gmake and gcc via homebrew, and swapped them out as the make and compiler targets in my CLion toolchain. However, when I try to build, I am still getting the error "ld: unknown option: -rpath=$ORIGIN". This is the line that is failing (line 10) everytime:

$(CC) $(CFLAGS) $(LDFLAGS) -DDEBUG=$(DEBUG) -L. -Wl,-rpath='$$ORIGIN' -driverfile myfile.c -o $@

Here is my output when I hit build:

====================[ Build | all ]=============================================
/usr/local/Cellar/make/4.3/bin/gmake --jobs=9 all
/usr/local/Cellar/gcc/11.2.0_3/bin/gcc-11 -Wall -g  -DDEBUG=1 -L. -Wl, -rpath='$ORIGIN' -driverfile myfile.c -o myfile

ld: unknown option: -rpath=$ORIGIN
collect2: error: ld returned 1 exit status
gmake: *** [Makefile:10: myfile] Error 1

I am allowed to modify the makefile for testing purposes on my local machine, so long as all the stuff still works with the original makefile on the Arch Linux VM, and I'm happy to do this if it's the only solution, but I'd much rather figure out why its not working as is. (Even if the answer is 'Bc its a Mac and Apple says so.')



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source