makefile: dynamically determine if shm_open is available on the local system, Fix X11R7 library reference when available

This commit is contained in:
Mark Pizzolato 2015-04-28 16:29:23 -07:00
parent 041c866d67
commit cd799c9d3f
2 changed files with 12 additions and 1 deletions

View file

@ -176,6 +176,7 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
GCC_OPTIMIZERS_CMD = $(GCC) -v --help 2>&1
GCC_WARNINGS_CMD = $(GCC) -v --help 2>&1
LD_ELF = $(shell echo | $(GCC) -E -dM - | grep __ELF__)
INCPATH:=$(shell $(GCC) -x c -v -E /dev/null 2>&1 | grep -A 10 '> search starts here' | grep '^ ' | tr -d '\n')
ifeq (Darwin,$(OSTYPE))
OSNAME = OSX
LIBEXT = dylib
@ -276,7 +277,7 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
ifeq (X11R7,$(shell if $(TEST) -d /usr/X11R7/lib; then echo X11R7; fi))
LIBPATH += /usr/X11R7/lib
INCPATH += /usr/X11R7/include
OS_LDFLAGS += -L/X11R7/pkg/lib -R/usr/X11R7/lib
OS_LDFLAGS += -L/usr/X11R7/lib -R/usr/X11R7/lib
OS_CCDEFS += -I/usr/X11R7/include
endif
ifeq (/usr/local/lib,$(findstring /usr/local/lib,$(LIBPATH)))
@ -399,6 +400,12 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
OS_CCDEFS += -DHAVE_FNMATCH
endif
endif
ifneq (,$(call find_include,sys/mman))
ifneq (,$(shell grep shm_open $(call find_include,sys/mman)))
OS_CCDEFS += -DHAVE_SHM_OPEN
$(info using mman: $(call find_include,sys/mman))
endif
endif
ifneq (,$(VIDEO_USEFUL))
ifneq (,$(call find_include,SDL2/SDL))
ifneq (,$(call find_lib,SDL2))

View file

@ -459,6 +459,7 @@ struct SHMEM {
t_stat sim_shmem_open (const char *name, size_t size, SHMEM **shmem, void **addr)
{
#ifdef HAVE_SHM_OPEN
*shmem = (SHMEM *)calloc (1, sizeof(**shmem));
*addr = NULL;
@ -499,6 +500,9 @@ if ((*shmem)->shm_base == MAP_FAILED) {
}
*addr = (*shmem)->shm_base;
return SCPE_OK;
#else
return SCPE_NOFNC;
#endif
}
void sim_shmem_close (SHMEM *shmem)