diff --git a/repos/libports/lib/import/import-ffi.mk b/repos/libports/lib/import/import-ffi.mk new file mode 100644 index 0000000000..422f73ee03 --- /dev/null +++ b/repos/libports/lib/import/import-ffi.mk @@ -0,0 +1,7 @@ +ifeq ($(filter-out $(SPECS),x86_64),) +INC_DIR += $(call select_from_ports,ffi)/include/ffi/x86_64 +endif + +ifeq ($(filter-out $(SPECS),arm),) +INC_DIR += $(call select_from_ports,ffi)/include/ffi/arm +endif diff --git a/repos/libports/lib/mk/spec/arm/ffi.mk b/repos/libports/lib/mk/spec/arm/ffi.mk new file mode 100644 index 0000000000..7683855dbe --- /dev/null +++ b/repos/libports/lib/mk/spec/arm/ffi.mk @@ -0,0 +1,20 @@ +SHARED_LIB = yes + +LIBS = libc + +FFI_PORT = $(call select_from_ports,ffi)/src/lib/ffi + +INC_DIR = $(FFI_PORT)/include + +INC_DIR += $(call select_from_ports,ffi)/include/ffi/arm \ + $(REP_DIR)/src/lib/ffi + +CC_OPT = -DFFI_NO_RAW_API=0 + +SRC_C = prep_cif.c types.c ffi.c +SRC_S = sysv.S + +vpath prep_cif.c $(FFI_PORT)/src +vpath types.c $(FFI_PORT)/src +vpath ffi.c $(FFI_PORT)/src/arm +vpath sysv.S $(FFI_PORT)/src/arm diff --git a/repos/libports/lib/mk/spec/x86_64/ffi.mk b/repos/libports/lib/mk/spec/x86_64/ffi.mk new file mode 100644 index 0000000000..6d52c4d147 --- /dev/null +++ b/repos/libports/lib/mk/spec/x86_64/ffi.mk @@ -0,0 +1,22 @@ +SHARED_LIB = yes + +LIBS = libc + +FFI_PORT = $(call select_from_ports,ffi)/src/lib/ffi + +INC_DIR = $(FFI_PORT)/include + +INC_DIR += $(call select_from_ports,ffi)/include/ffi/x86_64 \ + $(REP_DIR)/src/lib/ffi + +CC_OPT = -DFFI_NATAIVE_RAW_API=1 -DFFI_NO_RAW_API=0 + +SRC_C = prep_cif.c types.c ffi64.c +SRC_S = unix64.S + +CC_OPT_unix64 = -DHAVE_AS_X86_PCREL=1 + +vpath prep_cif.c $(FFI_PORT)/src +vpath types.c $(FFI_PORT)/src +vpath ffi64.c $(FFI_PORT)/src/x86 +vpath unix64.S $(FFI_PORT)/src/x86 diff --git a/repos/libports/ports/ffi.hash b/repos/libports/ports/ffi.hash new file mode 100644 index 0000000000..b26120f267 --- /dev/null +++ b/repos/libports/ports/ffi.hash @@ -0,0 +1 @@ +77c655dd76559e5fee6adbdde54d6d902e708865 diff --git a/repos/libports/ports/ffi.port b/repos/libports/ports/ffi.port new file mode 100644 index 0000000000..81f78f6661 --- /dev/null +++ b/repos/libports/ports/ffi.port @@ -0,0 +1,46 @@ +LICENSE := MIT +DOWNLOADS := ffi.archive +VERSION := 3.2.1 + +URL(ffi) := https://github.com/libffi/libffi/archive/v$(VERSION).tar.gz +SHA(ffi) := 4d8dabf78a9892f207f2968453d4eceb6c48ec26 +DIR(ffi) := src/lib/ffi + +$(call check_tool,sed) + +DIRS := include/ffi/x86_64 include/ffi/arm +DIR_CONTENT(include/ffi/x86_64) := src/lib/ffi/src/x86/ffitarget.h +DIR_CONTENT(include/ffi/arm) := src/lib/ffi/src/arm/ffitarget.h + +gen_inc := ffi.h + +gen_files := $(addprefix include/ffi/x86_64/,$(gen_inc)) \ + $(addprefix include/ffi/arm/,$(gen_inc)) + +default: $(gen_files) + +$(gen_files): _dirs + +subst_x86_64 := \ + "@TARGET@/X86_64" \ + "@HAVE_LONG_DOUBLE@/1" \ + "@HAVE_LONG_DOUBLE_VARIANT@/0" \ + "@FFI_EXEC_TRAMPOLINE_TABLE@/0" + +subst_ARM := \ + "@TARGET@/ARM" \ + "@HAVE_LONG_DOUBLE@/0" \ + "@HAVE_LONG_DOUBLE_VARIANT@/0" \ + "@FFI_EXEC_TRAMPOLINE_TABLE@/0" + +apply_substitutions = $(VERBOSE)for i in $(2); do sed -i "s/$$i/g" $(1); done + +include/ffi/x86_64/ffi.h: + @$(MSG_GENERATE)$@ + $(VERBOSE)cp src/lib/ffi/include/ffi.h.in $@ + $(call apply_substitutions,$@,$(subst_x86_64)) + +include/ffi/arm/ffi.h: + @$(MSG_GENERATE)$@ + $(VERBOSE)cp src/lib/ffi/include/ffi.h.in $@ + $(call apply_substitutions,$@,$(subst_ARM)) diff --git a/repos/libports/src/lib/ffi/fficonfig.h b/repos/libports/src/lib/ffi/fficonfig.h new file mode 100644 index 0000000000..be386280ea --- /dev/null +++ b/repos/libports/src/lib/ffi/fficonfig.h @@ -0,0 +1,9 @@ +#ifndef _FFICONFIG_H_ +#define _FFICONFIG_H_ + +#define FFI_HIDDEN __attribute__ ((visibility ("hidden"))) +#define STDC_HEADERS 1 + +#define HAVE_MEMCPY 1 + +#endif /* _FFICONFIG_H_ */