From 39d41c8c0f38a95cadd67e0b085a889a79a799a7 Mon Sep 17 00:00:00 2001 From: Doekin <105162544+Doekin@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:29:32 +0800 Subject: [PATCH] ZBar: add package (#5530) * zbar: add package * Update dependencies and build configurations * Update gettext package to handle binary installation * Revert "Update gettext package to handle binary installation" This reverts commit 7854133b6ad340d14fc4f0fafdd58125c5f1b05f. * Update deps * Use system libiconv on MacOS * Update gettext package to handle binary installation * Add ldflag of pthread * Add autoconf-archive dep for MacOS * Update deps * Revert "Update gettext package to handle binary installation" This reverts commit d51bbeeab3661af42f19772906be84ab376125ff. * Use host gettext * Depend on private `gettext` * Disable pthread on Android * Add dep: pkg-config * Get aclocal path by running command * Use up-to-date libtool * Include `autoconf` m4 dir for `autoreconf` * Disable Android build on Windows, as for no autotools * Fix incorrect config * Build with xmake port instead of autotools * Add configure options `--without-x` and `--without-jpeg` * Export all symbols for Windows shared library * Fix file pattern for pdf417 decoder in xmake.lua * Fix install headers path * Add extsources * "Null" implementation for window module and video module * Add github git url * Fix multiple definition caused by duplicate implementation * libiconv: add iPhoneOS target platform * Disable processor * libiconv: use xmake port on `iphoneos` * zbar: Drop `iphoneos` support * Requires system libiconv on MacOS * Disable sys/time.h header inclusion * Remove zbar/window.c * Revert "Remove zbar/window.c" This reverts commit 94b839d07e571bea2f38a6520ebe9810fb2e1ca2. * Revert "Disable sys/time.h header inclusion" This reverts commit 331dcff4ec709e1e2783b1db129ce5ff5eeeb532. * Drop `windows` support * Fix invalid target platform limit * Process `config.h.in` instread of using preconfigured file * Fix missing def: LIB_VERSION * Remove `config.h` * Remove invalid `set_configvar` in `option("enable_codebar")` * Format * Simplify dep `libiconv` requirement * Refactor options to mimic original config `--enable-codes=SYMS` * Add package configs to better control symbologies support * Remove "export all symbols" for Windows * More concise configs * Fix invalid config * Format * Use built-in `${VERSION_*}` variables * Update config.h.in * Update xmake.lua * Update xmake.lua --------- Co-authored-by: ruki --- packages/z/zbar/port/config.h.in | 479 +++++++++++++++++++++++++++++++ packages/z/zbar/port/xmake.lua | 99 +++++++ packages/z/zbar/xmake.lua | 56 ++++ 3 files changed, 634 insertions(+) create mode 100644 packages/z/zbar/port/config.h.in create mode 100644 packages/z/zbar/port/xmake.lua create mode 100644 packages/z/zbar/xmake.lua diff --git a/packages/z/zbar/port/config.h.in b/packages/z/zbar/port/config.h.in new file mode 100644 index 00000000000..9692125b90f --- /dev/null +++ b/packages/z/zbar/port/config.h.in @@ -0,0 +1,479 @@ +/* include/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if using 'alloca.c'. */ +#undef C_ALLOCA + +/* whether to build support for Codabar symbology */ +#undef ENABLE_CODABAR + +/* whether to build support for Code 128 symbology */ +#undef ENABLE_CODE128 + +/* whether to build support for Code 39 symbology */ +#undef ENABLE_CODE39 + +/* whether to build support for Code 93 symbology */ +#undef ENABLE_CODE93 + +/* whether to build support for DataBar symbology */ +#undef ENABLE_DATABAR + +/* whether to build support for EAN symbologies */ +#undef ENABLE_EAN + +/* whether to build support for Interleaved 2 of 5 symbology */ +#undef ENABLE_I25 + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#undef ENABLE_NLS + +/* whether to build support for PDF417 symbology (incomplete) */ +#undef ENABLE_PDF417 + +/* whether to build support for QR Code */ +#undef ENABLE_QRCODE + +/* whether to build support for SQ Code */ +#undef ENABLE_SQCODE + +/* Define to 1 if you have the 'alarm' function. */ +#undef HAVE_ALARM + +/* Define to 1 if you have 'alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if works. */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Define to 1 if you have the Mac OS X function + CFLocaleCopyPreferredLanguages in the CoreFoundation framework. */ +#undef HAVE_CFLOCALECOPYPREFERREDLANGUAGES + +/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +#undef HAVE_CFPREFERENCESCOPYAPPVALUE + +/* Define to 1 if you have the 'clock_gettime' function. */ +#undef HAVE_CLOCK_GETTIME + +/* Define to 1 to use dbus */ +#undef HAVE_DBUS + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +#undef HAVE_DCGETTEXT + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FEATURES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FLOAT_H + +/* Define to 1 if you have the 'floor' function. */ +#undef HAVE_FLOOR + +/* Define to 1 if fseeko (and ftello) are declared in stdio.h. */ +#undef HAVE_FSEEKO + +/* Define to 1 if you have the 'getcwd' function. */ +#undef HAVE_GETCWD + +/* Define to 1 if you have the 'getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define if the GNU gettext() function is already present or preinstalled. */ +#undef HAVE_GETTEXT + +/* Define to 1 if you have the 'gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 to use GraphicsMagick */ +#undef HAVE_GRAPHICSMAGICK + +/* Define if you have the iconv() function and it works. */ +#undef HAVE_ICONV + +/* Define to 1 to use ImageMagick */ +#undef HAVE_IMAGEMAGICK + +/* Define to 1 to use ImageMagick 7 */ +#undef HAVE_IMAGEMAGICK7 + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_JERROR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_JNI_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_JPEGLIB_H + +/* Define to 1 if you have the 'jpeg' library (-ljpeg). */ +#undef HAVE_LIBJPEG + +/* Define to 1 if you have the 'pthread' library (-lpthread). */ +#undef HAVE_LIBPTHREAD + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBV4L2_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_VIDEODEV2_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_VIDEODEV_H + +/* Define to 1 if you have the 'localeconv' function. */ +#undef HAVE_LOCALECONV + +/* Define to 1 if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MAGICKWAND_MAGICKWAND_H + +/* Define to 1 if you have the 'malloc' function. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#undef HAVE_MALLOC_H + +/* Define to 1 if you have the 'memchr' function. */ +#undef HAVE_MEMCHR + +/* Define to 1 if you have the 'memmove' function. */ +#undef HAVE_MEMMOVE + +/* Define to 1 if you have the 'memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have a working 'mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_MNTENT_H + +/* Define to 1 if you have the 'modf' function. */ +#undef HAVE_MODF + +/* Define to 1 if you have the 'munmap' function. */ +#undef HAVE_MUNMAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_POLL_H + +/* Define to 1 if you have the 'pow' function. */ +#undef HAVE_POW + +/* Define to 1 if you have the header file. */ +#undef HAVE_PTHREAD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PYTHON_H + +/* Define to 1 if you have the 'realloc' function. */ +#undef HAVE_REALLOC + +/* Define to 1 if you have the 'select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the 'setenv' function. */ +#undef HAVE_SETENV + +/* Define to 1 if you have the header file. */ +#undef HAVE_SHADOW_H + +/* Define to 1 if you have the 'sqrt' function. */ +#undef HAVE_SQRT + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDDEF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the 'strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the 'strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the 'strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the 'strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the 'strrchr' function. */ +#undef HAVE_STRRCHR + +/* Define to 1 if you have the 'strstr' function. */ +#undef HAVE_STRSTR + +/* Define to 1 if you have the 'strtol' function. */ +#undef HAVE_STRTOL + +/* Define to 1 if you have the 'strtoul' function. */ +#undef HAVE_STRTOUL + +/* Define to 1 if 'st_rdev' is a member of 'struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_RDEV + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_FILE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IPC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MOUNT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SHM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STATFS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STATVFS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIMES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_VFS_H + +/* Define to 1 if the system has the type 'uintptr_t'. */ +#undef HAVE_UINTPTR_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_VALUES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_VFW_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_WAND_MAGICKWAND_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_XSHM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_XVLIB_H + +/* Define to 1 if the system has the type '_Bool'. */ +#undef HAVE__BOOL + +/* Define as const if the declaration of iconv() needs const. */ +#undef ICONV_CONST + +/* Library major version */ +#undef LIB_VERSION_MAJOR + +/* Library minor version */ +#undef LIB_VERSION_MINOR + +/* Library revision */ +#undef LIB_VERSION_REVISION + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#undef LT_OBJDIR + +/* Define to 1 if 'major', 'minor', and 'makedev' are declared in . + */ +#undef MAJOR_IN_MKDEV + +/* Define to 1 if 'major', 'minor', and 'makedev' are declared in + . */ +#undef MAJOR_IN_SYSMACROS + +/* Define to 1 if assertions should be disabled. */ +#undef NDEBUG + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "zbar ${VERSION}" + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "${VERSION}" + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if all of the C89 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING + +/* Program major version (before the '.') as a number */ +#define ZBAR_VERSION_MAJOR ${VERSION_MAJOR} + +/* Program minor version (after '.') as a number */ +#define ZBAR_VERSION_MINOR ${VERSION_MINOR} + +/* Program patch version (after the second '.') as a number */ +#define ZBAR_VERSION_PATCH ${VERSION_ALTER} + +/* Define to 1 if necessary to make fseeko visible. */ +#undef _LARGEFILE_SOURCE + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT64_T + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT8_T + +/* Minimum Windows API version */ +#undef _WIN32_WINNT + +/* used only for pthread debug attributes */ +#undef __USE_UNIX98 + +/* Define to empty if 'const' does not conform to ANSI C. */ +#undef const + +/* Define as 'int' if doesn't define. */ +#undef gid_t + +/* Define to '__inline__' or '__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef int32_t + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +#undef int64_t + +/* Define to 'long int' if does not define. */ +#undef off_t + +/* Define as 'unsigned int' if doesn't define. */ +#undef size_t + +/* Define as 'int' if doesn't define. */ +#undef uid_t + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +#undef uint16_t + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef uint32_t + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +#undef uint64_t + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +#undef uint8_t + +/* Define to the type of an unsigned integer type wide enough to hold a + pointer, if such a type exists, and if the system does not define it. */ +#undef uintptr_t + +#ifndef X_DISPLAY_MISSING +# define HAVE_X +#endif + diff --git a/packages/z/zbar/port/xmake.lua b/packages/z/zbar/port/xmake.lua new file mode 100644 index 00000000000..cb28fda79d3 --- /dev/null +++ b/packages/z/zbar/port/xmake.lua @@ -0,0 +1,99 @@ +add_rules("mode.debug", "mode.release") + +add_requires("libiconv") + +-- add options +option("symbologies", {description = "Select symbologies to compile"}) +option("vers", {description = "Set the version"}) +option("LIB_VERSION", {description = "Set the library version"}) + +set_version("$(vers)") + +if has_config("LIB_VERSION") then + local lib_vers = get_config("LIB_VERSION") + + local cur = lib_vers:match("([^:]+)") + local age = lib_vers:match(".*:(.*)$") + local major = tonumber(cur) - tonumber(age) + local minor = tonumber(age) + local revision = lib_vers:match("^[^:]*:([^:]*):.*$") + + set_configvar("LIB_VERSION_MAJOR", major, {quote = false}) + set_configvar("LIB_VERSION_MINOR", minor, {quote = false}) + set_configvar("LIB_VERSION_REVISION", revision, {quote = false}) +end + +set_configvar("PACKAGE", "zbar") +set_configvar("PACKAGE_NAME", "zbar") +set_configvar("PACKAGE_TARNAME", "zbar") +set_configvar("PACKAGE_BUGREPORT", "mchehab+huawei@kernel.org") +set_configvar("PACKAGE_URL", "") + +includes("@builtin/check") + +-- config.h variables +configvar_check_cincludes("HAVE_SYS_TIME_H", "sys/time.h") +configvar_check_cincludes("HAVE_INTTYPES_H", "inttypes.h") + +target("zbar") + set_kind("$(kind)") + + if is_plat("linux", "bsd") then + add_syslinks("pthread") + end + + add_packages("libiconv") + + add_includedirs("include") + add_includedirs("zbar") + + add_headerfiles("include/zbar.h") + add_headerfiles("include/zbar/Scanner.h", "include/zbar/Decoder.h", + "include/zbar/Exception.h", "include/zbar/Symbol.h", "include/zbar/Image.h", + "include/zbar/ImageScanner.h", "include/zbar/Video.h", "include/zbar/Window.h", + "include/zbar/Processor.h", {prefixdir = "zbar"}) + + set_configdir("include") + add_configfiles("include/(config.h.in)", {filename = "config.h"}) + + add_files( + "zbar/config.c", + "zbar/error.c", + "zbar/symbol.c", + "zbar/image.c", + "zbar/convert.c", + "zbar/refcnt.c", + "zbar/window.c", + "zbar/video.c", + "zbar/img_scanner.c", + "zbar/scanner.c", + "zbar/decoder.c", + "zbar/misc.c", + "zbar/sqcode.c") + + local symbologies = {{name = "ean", files = {"zbar/decoder/ean.c"}}, + {name = "databar", files = {"zbar/decoder/databar.c"}}, + {name = "code128", files = {"zbar/decoder/code128.c"}}, + {name = "code93", files = {"zbar/decoder/code93.c"}}, + {name = "code39", files = {"zbar/decoder/code39.c"}}, + {name = "codabar", files = {"zbar/decoder/codabar.c"}}, + {name = "i25", files = {"zbar/decoder/i25.c"}}, + {name = "qrcode", files = {"zbar/decoder/qr_finder.c", "zbar/qrcode/*.c"}}, + {name = "sqcode", files = {"zbar/decoder/sq_finder.c"}}, + {name = "pdf417", files = {"zbar/decoder/pdf417.c"}}} + local enabled_symbologies = get_config("symbologies") + if enabled_symbologies then + for _, symbology in ipairs(symbologies) do + if enabled_symbologies:find(symbology.name) or enabled_symbologies:find("all") then + add_files(symbology.files) + set_configvar("ENABLE_" .. symbology.name:upper(), 1) + end + end + end + + -- "null" implementation for window module and video module + add_files("zbar/window/null.c", "zbar/video/null.c", "zbar/processor/null.c") + + if is_plat("windows", "mingw") then + add_files("zbar/libzbar.rc") + end diff --git a/packages/z/zbar/xmake.lua b/packages/z/zbar/xmake.lua new file mode 100644 index 00000000000..1cd806910e4 --- /dev/null +++ b/packages/z/zbar/xmake.lua @@ -0,0 +1,56 @@ +package("zbar") + set_homepage("https://github.com/mchehab/zbar") + set_description("Library for reading bar codes from various sources") + set_license("LGPL-2.1") + + add_urls("https://github.com/mchehab/zbar/archive/refs/tags/$(version).tar.gz", + "https://github.com/mchehab/zbar.git") + add_versions("0.23.93", "212dfab527894b8bcbcc7cd1d43d63f5604a07473d31a5f02889e372614ebe28") + + if is_plat("mingw") and is_subhost("msys") then + add_extsources("pacman::zbar") + elseif is_plat("linux") then + add_extsources("pacman::zbar", "apt::libzbar-dev") + elseif is_plat("macosx") then + add_extsources("brew::zbar") + end + + add_configs("symbologies", {description = "Select symbologies to compile", default = {"ean", "databar", "code128", "code93", "code39", "codabar", "i25", "qrcode", "sqcode"}, type = "table"}) + + if is_plat("linux", "bsd") then + add_syslinks("pthread") + end + + add_deps("libiconv") + + on_install("!iphoneos and !windows", function (package) + os.cp(path.join(package:scriptdir(), "port", "config.h.in"), "include/config.h.in") + io.gsub("include/config.h.in", "# ?undef (.-)\n", "${define %1}\n") + os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") + + local configs = { vers = package:version_str(), + symbologies = table.concat(package:config("symbologies"), ",") } + + -- get LIB_VERSION from configure.ac + -- format: AC_SUBST([LIB_VERSION], [3:0:3]) + local configure_ac = io.readfile("configure.ac") + for _, key in ipairs({"LIB_VERSION"}) do + local value = configure_ac:match("AC_SUBST%(%[" .. key .. "%]%s*,%s*%[(.-)%]%)") + if value then + configs[key] = value + end + end + + import("package.tools.xmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_csnippets({test = [[ + void test() { + zbar_image_scanner_t *scanner ; + scanner = zbar_image_scanner_create(); + zbar_image_scanner_set_config(scanner, 0, ZBAR_CFG_ENABLE, 1); + zbar_image_scanner_destroy(scanner); + } + ]]}, {includes = "zbar.h"})) + end)