Description: Convert local source to external dependencies 
Author: Lance Lin <lq27267@gmail.com>
Forwarded: not-needed
Date: 21 Aug 2023

--- a/core/src/xmake/prefix.h
+++ b/core/src/xmake/prefix.h
@@ -25,7 +25,7 @@
  * includes
  */
 #include "prefix/prefix.h"
-#include "luaconf.h"
+#include <luaconf.h>
 #if defined(TB_CONFIG_OS_WINDOWS) && defined(__cplusplus)
 #   undef LUA_API
 #   undef LUALIB_API
@@ -33,13 +33,13 @@
 #   define LUALIB_API	LUA_API
 #endif
 #ifdef USE_LUAJIT
-#   include "luajit.h"
-#   include "lualib.h"
-#   include "lauxlib.h"
+#   include <luajit.h>
+#   include <lualib.h>
+#   include <lauxlib.h>
 #else
-#   include "lua.h"
-#   include "lualib.h"
-#   include "lauxlib.h"
+#   include <lua.h>
+#   include <lualib.h>
+#   include <lauxlib.h>
 #endif
 
 /* //////////////////////////////////////////////////////////////////////////////////////
--- a/core/xmake.sh
+++ b/core/xmake.sh
@@ -215,17 +215,14 @@
     option_end
 }
 
+# Define symbol for lua-cjson if linker flag found
+lua_ldflags=`pkg-config --libs lua 2>/dev/null | tr -d " "`
+lua_cjson_ldflags="${lua_ldflags}-cjson"
+case "${LDFLAGS}" in
+    *"${lua_cjson_ldflags}"*)
+        add_defines "XM_CONFIG_API_HAVE_LUA_CJSON" "{public}"
+esac
+
 # add projects
-if ! has_config "external"; then
-    if is_config "runtime" "luajit"; then
-        includes "src/luajit"
-    else
-        includes "src/lua"
-    fi
-    includes "src/lua-cjson"
-    includes "src/lz4"
-    includes "src/sv"
-    includes "src/tbox"
-fi
 includes "src/xmake"
 includes "src/cli"
--- a/core/xmake.lua
+++ b/core/xmake.lua
@@ -130,22 +130,13 @@
 end
 
 -- add projects
-includes("src/sv", "src/lz4", "src/xmake", "src/cli")
-if namespace then
-    namespace("tbox", function ()
-        includes("src/tbox")
-    end)
-else
-    includes("src/tbox")
-end
 if has_config("lua_cjson") then
-    includes("src/lua-cjson")
-end
-if is_config("runtime", "luajit") then
-    includes("src/luajit")
-else
     includes("src/lua")
+    add_deps("lua-cjson")
+    add_defines("NDEBUG", "USE_INTERNAL_FPCONV")
+    add_defines("XM_CONFIG_API_HAVE_LUA_CJSON", {public = true})
 end
+
 if is_plat("windows") then
     includes("src/pdcurses")
 end
--- a/core/src/xmake/hash/xxhash.c
+++ b/core/src/xmake/hash/xxhash.c
@@ -32,7 +32,7 @@
 #define XXH_NAMESPACE XM_
 #define XXH_STATIC_LINKING_ONLY
 #define XXH_IMPLEMENTATION
-#include "xxhash/xxhash.h"
+#include <xxhash.h>
 
 /* //////////////////////////////////////////////////////////////////////////////////////
  * implementation
