From 4eff2b5f6a25fbff923f33c7de84ae4f44f03f83 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Fri, 22 May 2020 05:27:30 +0200 Subject: [PATCH] macos: more adjustments for OSX systems * instead of /usr/include use the current SDK path as system include directory (/usr/include is empty with current tools) (this also removes the need to add these paths in individual Makefiles) * define _DARWIN_C_SOURCE in tcc.h to get the full set of decls from system headers (e.g. vsnprintf), similar to _GNU_SOURCE (and don't define _ANSI_SOURCE in the main Makefile anymore) * tests/tests2/Makefile: remove the -w flag, it's added when necessary in the rules generating the .expect files --- Makefile | 3 --- configure | 4 ++++ lib/Makefile | 4 ---- tcc.h | 7 ++++++- tests/tests2/Makefile | 3 --- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index a97ab041..6f6fdd36 100644 --- a/Makefile +++ b/Makefile @@ -58,9 +58,6 @@ TCCFLAGS-unx = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP) TCCFLAGS = $(TCCFLAGS$(CFGWIN)) TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS) -ifdef CONFIG_OSX - TCCFLAGS += -D_ANSI_SOURCE -endif # cross compiler targets to build TCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince c67 diff --git a/configure b/configure index 594aa2a9..1f50a53c 100755 --- a/configure +++ b/configure @@ -35,6 +35,7 @@ mingw32="no" LIBSUF=".a" EXESUF="" DLLSUF=".so" +tcc_usrinclude="" tcc_sysincludepaths="" tcc_libpaths="" tcc_crtprefix="" @@ -53,6 +54,7 @@ targetos=`uname` case $targetos in Darwin) confvars="$confvars OSX" + tcc_usrinclude="`xcrun --show-sdk-path`/usr/include" DLLSUF=".dylib" ;; Windows_NT|MINGW*|MSYS*|CYGWIN*) @@ -401,6 +403,7 @@ fcho "Manual directory " "$mandir" fcho "Info directory " "$infodir" fcho "Doc directory " "$docdir" fcho "Target root prefix " "$sysroot" +fcho "/usr/include dir " "$tcc_usrinclude" echo "Source path $source_path" echo "C compiler $cc ($gcc_major.$gcc_minor)" echo "Target OS $targetos" @@ -455,6 +458,7 @@ echo "/* Automatically generated by configure - do not modify */" > $TMPH print_inc CONFIG_SYSROOT "$sysroot" print_inc CONFIG_TCCDIR "$tccdir" +print_mak CONFIG_USR_INCLUDE "$tcc_usrinclude" print_mak CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths" print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths" print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix" diff --git a/lib/Makefile b/lib/Makefile index 6e2a85d8..bc57be7f 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -17,10 +17,6 @@ XFLAGS = $(XFLAGS$(XCFG)) -I$(TOP) XCFG = $(or $(findstring -win,$T),-unx) S = $(if $(findstring yes,$(SILENT)),@$(info * $@)) -ifdef CONFIG_OSX - XFLAGS += -I`xcrun --show-sdk-path`/usr/include -endif - # in order to use gcc, type: make -libtcc1-usegcc=yes arm-libtcc1-usegcc ?= no diff --git a/tcc.h b/tcc.h index d74d918a..89c33e98 100644 --- a/tcc.h +++ b/tcc.h @@ -22,6 +22,7 @@ #define _TCC_H #define _GNU_SOURCE +#define _DARWIN_C_SOURCE #include "config.h" #include @@ -217,6 +218,10 @@ extern long double strtold (const char *__nptr, char **__endptr); # define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) #endif +#ifndef CONFIG_USR_INCLUDE +# define CONFIG_USR_INCLUDE "/usr/include" +#endif + /* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */ /* system include paths */ @@ -227,7 +232,7 @@ extern long double strtold (const char *__nptr, char **__endptr); # define CONFIG_TCC_SYSINCLUDEPATHS \ "{B}/include" \ ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \ - ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include") + ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE) # endif #endif diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 1a3d1597..b53622e6 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -15,9 +15,6 @@ endif ifdef CONFIG_OSX SKIP += 40_stdio.test 42_function_pointer.test SKIP += 113_btdll.test # no shared lib support yet - FLAGS += -w - SDK := `xcrun --show-sdk-path` - TCCFLAGS += -I$(SDK)/usr/include endif ifeq ($(ARCH),x86_64) SKIP += 73_arm64.test