Skip to content

Commit

Permalink
Use R CMD CONFIG to detect compiler (#56)
Browse files Browse the repository at this point in the history
* Use R CMD CONFIG to detect compiler

* R path, R REMAP
  • Loading branch information
andrjohns authored Jun 7, 2024
1 parent 869970f commit fa49fc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions inst/include/cpp11/R.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
#endif
#endif

#ifndef R_NO_REMAP
#define R_NO_REMAP
#endif
#ifndef STRICT_R_HEADERS
#define STRICT_R_HEADERS
#endif
#include "Rinternals.h"

// clang-format off
Expand Down
11 changes: 7 additions & 4 deletions src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ else
DLL := .so
endif

CC_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion 2>&1)
R_CC := $(shell $(R_HOME)/bin$(R_ARCH_BIN)/R CMD config CC)
R_CXX := $(shell $(R_HOME)/bin$(R_ARCH_BIN)/R CMD config CXX)

CC_VERSION := $(shell $(R_CXX) -dumpfullversion -dumpversion 2>&1)
CC_MAJOR := $(word 1,$(subst ., ,$(CC_VERSION)))

CLANG_CHECK := $(shell echo | $(CXX) -dM -E - | grep -i __clang__)
CLANG_CHECK := $(shell echo | $(R_CC) -dM -E - | grep -i __clang__)

# Older versions of gcc and clang don't provide the stdatomic.h header
ifneq (,$(CLANG_CHECK))
Expand All @@ -21,7 +24,7 @@ ifneq (,$(CLANG_CHECK))
endif
# Clang on armel needs libatomic
ifeq ($(shell uname -m), armv7l)
CC_TARGET := $(shell $(CXX) -v 2>&1 | grep Target | cut -d ' ' -f 2)
CC_TARGET := $(shell $(R_CXX) -v 2>&1 | grep Target | cut -d ' ' -f 2)
ifeq ($(findstring gnueabihf,$(CC_TARGET)),)
PKG_LIBS += -latomic
endif
Expand Down Expand Up @@ -64,7 +67,7 @@ build-static: $(QUICKJS_OBJECTS)
$(AR) -rs ../inst/lib/$(R_ARCH)/libquickjs.a $(QUICKJS_OBJECTS)

$(QUICKJS_OBJECTS): quickjs/%.o : quickjs/%.c
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -DFALSE=0 -DTRUE=1 -DSTRICT_R_HEADERS -funsigned-char -fwrapv -std=gnu11 -c $< -o $@
$(R_CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -DFALSE=0 -DTRUE=1 -DSTRICT_R_HEADERS -funsigned-char -fwrapv -std=gnu11 -c $< -o $@

clean:
$(RM) $(QUICKJS_OBJECTS) $(OBJECTS) ../inst/VERSION QuickJSR$(DLL)
Expand Down

0 comments on commit fa49fc4

Please sign in to comment.