File: premake4.lua

package info (click to toggle)
liblo 0.28-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,968 kB
  • ctags: 1,386
  • sloc: sh: 11,605; ansic: 7,381; cpp: 868; makefile: 144
file content (288 lines) | stat: -rw-r--r-- 7,569 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
----------------------------------------------------------------------
-- Premake4 configuration script for LibLo
-- Adapted from ODE's build script by Jason Perkins.
-- For more information on Premake: http://industriousone.com/premake
----------------------------------------------------------------------

----------------------------------------------------------------------
-- Configuration options
----------------------------------------------------------------------

  -- always clean all of the optional components and toolsets
  if _ACTION == "clean" then
    for action in pairs(premake.actions) do
      os.rmdir(action)
    end
  end
  
  

----------------------------------------------------------------------
-- The solution, and solution-wide settings
----------------------------------------------------------------------

  solution "liblo"

    language "C"
    location ( _OPTIONS["to"] or _ACTION )

    newoption {
        trigger     = "without-threads",
        description = "Disable lo_server_thread functions, no need for pthread."
}

    newoption {
        trigger     = "pthreads",
	description = "Specify the location of the pthreads-w32 library."
    }

    includedirs {
      "../lo",
      "../src"
    }
      
    -- define all the possible build configurations
    configurations {
      "DebugDLL", "ReleaseDLL", 
      "DebugLib", "ReleaseLib", 
    }
    
    configuration { "Debug*" }
      defines { "_DEBUG" }
      flags   { "Symbols" }
      
    configuration { "Release*" }
      flags   { "OptimizeSpeed", "NoFramePointer" }

    configuration { "Windows" }
      defines { "WIN32" }

    -- give each configuration a unique output directory
    for _, name in ipairs(configurations()) do
      configuration { name }
        targetdir ( "../lib/" .. name )
    end
      
    -- disable Visual Studio security warnings
    configuration { "vs*" }
      defines { "_CRT_SECURE_NO_DEPRECATE" }

    -- tell source to use config.h
    configuration { "vs*" }
      defines { "HAVE_CONFIG_H" }

    -- don't remember why we had to do this	(from ODE)
    configuration { "vs2002 or vs2003", "*Lib" }
      flags  { "StaticRuntime" }

----------------------------------------------------------------------
-- Write a custom <config.h> to .., based on the supplied flags
----------------------------------------------------------------------

-- First get the version number from "configure.ac" --

  io.input("../configure.ac")
  text = io.read("*all")
  io.close()

  version = string.match(text, "AC_INIT%(%[liblo%],%[(%d+%.%d+%w+)%]")

  ltcurrent = string.match(text, "m4_define%(%[lt_current%], (%d+)")
  ltrev = string.match(text, "m4_define%(%[lt_revision%], (%d+)")
  ltage = string.match(text, "m4_define%(%[lt_age%], (%d+)")

  ltversion = '{' .. ltcurrent .. ', ' .. ltrev .. ', ' .. ltage .. '}'

-- Replace it in "config.h" --

  io.input("config-msvc.h")
  local text = io.read("*all")

  text = string.gsub(text, '/%*VERSION%*/', '"'..version..'"')

  if _OPTIONS["without-threads"] then
    text = string.gsub(text, '@DEFTHREADS@', '// ')
  else
    text = string.gsub(text, '@DEFTHREADS@', '')
  end

  text = string.gsub(text, '@LO_SO_VERSION@', ltversion)

  io.output("../config.h")
  io.write(text)
  io.close()

----------------------------------------------------------------------
-- Write a custom <liblo.def> to ../src/
----------------------------------------------------------------------

  io.input("../src/liblo.def.in")
  local text = io.read("*all")

  if _OPTIONS["without-threads"] then
    text = string.gsub(text, '@DEFTHREADS@', ';;')
  else
    text = string.gsub(text, '@DEFTHREADS@', '')
  end

  text = string.gsub(text, ' @DLL_NAME@', '')

  io.output("../src/liblo.def")
  io.write(text)
  io.close()

----------------------------------------------------------------------
-- Write a custom <lo.h> to ../lo/
----------------------------------------------------------------------

  io.input("../lo/lo.h.in")
  local text = io.read("*all")

  if _OPTIONS["without-threads"] then
    text = string.gsub(text, '@ENABLE_THREADS@', '0')
  else
    text = string.gsub(text, '@ENABLE_THREADS@', '1')
  end

  io.output("../lo/lo.h")
  io.write(text)
  io.close()

----------------------------------------------------------------------
-- Copy <lo_endian.h> to ../lo
----------------------------------------------------------------------

  io.input("lo_endian-msvc.h")
  io.output("../lo/lo_endian.h")
  local text = io.read("*all")
  io.write(text)
  io.close()

----------------------------------------------------------------------
-- The LibLo library project
----------------------------------------------------------------------

  project "liblo"

    kind     "StaticLib"
    location ( _OPTIONS["to"] or _ACTION )

    includedirs {
      "..",
    }

    files {
      "../src/*.c",
      "../src/*.h",
      "../lo/*.h",
      "../src/liblo.def",
    }

    excludes {
      "../src/testlo.c",
      "../src/subtest.c",
      "../src/test_bidirectional_tcp.c",
      "../src/tools",
    }

    configuration { "windows" }
      links   { "user32",
                "wsock32",
                "ws2_32",
                "iphlpapi",
              }

    configuration { "without-threads" }
      excludes { "../src/server_thread.c" }

    configuration { "not without-threads" }
      links { "pthreadVC2" }
      if (_OPTIONS["pthreads"]) then
        includedirs { _OPTIONS["pthreads"] }
      end

    configuration { "*Lib" }
      kind    "StaticLib"
      defines "LIBLO_LIB"
      
    configuration { "*DLL" }
      kind    "SharedLib"
      defines "LIBLO_DLL"

    configuration { "Debug*" }
      targetname "liblo_d"
      
    configuration { "Release*" }
      targetname "liblo"


----------------------------------------------------------------------
-- The automated test application
----------------------------------------------------------------------


  project "testlo"
  
    kind     "ConsoleApp"
    location ( _OPTIONS["to"] or _ACTION )
    links   { "user32",
              "wsock32",
              "ws2_32",
              "iphlpapi",
              "pthreadVC2",
            }

    includedirs { 
      "..",
    }
    
    files { 
      "../src/testlo.c",
    }

    configuration { "DebugDLL" }
      links { "liblo_d" }
      libdirs { "../lib/debugdll" }

    configuration { "DebugLib" }
      links { "liblo_d" }
      libdirs { "../lib/debuglib" }
      
    configuration { "Release*" }
      links { "liblo" }

    configuration { "not without-threads" }
      links { "pthreadVC2" }
      if (_OPTIONS["pthreads"]) then
        includedirs { _OPTIONS["pthreads"] }
      end

  project "subtest"
  
    kind     "ConsoleApp"
    location ( _OPTIONS["to"] or _ACTION )
    links   { "user32",
              "wsock32",
              "ws2_32",
              "iphlpapi",
              "pthreadVC2",
            }

    includedirs { 
      "..",
    }

    files { 
      "../src/subtest.c",
    }

    configuration { "DebugDLL" }
      links { "liblo_d" }
      libdirs { "../lib/debugdll" }

    configuration { "DebugLib" }
      links { "liblo_d" }
      libdirs { "../lib/debuglib" }
      
    configuration { "Release*" }
      links { "liblo" }