|
| 1 | +add_rules("mode.debug", "mode.release") |
| 2 | +add_requires("libcurl", "gmp", "icu4c", "mpfr", "readline", "libxml2") |
| 3 | +add_packages("libcurl", "gmp", "icu4c", "mpfr", "readline", "libxml2") |
| 4 | +add_includedirs(".", "libqalculate") |
| 5 | +set_languages("c++17") -- Use C++17 to avoid template syntax issues with nested angle brackets for Apple Clang |
| 6 | + |
| 7 | +includes("@builtin/check") |
| 8 | +check_cxxincludes("HAVE_UNORDERED_MAP", "unordered_map") |
| 9 | +check_cincludes("HAVE_PTHREADS", "pthread.h") |
| 10 | +check_cincludes("HAVE_STDIO_H", "stdio.h") |
| 11 | +check_cfuncs("HAVE_PIPE2", "pipe2", {includes = {"unistd.h", "fcntl.h"}}) |
| 12 | +-- External dependencies |
| 13 | +-- check_cincludes("HAVE_ICONV", "iconv.h") |
| 14 | +check_cincludes("HAVE_ICU", "unicode/ucasemap.h") |
| 15 | +check_cincludes("HAVE_LIBCURL", "curl/curl.h") |
| 16 | +check_cincludes("HAVE_LIBREADLINE", {"stdio.h", "readline/readline.h"}) |
| 17 | +-- Check if 'int_n_cs_precedes' is a member of 'struct lconv' |
| 18 | +-- check_csnippets("HAVE_STRUCT_LCONV_INT_N_CS_PRECEDES", [[ |
| 19 | +-- #include <locale.h> |
| 20 | +-- void* test(void) { |
| 21 | +-- return &((struct lconv *)0)->int_n_cs_precedes; |
| 22 | +-- } |
| 23 | +-- ]]) |
| 24 | +-- check_csnippets("HAVE_STRUCT_LCONV_INT_P_CS_PRECEDES", [[ |
| 25 | +-- #include <locale.h> |
| 26 | +-- void* test(void) { |
| 27 | +-- return &((struct lconv *)0)->int_p_cs_precedes; |
| 28 | +-- } |
| 29 | +-- ]]) |
| 30 | +-- -- Define "ICONV_CONST" as "const" if the declaration of iconv() needs const. |
| 31 | +-- option("iconv_not_need_const") |
| 32 | +-- add_csnippets("iconv_const", [[ |
| 33 | +-- #include <iconv.h> |
| 34 | +-- #include <string.h> |
| 35 | + |
| 36 | +-- #ifndef ICONV_CONST |
| 37 | +-- # define ICONV_CONST |
| 38 | +-- #endif |
| 39 | +-- int main(int argc, char **argv) { |
| 40 | +-- int result = 0; |
| 41 | +-- /* Test against AIX 5.1 bug: Failures are not distinguishable from successful |
| 42 | +-- returns. */ |
| 43 | +-- iconv_t cd_utf8_to_88591 = iconv_open("ISO8859-1", "UTF-8"); |
| 44 | +-- if (cd_utf8_to_88591 != (iconv_t)(-1)) { |
| 45 | +-- static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ |
| 46 | +-- char buf[10]; |
| 47 | +-- ICONV_CONST char *inptr = input; |
| 48 | +-- size_t inbytesleft = strlen(input); |
| 49 | +-- char *outptr = buf; |
| 50 | +-- size_t outbytesleft = sizeof(buf); |
| 51 | +-- size_t res = iconv(cd_utf8_to_88591, |
| 52 | +-- &inptr, &inbytesleft, |
| 53 | +-- &outptr, &outbytesleft); |
| 54 | +-- if (res == 0) |
| 55 | +-- result |= 1; |
| 56 | +-- iconv_close(cd_utf8_to_88591); |
| 57 | +-- } |
| 58 | +-- return result; |
| 59 | +-- } |
| 60 | +-- ]]) |
| 61 | +-- option_end() |
| 62 | +-- if get_config("iconv_not_need_const") then |
| 63 | +-- add_defines("ICONV_CONST=") |
| 64 | +-- else |
| 65 | +-- add_defines("ICONV_CONST=const") |
| 66 | +-- end |
| 67 | + |
| 68 | +option("version", {default = "0.0.1"}) |
| 69 | +local version = get_config("version") |
| 70 | +if version then |
| 71 | + add_defines("VERSION=\"" .. version .. "\"") |
| 72 | +end |
| 73 | + |
| 74 | +target("libqalculate") -- Expect `libqalculate.pc` to be generated |
| 75 | + set_basename("qalculate") |
| 76 | + set_kind("$(kind)") |
| 77 | + add_headerfiles("(libqalculate/BuiltinFunctions.h)", |
| 78 | + "(libqalculate/Calculator.h)", |
| 79 | + "(libqalculate/DataSet.h)", |
| 80 | + "(libqalculate/ExpressionItem.h)", |
| 81 | + "(libqalculate/Function.h)", |
| 82 | + "(libqalculate/MathStructure.h)", |
| 83 | + "(libqalculate/Number.h)", |
| 84 | + "(libqalculate/Prefix.h)", |
| 85 | + "(libqalculate/QalculateDateTime.h)", |
| 86 | + "(libqalculate/Unit.h)", |
| 87 | + "(libqalculate/Variable.h)", |
| 88 | + "(libqalculate/includes.h)", |
| 89 | + "(libqalculate/qalculate.h)", |
| 90 | + "(libqalculate/util.h)") |
| 91 | + add_files("libqalculate/*.cc") |
| 92 | + |
| 93 | +target("qalc") |
| 94 | + set_kind("binary") |
| 95 | + add_files("src/qalc.cc") |
| 96 | + add_deps("libqalculate") |
0 commit comments