[28] | 1 | ---------------------------------------------------- |
---|
| 2 | -- The main porpouse of this file is to build linux gcc makefiles. |
---|
| 3 | -- Must have Premake version 3 installed. |
---|
| 4 | -- Original Premake was changed to remove some parameters and add others. |
---|
| 5 | -- Default parameters: |
---|
| 6 | -- premake3s --target gnu --os linux |
---|
| 7 | -- But it can build windows gcc makefiles, and visual studio projects. |
---|
| 8 | -- premake3s --target gnu --os windows |
---|
| 9 | -- premake3s --target gnu --os macosx |
---|
| 10 | -- premake3s --target vs6 |
---|
| 11 | -- premake3s --target vs2002 |
---|
| 12 | -- premake3s --target vs2003 |
---|
| 13 | -- premake3s --target vs2005 (MUST UPDATE DEPENDENCIES) |
---|
| 14 | -- In Linux the generated makefiles will not correctly build libraries in 64-bits. |
---|
| 15 | -- must add "-m64 -fPIC" flags |
---|
| 16 | ---------------------------------------------------- |
---|
| 17 | |
---|
| 18 | if (not options.target) then |
---|
| 19 | options.target = "gnu" |
---|
| 20 | end |
---|
| 21 | |
---|
| 22 | if (not options.os) then |
---|
| 23 | if (options.target ~= "gnu") then |
---|
| 24 | options.os = "windows" |
---|
| 25 | else |
---|
| 26 | options.os = "linux" |
---|
| 27 | end |
---|
| 28 | end |
---|
| 29 | |
---|
| 30 | function fixPackagePath(package_files) |
---|
| 31 | if (options.os ~= "linux") then |
---|
| 32 | for i, file in package_files do |
---|
| 33 | package_files[i] = "../src/"..file |
---|
| 34 | end |
---|
| 35 | end |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | ---------------------------------------------------- |
---|
| 39 | |
---|
| 40 | lua_suffix = "5.1" |
---|
| 41 | |
---|
| 42 | project.name = "lua"..lua_suffix |
---|
| 43 | project.bindir = "../bin" |
---|
| 44 | project.libdir = "../lib" |
---|
| 45 | |
---|
| 46 | if (options.os ~= "linux") then |
---|
| 47 | if (options.os == "macosx") then |
---|
| 48 | project.path = "../mak.macosx" |
---|
| 49 | else |
---|
| 50 | project.path = "../mak."..options.target |
---|
| 51 | end |
---|
| 52 | end |
---|
| 53 | |
---|
| 54 | lua_defines = { } |
---|
| 55 | |
---|
| 56 | if (options.os == "windows") then |
---|
| 57 | if (options.target == "gnu") then |
---|
| 58 | -- Cygwin Only (POSIX build) |
---|
| 59 | tinsert(lua_defines, {"LUA_USE_DLOPEN", "LUA_USE_READLINE"}) |
---|
| 60 | end |
---|
| 61 | else |
---|
| 62 | -- All non-Windows (posix) |
---|
| 63 | tinsert(lua_defines, {"LUA_USE_POSIX"}) |
---|
| 64 | |
---|
| 65 | if (options.os == "linux") then |
---|
| 66 | -- Linux Only |
---|
| 67 | tinsert(lua_defines, {"LUA_USE_DLOPEN", "LUA_USE_READLINE"}) |
---|
| 68 | end |
---|
| 69 | |
---|
| 70 | if (options.os == "macosx") then |
---|
| 71 | -- MacOS X Only |
---|
| 72 | tinsert(lua_defines, {"LUA_DL_DYLD"}) |
---|
| 73 | end |
---|
| 74 | |
---|
| 75 | if (options.os == "bsd") then |
---|
| 76 | -- BSD Only |
---|
| 77 | tinsert(lua_defines, {"LUA_USE_DLOPEN"}) |
---|
| 78 | end |
---|
| 79 | end |
---|
| 80 | |
---|
| 81 | if (options.target == "vs2005") then |
---|
| 82 | tinsert(lua_defines, {"_CRT_SECURE_NO_DEPRECATE"}) |
---|
| 83 | end |
---|
| 84 | |
---|
| 85 | ---------------------------------------------------- |
---|
| 86 | |
---|
| 87 | package = newpackage() |
---|
| 88 | package.name = "lua"..lua_suffix.."_dll" |
---|
| 89 | package.target = "lua"..lua_suffix |
---|
| 90 | package.objdir = "../obj/"..package.name |
---|
| 91 | package.language = "c" |
---|
| 92 | package.kind = "dll" |
---|
| 93 | package.defines = lua_defines |
---|
| 94 | package.includepaths = { "../include" } |
---|
| 95 | package.path = project.path |
---|
| 96 | |
---|
| 97 | lua_files = |
---|
| 98 | { |
---|
| 99 | "lapi.c", "lcode.c", "ldebug.c", "ldo.c", "ldump.c", "lfunc.c", "lgc.c", "llex.c", "lmem.c", |
---|
| 100 | "lobject.c", "lopcodes.c", "lparser.c", "lstate.c", "lstring.c", "ltable.c", "ltm.c", |
---|
| 101 | "lundump.c", "lvm.c", "lzio.c", |
---|
| 102 | "lauxlib.c", "lbaselib.c", "ldblib.c", "liolib.c", "lmathlib.c", "loslib.c", "ltablib.c", |
---|
| 103 | "lstrlib.c", "loadlib.c", "linit.c" |
---|
| 104 | } |
---|
| 105 | fixPackagePath(lua_files) |
---|
| 106 | |
---|
| 107 | package.files = lua_files |
---|
| 108 | |
---|
| 109 | if (options.os == "windows") then |
---|
| 110 | tinsert(package.files, {"../src/lua"..lua_suffix..".def"}) |
---|
| 111 | end |
---|
| 112 | |
---|
| 113 | --------------------------------------------------------------------- |
---|
| 114 | |
---|
| 115 | package = newpackage() |
---|
| 116 | package.name = "lua"..lua_suffix.."_lib" |
---|
| 117 | package.target = "lua"..lua_suffix |
---|
| 118 | package.objdir = "../obj/"..package.name |
---|
| 119 | if (options.os == "windows") then |
---|
| 120 | package.libdir = "../lib/static" |
---|
| 121 | end |
---|
| 122 | package.language = "c" |
---|
| 123 | package.kind = "lib" |
---|
| 124 | package.defines = lua_defines |
---|
| 125 | package.files = lua_files |
---|
| 126 | package.includepaths = { "../include" } |
---|
| 127 | package.path = project.path |
---|
| 128 | |
---|
| 129 | --------------------------------------------------------------------- |
---|
| 130 | |
---|
| 131 | package = newpackage() |
---|
| 132 | package.name = "lua"..lua_suffix.."_exe" |
---|
| 133 | package.target = "lua"..lua_suffix |
---|
| 134 | package.objdir = "../obj/"..package.name |
---|
| 135 | package.language = "c" |
---|
| 136 | package.kind = "exe" |
---|
| 137 | package.defines = lua_defines |
---|
| 138 | package.includepaths = { "../include" } |
---|
| 139 | package.path = project.path |
---|
| 140 | |
---|
| 141 | package.files = |
---|
| 142 | { |
---|
| 143 | "lua.c" |
---|
| 144 | } |
---|
| 145 | fixPackagePath(package.files) |
---|
| 146 | |
---|
| 147 | if (options.os == "windows") then |
---|
| 148 | tinsert(package.files, {"../src/lua.rc"}) |
---|
| 149 | package.links = { "lua"..lua_suffix } |
---|
| 150 | package.libpaths = { "../lib" } |
---|
| 151 | package.linkoptions = { "setargv.obj" } |
---|
| 152 | |
---|
| 153 | if (options.target == "gnu") then |
---|
| 154 | tinsert(package.links, {"readline", "history"}) |
---|
| 155 | end |
---|
| 156 | else |
---|
| 157 | package.links = { "lua"..lua_suffix, "m" } |
---|
| 158 | package.libpaths = { "../lib" } |
---|
| 159 | |
---|
| 160 | if (options.os == "linux") then |
---|
| 161 | tinsert(package.links, {"readline", "history", "curses", "ncurses"}) |
---|
| 162 | tinsert(package.links, {"dl"}) |
---|
| 163 | package.linkoptions = { "-Wl,-E" } |
---|
| 164 | end |
---|
| 165 | |
---|
| 166 | if (options.os == "bsd") then |
---|
| 167 | package.linkoptions = { "-Wl,-E" } |
---|
| 168 | end |
---|
| 169 | |
---|
| 170 | if (options.os == "sunos") then |
---|
| 171 | tinsert(package.links, {"dl"}) |
---|
| 172 | end |
---|
| 173 | end |
---|
| 174 | |
---|
| 175 | --------------------------------------------------------------------- |
---|
| 176 | |
---|
| 177 | package = newpackage() |
---|
| 178 | package.name = "luac"..lua_suffix.."_exe" |
---|
| 179 | package.target = "luac"..lua_suffix |
---|
| 180 | package.objdir = "../obj/"..package.name |
---|
| 181 | package.language = "c" |
---|
| 182 | package.kind = "exe" |
---|
| 183 | package.defines = lua_defines |
---|
| 184 | package.includepaths = { "../include", "../src" } |
---|
| 185 | package.path = project.path |
---|
| 186 | |
---|
| 187 | package.files = |
---|
| 188 | { |
---|
| 189 | "luac.c", "print.c" |
---|
| 190 | } |
---|
| 191 | fixPackagePath(package.files) |
---|
| 192 | |
---|
| 193 | if (options.os == "windows") then |
---|
| 194 | tinsert(package.files, {"../src/lua.rc"}) |
---|
| 195 | package.links = { "lua"..lua_suffix } |
---|
| 196 | package.libpaths = { "../lib/static" } |
---|
| 197 | package.linkoptions = { "setargv.obj" } |
---|
| 198 | else |
---|
| 199 | package.links = { "lua"..lua_suffix, "m" } |
---|
| 200 | package.libpaths = { "../lib" } |
---|
| 201 | |
---|
| 202 | if (options.os == "linux") then |
---|
| 203 | tinsert(package.links, {"dl"}) |
---|
| 204 | package.linkoptions = { "-Wl,-E" } |
---|
| 205 | end |
---|
| 206 | |
---|
| 207 | if (options.os == "bsd") then |
---|
| 208 | package.linkoptions = { "-Wl,-E" } |
---|
| 209 | end |
---|
| 210 | |
---|
| 211 | if (options.os == "sunos") then |
---|
| 212 | tinsert(package.links, {"dl"}) |
---|
| 213 | end |
---|
| 214 | end |
---|
| 215 | |
---|
| 216 | --------------------------------------------------------------------- |
---|
| 217 | |
---|
| 218 | package = newpackage() |
---|
| 219 | package.name = "bin2c"..lua_suffix.."_exe" |
---|
| 220 | package.target = "bin2c"..lua_suffix |
---|
| 221 | package.objdir = "../obj/"..package.name |
---|
| 222 | package.language = "c" |
---|
| 223 | package.kind = "exe" |
---|
| 224 | package.linkflags = { "static-runtime" } |
---|
| 225 | package.path = project.path |
---|
| 226 | |
---|
| 227 | package.files = |
---|
| 228 | { |
---|
| 229 | "../etc/bin2c.c" |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | if (options.os == "windows") then |
---|
| 233 | tinsert(package.files, {"../src/lua.rc"}) |
---|
| 234 | end |
---|
| 235 | |
---|
| 236 | --------------------------------------------------------------------- |
---|