From acb4296d3cdd3b5017c3c39e04ecc12c55e49ed5 Mon Sep 17 00:00:00 2001 From: Fabio Mascarenhas Date: Fri, 22 Jan 2010 14:57:23 -0200 Subject: mingw as build system --- install.bat | 24 +++++++++++++++++++----- src/luarocks/build/builtin.lua | 9 ++++----- src/luarocks/cfg.lua | 14 +++++++------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/install.bat b/install.bat index 5644fa2a..09d96b8c 100644 --- a/install.bat +++ b/install.bat @@ -31,9 +31,9 @@ IF [%1]==[/?] ( ECHO /P [dir] Where to install. ECHO Default is %PREFIX% ECHO /CONFIG [dir] Location where the config file should be installed. - ECHO Default is %SYSCONFDIR% + ECHO Default is same place of installation ECHO /TREE [dir] Root of the local tree of installed rocks. - ECHO Default is %ROCKS_TREE% + ECHO Default is same place of installation ECHO /SCRIPTS [dir] Where to install scripts installed by rocks. ECHO Default is TREE/bin. ECHO. @@ -56,6 +56,8 @@ IF [%1]==[/?] ( ) IF /I [%1]==[/P] ( SET PREFIX=%2 + SET SYSCONFDIR=%2 + SET ROCKS_TREE=%2 SHIFT /1 SHIFT /1 GOTO PARSE_LOOP @@ -240,7 +242,11 @@ IF ERRORLEVEL 1 GOTO ERROR IF [%INSTALL_LUA%]==[ON] ( IF NOT EXIST "%LUA_BINDIR%" %MKDIR% "%LUA_BINDIR%" IF NOT EXIST "%LUA_INCDIR%" %MKDIR% "%LUA_INCDIR%" - COPY lua5.1\bin\*.* "%LUA_BINDIR%" >NUL +REM IF [%USE_MINGW%]==[ON] ( +REM COPY lua5.1\mingw32-bin\*.* "%LUA_BINDIR%" >NUL +REM ) ELSE ( + COPY lua5.1\bin\*.* "%LUA_BINDIR%" >NUL +REM ) COPY lua5.1\include\*.* "%LUA_INCDIR%" >NUL ) COPY bin\*.* "%BINDIR%" >NUL @@ -301,11 +307,19 @@ IF NOT EXIST "%CONFIG_FILE%" ( IF [%SCRIPTS_DIR%]==[] ( %MKDIR% "%ROCKS_TREE%"\bin >NUL - COPY lua5.1\bin\*.dll "%ROCKS_TREE%"\bin >NUL +REM IF [%USE_MINGW%]==[ON] ( +REM COPY lua5.1\mingw32-bin\*.dll "%ROCKS_TREE%"\bin >NUL +REM ) ELSE ( + COPY lua5.1\bin\*.dll "%ROCKS_TREE%"\bin >NUL +REM ) ) IF NOT [%SCRIPTS_DIR%]==[] ( %MKDIR% "%SCRIPTS_DIR%" >NUL - COPY lua5.1\bin\*.dll "%SCRIPTS_DIR%" >NUL +REM IF [%USE_MINGW%]==[ON] ( +REM COPY lua5.1\mingw32-bin\*.dll "%SCRIPTS_DIR%" >NUL +REM ) ELSE ( + COPY lua5.1\bin\*.dll "%SCRIPTS_DIR%" >NUL +REM ) ) IF NOT EXIST "%ROCKS_TREE%" %MKDIR% "%ROCKS_TREE%" diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index dacaad0a..b6f42eab 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -86,10 +86,9 @@ function run(rockspec) compile_library = function(library, objects, libraries, libdirs, name) local extras = { unpack(objects) } add_flags(extras, "-L%s", libdirs) - add_flags(extras, "-l%s", libraries) - extras[#extras+1] = "-L" .. variables.LUA_LIBDIR - extras[#extras+1] = "-llua51" - extras[#extras+1] = "-lmsvcrt" + add_flags(extras, "%s.lib", libraries) + extras[#extras+1] = dir.path(variables.LUA_LIBDIR, "lua5.1.lib") + extras[#extras+1] = "-l" .. (variables.MSVCRT or "msvcr80") local ok = execute(variables.LD.." "..variables.LIBFLAG, "-o", library, unpack(extras)) return ok end @@ -103,7 +102,7 @@ function run(rockspec) local ok = execute(variables.RC, "-o", resname, rcname) if not ok then return ok end ok = execute(variables.LD, "-o", wrapname, resname, variables.WRAPPER, - "-L"..variables.LUA_LIBDIR, "-llua51", "-lmsvcrt", "-luser32") + dir.path(variables.LUA_LIBDIR, "lua5.1.lib"), "-l" .. (variables.MSVCRT or "msvcr80"), "-luser32") return ok, wrapname end elseif is_platform("win32") then diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 5ec87bf5..ae07f905 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -176,12 +176,12 @@ if detected.windows then defaults.variables.LIBFLAG = "/dll" defaults.external_deps_patterns = { bin = { "?.exe", "?.bat" }, - lib = { "?.lib", "?.dll" }, + lib = { "?.lib", "?.dll", "lib?.dll" }, include = { "?.h" } } defaults.runtime_external_deps_patterns = { bin = { "?.exe", "?.bat" }, - lib = { "?.dll" }, + lib = { "?.dll", "lib?.dll" }, include = { "?.h" } } defaults.local_cache = home.."/cache/luarocks" @@ -189,7 +189,7 @@ end if detected.mingw32 then home_config_file = home_config_file:gsub("\\","/") - defaults.arch = "mingw32-"..proc + defaults.arch = "win32-"..proc defaults.platforms = { "win32", "mingw32" } defaults.lib_extension = "dll" defaults.external_lib_extension = "dll" @@ -201,15 +201,15 @@ if detected.mingw32 then defaults.cmake_generator = "MinGW Makefiles" defaults.make = "mingw32-make" -- TODO: Split Windows flavors between mingw and msvc defaults.makefile = "Makefile.win" - defaults.variables.CC = "gcc" + defaults.variables.CC = "mingw32-gcc" defaults.variables.RC = "windres" defaults.variables.WRAPPER = config.LUAROCKS_PREFIX .. "\\2.0\\rclauncher.o" - defaults.variables.LD = "gcc" + defaults.variables.LD = "mingw32-gcc" defaults.variables.CFLAGS = "-O2" - defaults.variables.LIBFLAG = "-shared --dll --export-all-symbols" + defaults.variables.LIBFLAG = "-shared" defaults.external_deps_patterns = { bin = { "?.exe", "?.bat" }, - lib = { "lib?.a", "?.dll", "lib?.dll" }, + lib = { "?.lib", "?.dll", "lib?.dll" }, include = { "?.h" } } defaults.runtime_external_deps_patterns = { -- cgit v1.2.3-55-g6feb