build: add xlc and AIX support (#1559)

This commit is contained in:
Jiayi Zhao 2019-10-30 16:02:31 -04:00 committed by Nguyen Anh Quynh
parent 4294ca7570
commit d3b96a627a
3 changed files with 24 additions and 3 deletions

View File

@ -34,6 +34,10 @@ RANLIB = $(CROSS)ranlib
STRIP = $(CROSS)strip
endif
ifeq ($(OS),OS/390)
RANLIB = touch
endif
ifneq (,$(findstring yes,$(CAPSTONE_DIET)))
CFLAGS ?= -Os
CFLAGS += -DCAPSTONE_DIET
@ -45,7 +49,14 @@ ifneq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE)))
CFLAGS += -DCAPSTONE_X86_ATT_DISABLE
endif
ifeq ($(CC),xlc)
CFLAGS += -qcpluscmt -qkeyword=inline -qlanglvl=extc1x -Iinclude
ifneq ($(OS),OS/390)
CFLAGS += -fPIC
endif
else
CFLAGS += -fPIC -Wall -Wwrite-strings -Wmissing-prototypes -Iinclude
endif
ifeq ($(CAPSTONE_USE_SYS_DYN_MEM),yes)
CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
@ -335,7 +346,11 @@ endif
else
CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
ifeq ($(OS), AIX)
$(LIBNAME)_LDFLAGS += -qmkshrobj
else
$(LIBNAME)_LDFLAGS += -shared
endif
# Cygwin?
IS_CYGWIN := $(shell $(CC) -dumpmachine 2>/dev/null | grep -i cygwin | wc -l)
ifeq ($(IS_CYGWIN),1)
@ -556,9 +571,12 @@ define install-library
endef
endif
ifeq ($(AR_FLAGS),)
AR_FLAGS := q
endif
define create-archive
$(AR) q $(ARCHIVE) $(LIBOBJ)
$(AR) $(AR_FLAGS) $(ARCHIVE) $(LIBOBJ)
$(RANLIB) $(ARCHIVE)
endef

View File

@ -30,14 +30,14 @@ extern "C" {
#endif
#else
#define CAPSTONE_API
#if defined(__GNUC__) && !defined(CAPSTONE_STATIC)
#if (defined(__GNUC__) || defined(__IBMC__)) && !defined(CAPSTONE_STATIC)
#define CAPSTONE_EXPORT __attribute__((visibility("default")))
#else // defined(CAPSTONE_STATIC)
#define CAPSTONE_EXPORT
#endif
#endif
#ifdef __GNUC__
#if (defined(__GNUC__) || defined(__IBMC__))
#define CAPSTONE_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define CAPSTONE_DEPRECATED __declspec(deprecated)

View File

@ -145,6 +145,9 @@ case "$TARGET" in
${MAKE} "$@";;
"mac-universal" ) MACOS_UNIVERSAL=yes ${MAKE} "$@";;
"mac-universal-no" ) MACOS_UNIVERSAL=no ${MAKE} "$@";;
"xlc31" ) CC=xlc CFLAGS=-q31 LDFLAGS=-q31 ${MAKE} "$@";;
"xlc32" ) CC=xlc CFLAGS=-q32 LDFLAGS=-q32 ${MAKE} "$@";;
"xlc64" ) CC=xlc CFLAGS=-q64 LDFLAGS=-q64 ${MAKE} "$@";;
* )
echo "Usage: $0 ["$(grep '^ "' $0 | cut -d '"' -f 2 | tr "\\n" "|")"]"
exit 1;;