Browse Source

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 <[email protected]>
Doekin 10 months ago
parent
commit
39d41c8c0f
3 changed files with 634 additions and 0 deletions
  1. 479 0
      packages/z/zbar/port/config.h.in
  2. 99 0
      packages/z/zbar/port/xmake.lua
  3. 56 0
      packages/z/zbar/xmake.lua

+ 479 - 0
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 <alloca.h> works. */
+#undef HAVE_ALLOCA_H
+
+/* Define to 1 if you have the <arpa/inet.h> 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 <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the <features.h> header file. */
+#undef HAVE_FEATURES_H
+
+/* Define to 1 if you have the <float.h> 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 <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <jerror.h> header file. */
+#undef HAVE_JERROR_H
+
+/* Define to 1 if you have the <jni.h> header file. */
+#undef HAVE_JNI_H
+
+/* Define to 1 if you have the <jpeglib.h> 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 <libv4l2.h> header file. */
+#undef HAVE_LIBV4L2_H
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define to 1 if you have the <linux/videodev2.h> header file. */
+#undef HAVE_LINUX_VIDEODEV2_H
+
+/* Define to 1 if you have the <linux/videodev.h> 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 <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
+/* Define to 1 if you have the <MagickWand/MagickWand.h> 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 <malloc.h> 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 <mntent.h> 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 <netdb.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the <poll.h> 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 <pthread.h> header file. */
+#undef HAVE_PTHREAD_H
+
+/* Define to 1 if you have the <Python.h> 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 <shadow.h> 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 <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> 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 <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> 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 <sys/file.h> header file. */
+#undef HAVE_SYS_FILE_H
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define to 1 if you have the <sys/ipc.h> header file. */
+#undef HAVE_SYS_IPC_H
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#undef HAVE_SYS_MMAN_H
+
+/* Define to 1 if you have the <sys/mount.h> header file. */
+#undef HAVE_SYS_MOUNT_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/shm.h> header file. */
+#undef HAVE_SYS_SHM_H
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/statfs.h> header file. */
+#undef HAVE_SYS_STATFS_H
+
+/* Define to 1 if you have the <sys/statvfs.h> header file. */
+#undef HAVE_SYS_STATVFS_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/times.h> header file. */
+#undef HAVE_SYS_TIMES_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/vfs.h> 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 <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <values.h> header file. */
+#undef HAVE_VALUES_H
+
+/* Define to 1 if you have the <vfw.h> header file. */
+#undef HAVE_VFW_H
+
+/* Define to 1 if you have the <wand/MagickWand.h> header file. */
+#undef HAVE_WAND_MAGICKWAND_H
+
+/* Define to 1 if you have the <X11/extensions/XShm.h> header file. */
+#undef HAVE_X11_EXTENSIONS_XSHM_H
+
+/* Define to 1 if you have the <X11/extensions/Xvlib.h> 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 <mkdev.h>.
+   */
+#undef MAJOR_IN_MKDEV
+
+/* Define to 1 if 'major', 'minor', and 'makedev' are declared in
+   <sysmacros.h>. */
+#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 <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> 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 <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> 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 <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> 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 <sys/types.h> 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 <sys/types.h> does not define. */
+#undef off_t
+
+/* Define as 'unsigned int' if <stddef.h> doesn't define. */
+#undef size_t
+
+/* Define as 'int' if <sys/types.h> 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
+

+ 99 - 0
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", "[email protected]")
+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

+ 56 - 0
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)