Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/lua-5.1.3/etc/premake.lua @ 28

Last change on this file since 28 was 28, checked in by landauf, 16 years ago
File size: 6.3 KB
Line 
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
18if (not options.target) then 
19  options.target = "gnu"
20end
21
22if (not options.os) then
23  if (options.target ~= "gnu") then
24    options.os = "windows"
25  else
26    options.os = "linux"
27  end
28end
29
30function 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
36end
37
38----------------------------------------------------
39
40lua_suffix = "5.1"
41
42project.name = "lua"..lua_suffix
43project.bindir = "../bin"
44project.libdir = "../lib"
45
46if (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
52end
53
54lua_defines = { }
55
56if (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
61else
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
79end
80
81if (options.target == "vs2005") then
82  tinsert(lua_defines, {"_CRT_SECURE_NO_DEPRECATE"}) 
83end
84
85----------------------------------------------------
86
87package = newpackage()
88package.name = "lua"..lua_suffix.."_dll"
89package.target = "lua"..lua_suffix
90package.objdir = "../obj/"..package.name
91package.language = "c"
92package.kind = "dll"
93package.defines = lua_defines
94package.includepaths = { "../include" }
95package.path = project.path
96
97lua_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}                       
105fixPackagePath(lua_files)
106
107package.files = lua_files
108
109if (options.os == "windows") then
110  tinsert(package.files, {"../src/lua"..lua_suffix..".def"})
111end
112
113---------------------------------------------------------------------
114
115package = newpackage()
116package.name = "lua"..lua_suffix.."_lib"
117package.target = "lua"..lua_suffix
118package.objdir = "../obj/"..package.name
119if (options.os == "windows") then
120  package.libdir = "../lib/static"
121end
122package.language = "c"
123package.kind = "lib"
124package.defines = lua_defines
125package.files = lua_files
126package.includepaths = { "../include" }
127package.path = project.path
128
129---------------------------------------------------------------------
130
131package = newpackage()
132package.name = "lua"..lua_suffix.."_exe"
133package.target = "lua"..lua_suffix
134package.objdir = "../obj/"..package.name
135package.language = "c"
136package.kind = "exe"
137package.defines = lua_defines
138package.includepaths = { "../include" }
139package.path = project.path
140
141package.files =
142{
143  "lua.c"
144}
145fixPackagePath(package.files)
146
147if (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
156else
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
173end
174
175---------------------------------------------------------------------
176
177package = newpackage()
178package.name = "luac"..lua_suffix.."_exe"
179package.target = "luac"..lua_suffix
180package.objdir = "../obj/"..package.name
181package.language = "c"
182package.kind = "exe"
183package.defines = lua_defines
184package.includepaths = { "../include", "../src" }
185package.path = project.path
186
187package.files =
188{
189  "luac.c", "print.c"
190}
191fixPackagePath(package.files)
192
193if (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" }
198else
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
214end
215
216---------------------------------------------------------------------
217
218package = newpackage()
219package.name = "bin2c"..lua_suffix.."_exe"
220package.target = "bin2c"..lua_suffix
221package.objdir = "../obj/"..package.name
222package.language = "c"
223package.kind = "exe"
224package.linkflags = { "static-runtime" }
225package.path = project.path
226
227package.files =
228{
229  "../etc/bin2c.c"
230}
231
232if (options.os == "windows") then
233  tinsert(package.files, {"../src/lua.rc"})
234end
235
236---------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.