From e5d087c75c17fe8499a37f1e9fa09bf761b5adae Mon Sep 17 00:00:00 2001 From: Diego Argueta Date: Sat, 21 Sep 2024 06:29:20 -0700 Subject: [PATCH] Fix C++ flags on MacOS --- Makefile | 32 +++++++++++++++++--------------- unicorn-2.2.1-1.rockspec | 9 ++++++++- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 9b14d075..87451f13 100644 --- a/Makefile +++ b/Makefile @@ -11,21 +11,23 @@ LUAROCKS = luarocks get_luarocks_var = $(shell $(LUAROCKS) config variables.$1) -BUSTED := $(call get_luarocks_var,SCRIPTS_DIR)/busted -CC := $(call get_luarocks_var,CC) -CXXFLAGS := $(call get_luarocks_var,CFLAGS) -CURL := $(call get_luarocks_var,CURL) -LD := $(call get_luarocks_var,LD) -LIBFLAG := $(call get_luarocks_var,LIBFLAG) -LIB_EXTENSION := $(call get_luarocks_var,LIB_EXTENSION) -LUA := $(call get_luarocks_var,LUA) -LUA_DIR := $(call get_luarocks_var,LUA_DIR) -LUA_INCDIR := $(call get_luarocks_var,LUA_INCDIR) -LUA_LIBDIR := $(call get_luarocks_var,LUA_LIBDIR) -LUA_VERSION := $(call get_luarocks_var,LUA_VERSION) -MKDIR := $(call get_luarocks_var,MKDIR) -OBJ_EXTENSION := $(call get_luarocks_var,OBJ_EXTENSION) -UNICORN_INCDIR = /usr/include +ifndef CALLED_FROM_LUAROCKS + BUSTED := $(call get_luarocks_var,SCRIPTS_DIR)/busted + CC := $(call get_luarocks_var,CC) + CXXFLAGS := $(call get_luarocks_var,CFLAGS) + CURL := $(call get_luarocks_var,CURL) + LD := $(call get_luarocks_var,LD) + LIBFLAG := $(call get_luarocks_var,LIBFLAG) + LIB_EXTENSION := $(call get_luarocks_var,LIB_EXTENSION) + LUA := $(call get_luarocks_var,LUA) + LUA_DIR := $(call get_luarocks_var,LUA_DIR) + LUA_INCDIR := $(call get_luarocks_var,LUA_INCDIR) + LUA_LIBDIR := $(call get_luarocks_var,LUA_LIBDIR) + LUA_VERSION := $(call get_luarocks_var,LUA_VERSION) + MKDIR := $(call get_luarocks_var,MKDIR) + OBJ_EXTENSION := $(call get_luarocks_var,OBJ_EXTENSION) + UNICORN_INCDIR = /usr/include +endif ################################################################################ diff --git a/unicorn-2.2.1-1.rockspec b/unicorn-2.2.1-1.rockspec index 38be1c80..7589a11f 100644 --- a/unicorn-2.2.1-1.rockspec +++ b/unicorn-2.2.1-1.rockspec @@ -57,12 +57,14 @@ test = { "LUAROCKS=$(SCRIPTS_DIR)/luarocks", "OBJ_EXTENSION=$(OBJ_EXTENSION)", "MKDIR=$(MKDIR)", - -- The following are needed but not provided by LuaRocks + -- The following are needed for building the tests, but aren't provided by + -- LuaRocks when testing. "LUA_INCDIR=$(LUA_DIR)/include", "LUA_LIBDIR=$(LUA_DIR)/lib", -- "UNICORN_INCDIR=$(UNICORN_INCDIR)", -- "UNICORN_LIBDIR=$(UNICORN_LIBDIR)", -- "PTHREAD_LIBDIR=$(PTHREAD_LIBDIR)", + "CALLED_FROM_LUAROCKS=1", }, } @@ -78,6 +80,7 @@ build = { LUAROCKS = "$(SCRIPTS_DIR)/luarocks", OBJ_EXTENSION = "$(OBJ_EXTENSION)", LUA_VERSION = "$(LUA_VERSION)", + CALLED_FROM_LUAROCKS = "1", }, build_variables = { CC = "$(CC)", @@ -97,3 +100,7 @@ build = { INST_LIBDIR = "$(LIBDIR)", }, } + +-- Clang on MacOS needs to be explicitly told to use the C++11 standard, since it defaults +-- to C++03 or thereabouts. +build.platforms.macos.build_variables.CXXFLAGS = "$(CFLAGS) -std=c++11"