xmake.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. option("ver", {default = nil})
  2. add_rules("mode.debug", "mode.release")
  3. if has_config("ver") then
  4. set_version(get_config("ver"), {soname = true})
  5. end
  6. includes("@builtin/check")
  7. target("fcgi")
  8. set_kind("$(kind)")
  9. add_files("libfcgi/*.c|os_*.c")
  10. if is_plat("windows", "mingw") then
  11. add_files("libfcgi/os_win32.c")
  12. else
  13. add_files("libfcgi/os_unix.c")
  14. end
  15. if is_plat("windows") then
  16. if is_kind("static") then
  17. add_defines("DLLAPI=", {public = true})
  18. else
  19. add_defines("DLLAPI=__declspec(dllexport)")
  20. end
  21. end
  22. add_includedirs("include", {public = true})
  23. add_headerfiles("include/*.h|fcgi_config_x86.h")
  24. if is_plat("windows", "mingw") then
  25. add_syslinks("ws2_32")
  26. elseif is_plat("linux", "bsd") then
  27. add_syslinks("m")
  28. end
  29. set_configdir("include")
  30. add_configfiles("fcgi_config.h.in")
  31. local header_map = {
  32. HAVE_ARPA_INET_H = "arpa/inet.h",
  33. HAVE_DLFCN_H = "dlfcn.h",
  34. HAVE_INTTYPES_H = "inttypes.h",
  35. HAVE_LIMITS_H = "limits.h",
  36. HAVE_MEMORY_H = "memory.h",
  37. HAVE_NETDB_H = "netdb.h",
  38. HAVE_NETINET_IN_H = "netinet/in.h",
  39. HAVE_STDINT_H = "stdint.h",
  40. HAVE_STDLIB_H = "stdlib.h",
  41. HAVE_STRINGS_H = "strings.h",
  42. HAVE_STRING_H = "string.h",
  43. HAVE_SYS_PARAM_H = "sys/param.h",
  44. HAVE_SYS_SOCKET_H = "sys/socket.h",
  45. HAVE_SYS_STAT_H = "sys/stat.h",
  46. HAVE_SYS_TIME_H = "sys/time.h",
  47. HAVE_SYS_TYPES_H = "sys/types.h",
  48. HAVE_UNISTD_H = "unistd.h"
  49. }
  50. for macro, header in pairs(header_map) do
  51. configvar_check_cincludes(macro, header)
  52. end
  53. configvar_check_cfuncs("HAVE_STRERROR", "strerror", {includes = {"string.h"}})
  54. configvar_check_cfuncs("HAVE_FILENO_PROTO", "fileno", {includes = {"stdio.h"}})
  55. configvar_check_ctypes("HAVE_FPOS", "fpos_t", {includes = "stdio.h"})
  56. configvar_check_ctypes("HAVE_SOCKLEN", "socklen_t", {includes = "sys/socket.h"})
  57. configvar_check_csnippets("HAVE_SOCKADDR_UN_SUN_LEN", [[
  58. struct sockaddr_un addr;
  59. addr.sun_len = 0;
  60. ]], {includes = "sys/un.h"})
  61. configvar_check_csnippets("HAVE_VA_ARG_LONG_DOUBLE_BUG", [[
  62. long double lDblArg; va_list arg; lDblArg = va_arg(arg, long double);
  63. ]], {includes = "stdarg.h"})
  64. target("fcgi++")
  65. set_kind("$(kind)")
  66. add_files("libfcgi/*.cpp")
  67. if is_plat("windows") then
  68. if is_kind("static") then
  69. add_defines("DLLAPI=", {public = true})
  70. else
  71. add_defines("DLLAPI=__declspec(dllexport)")
  72. end
  73. end
  74. add_deps("fcgi")
  75. target("cgi-fcgi")
  76. set_kind("binary")
  77. add_files("cgi-fcgi/cgi-fcgi.c")
  78. add_deps("fcgi")