added missing file from lua 5.0 integration patch
[rrdtool.git] / bindings / lua / Makefile.lua
1
2 print(string.format('%s %s %s\n', '# Makefile generated by', _VERSION, 'from Makefile.lua.\n'))
3
4 local opts = {
5   LUA                 = '/usr/bin/lua',
6   LUA_MAJOR           = '5',
7   LUA_MINOR           = '0',
8   LUA_HAVE_COMPAT51   = 'HAVE_COMPAT51',
9   LUA_RRD_LANGPREF    = '/scratch/rrd4/lib/lua',
10   LUA_CFLAGS          = '-I/usr/include//lua50  ',
11   LUA_LFLAGS          = '-llualib50 -llua50  ',
12   LUA_SRCS            = 'rrdlua.c',
13   LUA_OBJS            = 'rrdlua.o',
14   LUA_INSTALL_CMOD    = '/scratch/rrd4/lib/lua/5.0',
15   CC                  = 'gcc',
16 }
17
18 -- doesn't preserve key order, but it's OK
19 for k, v in pairs(opts) do
20   print(string.format('%s=%s', k, v))
21 end
22
23 local lua_ver = opts['LUA_MAJOR'] .. '.' .. opts['LUA_MINOR']
24
25 print([[
26
27 T= rrd
28 # Version
29 LIB_VERSION=0.0.9
30
31 # OS dependent
32 LIB_EXT= .so
33
34 LIBNAME= $T-$(LIB_VERSION)$(LIB_EXT)
35
36 RRD_CFLAGS=-I../../src
37 RRD_LIB_DIR=-L../../src/.libs -lrrd
38
39 # Set shared object options to what your platform requires
40 # For Solaris - tested with 2.6, gcc 2.95.3 20010315 and Solaris ld:
41 # LIB_OPTION= -G -dy
42 # For GNU ld:
43 LIB_OPTION= -shared -dy
44
45 # Choose the PIC option
46 # safest, works on most systems
47 PIC=-fPIC
48 # probably faster, but may not work on your system
49 #PIC=-fpic
50
51 # Compilation directives
52 OPTIONS= -O3 -Wall $(PIC) -fomit-frame-pointer -pedantic-errors -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings
53 LIBS= $(RRD_LIB_DIR) $(LUA_LFLAGS) -lm
54 CFLAGS= $(OPTIONS) $(LUA_CFLAGS) $(RRD_CFLAGS) -DLIB_VERSION=\"$(LIB_VERSION)\" -DLUA$(LUA_MAJOR)$(LUA_MINOR) -D$(LUA_HAVE_COMPAT51)
55
56 all: $(LIBNAME)
57
58 lib: $(LIBNAME)
59
60 *.o:    *.c
61
62 $(LIBNAME): $(LUA_OBJS)
63         $(CC) $(CFLAGS) $(LIB_OPTION) $(LUA_OBJS) $(LIBS) -o $(LIBNAME)
64
65 install: $(LIBNAME)
66         mkdir -p $(LUA_INSTALL_CMOD)
67         cp $(LIBNAME) $(LUA_INSTALL_CMOD)
68         #strip $(LUA_INSTALL_CMOD)/$(LIBNAME)
69         (cd $(LUA_INSTALL_CMOD) ; rm -f $T$(LIB_EXT) ; ln -fs $(LIBNAME) $T$(LIB_EXT))]])
70 if lua_ver == '5.0' and opts['LUA_HAVE_COMPAT51'] ~= 'HAVE_COMPAT51' then
71   print([[
72         mkdir -p $(LUA_RRD_LANGPREF)/5.0
73         cp compat-5.1r5/compat-5.1.lua $(LUA_RRD_LANGPREF)/5.0
74 ]])
75 end
76
77 print([[
78
79 test.lua: $(LIBNAME) test.lua.bottom
80         @echo "-- Created by Makefile." > test.lua
81         @echo "-- Test script adapted from the one in the Ruby binding." > test.lua
82         @echo >> test.lua]])
83 if lua_ver == '5.0' then
84   print([[
85         @echo "--- compat-5.1.lua is only required for Lua 5.0 ----------" >> test.lua]])
86
87   if opts['LUA_HAVE_COMPAT51'] ~= 'HAVE_COMPAT51' then
88     print([[
89         @echo "original_LUA_PATH = LUA_PATH" >> test.lua
90         @echo "-- try only compat-5.1.lua installed with RRDtool package" >> test.lua
91         @echo "LUA_PATH = '$(LUA_RRD_LANGPREF)/5.0/?.lua'" >> test.lua]])
92   end
93     print([[
94         @echo "local r = pcall(require, 'compat-5.1')" >> test.lua
95         @echo "if not r then" >> test.lua
96         @echo "  print('** compat-5.1.lua not found')" >> test.lua
97         @echo "  os.exit(1)" >> test.lua
98         @echo "end" >> test.lua]])
99
100   if opts['LUA_HAVE_COMPAT51'] ~= 'HAVE_COMPAT51' then
101     print([[
102         @echo "LUA_PATH = original_LUA_PATH" >> test.lua
103         @echo "original_LUA_PATH = nil" >> test.lua]])
104   end
105   print([[
106         @echo "----------------------------------------------------------" >> test.lua
107         @echo >> test.lua]])
108 end
109 if opts['LUA_RRD_LANGPREF'] .. '/' .. lua_ver == opts['LUA_INSTALL_CMOD'] then
110   print([[
111         @echo "package.cpath = '$(LUA_INSTALL_CMOD)/?.so;' .. package.cpath" >> test.lua]])
112 end
113 print([[
114         @cat test.lua.bottom >> test.lua
115
116 test: test.lua
117         $(LUA) test.lua
118
119 clean:
120         rm -f $(LIBNAME) $(LUA_OBJS) test.lua *.so *.rrd *.xml *.png *~
121 ]])
122