File: lua-config50

package info (click to toggle)
lua50 5.0.3-8
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,228 kB
  • ctags: 2,026
  • sloc: ansic: 12,032; makefile: 310; sh: 20
file content (165 lines) | stat: -rw-r--r-- 3,656 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/lua50
-- -*- Lua -*-

-- This file is under the terms of the MIT licence. Do as you will.

-- Process the arg table
function usage()
   info();
   io.stderr:write([[Usage: lua-config50 <options>

  Valid options are:

  --include      Outputs the -I switches needed to find <lua.h> etc.

  --static       Outputs the full path to the static libraries

  --libs         Outputs the -L and -l switches needed to find the library
  --libs-only-L  Outputs only the -L switches
  --libs-only-l  Outputs only the -l switches

  --extralibs    Outputs the -l switches appropriate to the extra libs needed by lua

  Note that --static is mututally exclusive with the --libs* options

  Also, you can specify the following

  --vmonly       Outputs only the switches for finding the VM libraries
  --libonly      Outputs only the switches for finding the standard libraries
  --both         Outputs the switches for both [The default]

  Example:

  gcc `lua-config50 --include` my_prog.c -o my_prog `lua-config50 --libs`

]] );
   os.exit(1);
end

function version()
   io.stdout:write( [[5.0.0
]] );
   os.exit(0);
end

function info()
   io.stdout:write( [[lua-config version 1.10 (c) Daniel Silverstone 2002

lua-config was written for the Debian GNU/Linux project. This version
of lua-config will provide switches appropriate to Lua 5.0

]] );
end

if( table.getn(arg) == 0 ) then
   usage()
end

output_vm      = 1
output_lib     = 1

output_static  = 0
output_libs_l  = 0
output_libs_L  = 0
output_include = 0
output_extras  = 0

table.foreachi( arg,
	 function(n,param)
	    if( param == '--version' ) then
	       version()
	    end
	    if( param == '--help' ) then
	       usage()
	    end
	    if( param == '--include' ) then
	       output_include = 1;
	       return
	    end
	    if( param == '--libs' ) then
	       output_libs_l = 1;
	       output_libs_L = 1;
	       return
	    end
	    if( param == '--libs-only-L' ) then
	       output_libs_L = 1;
	       return
	    end
	    if( param == '--libs-only-l' ) then
	       output_libs_l = 1;
	       return
	    end
	    if( param == '--extralibs' ) then
	       output_extras = 1;
	       return
	    end
	    if( param == '--static' ) then
	       output_static = 1;
	       return
	    end
	    if( param == '--vmonly' ) then
	       output_vm = 1;
	       output_lib = 0;
	       return
	    end
	    if( param == '--libonly' ) then
	       output_lib = 1;
	       output_vm = 0;
	       return
	    end
	    if( param == '--both' ) then
	       output_lib = 1;
	       output_vm = 1;
	       return
	    end
	    io.stderr:write( "Unknown argument ", param );
	    usage();
	 end );

if( (output_extras + output_libs_l + output_libs_L + output_include + output_static) == 0 ) then
   usage()
end

if( (output_static + (output_libs_l or output_libs_L)) > 1 ) then
   usage();
end

outargs = {}

if( output_include == 1 ) then
   table.insert( outargs, "-I/usr/include/lua50" );
end

if( output_libs_L == 1 ) then
   table.insert( outargs, "-L/usr/include" );
end

if( output_libs_l == 1 ) then
   if( output_lib == 1 ) then
      table.insert( outargs, "-llualib50" );
   end
   if( output_vm == 1 ) then
      table.insert( outargs, "-llua50" );
   end
end

if( output_static == 1 ) then
   if( output_lib == 1 ) then
      table.insert( outargs, "/usr/lib/liblualib50.a" );
   end
   if( output_vm == 1 ) then
      table.insert( outargs, "/usr/lib/liblua50.a" );
   end
end

if( output_extras == 1 ) then
   table.insert( outargs, "-lm" );
end

io.stdout:write( outargs[1] );

for i=2,table.getn(outargs) do
   io.stdout:write( " ", outargs[i] );
end

io.stdout:write( "\n" );