2 print(string.format('%s %s %s\n', '# Makefile generated by', _VERSION, 'from Makefile.lua.\n'))
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',
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))
23 local lua_ver = opts['LUA_MAJOR'] .. '.' .. opts['LUA_MINOR']
34 LIBNAME= $T-$(LIB_VERSION)$(LIB_EXT)
36 RRD_CFLAGS=-I../../src
37 RRD_LIB_DIR=-L../../src/.libs -lrrd
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:
43 LIB_OPTION= -shared -dy
45 # Choose the PIC option
46 # safest, works on most systems
48 # probably faster, but may not work on your system
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)
62 $(LIBNAME): $(LUA_OBJS)
63 $(CC) $(CFLAGS) $(LIB_OPTION) $(LUA_OBJS) $(LIBS) -o $(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
72 mkdir -p $(LUA_RRD_LANGPREF)/5.0
73 cp compat-5.1r5/compat-5.1.lua $(LUA_RRD_LANGPREF)/5.0
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
83 if lua_ver == '5.0' then
85 @echo "--- compat-5.1.lua is only required for Lua 5.0 ----------" >> test.lua]])
87 if opts['LUA_HAVE_COMPAT51'] ~= 'HAVE_COMPAT51' then
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]])
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]])
100 if opts['LUA_HAVE_COMPAT51'] ~= 'HAVE_COMPAT51' then
102 @echo "LUA_PATH = original_LUA_PATH" >> test.lua
103 @echo "original_LUA_PATH = nil" >> test.lua]])
106 @echo "----------------------------------------------------------" >> test.lua
109 if opts['LUA_RRD_LANGPREF'] .. '/' .. lua_ver == opts['LUA_INSTALL_CMOD'] then
111 @echo "package.cpath = '$(LUA_INSTALL_CMOD)/?.so;' .. package.cpath" >> test.lua]])
114 @cat test.lua.bottom >> test.lua
120 rm -f $(LIBNAME) $(LUA_OBJS) test.lua *.so *.rrd *.xml *.png *~