1 #*****************************************************************************
2 # Makefile Build System for Fawkes: Lua bits
4 # Created on Wed Mar 12 19:15:54 2008
5 # Copyright (C) 2006-2008 by Tim Niemueller, AllemaniACs RoboCup Team
7 #*****************************************************************************
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 #*****************************************************************************
16 ifndef __buildsys_lua_mk_
17 __buildsys_lua_mk_ := 1
19 include $(BASEDIR)/etc/buildsys/config.mk
23 # Check for Lua (Fedora packages lua and lua-devel)
25 LUA_PACKAGE = $(firstword $(foreach P,lua lua$(LUA_VERSION) lua-$(LUA_VERSION),$(if $(shell $(PKGCONFIG) --atleast-version $(LUA_VERSION) $(P); echo $${?/1/}),$(P))))
26 HAVE_LUA = $(if $(LUA_PACKAGE),1,0)
30 LUADIR = $(abspath $(BASEDIR)/src/lua)
31 LUALIBDIR = $(abspath $(LIBDIR)/lua)
32 EXEC_LUADIR ?= $(abspath $(EXEC_BASEDIR)/src/lua)
33 EXEC_LUALIBDIR ?= $(abspath $(EXEC_LIBDIR)/lua)
34 CFLAGS_LUA = $(shell $(PKGCONFIG) --cflags '$(LUA_PACKAGE)') -DHAVE_LUA -DLUADIR=\"$(EXEC_LUADIR)\" -DLUALIBDIR=\"$(EXEC_LUALIBDIR)\"
35 LDFLAGS_LUA = $(shell $(PKGCONFIG) --libs '$(LUA_PACKAGE)')
36 ifneq ($(wildcard $(SYSROOT)/usr/include/tolua++.h),)
39 TOLUA_LIBS=tolua++-$(LUA_VERSION)
41 ifneq ($(wildcard $(SYSROOT)/usr/local/include/lua$(subst .,,$(LUA_VERSION))/tolua++.h),)
43 TOLUAPP=/usr/local/bin/lua$(subst .,,$(LUA_VERSION))/tolua++
46 CLEAN_FILES=*_tolua.{pkg,cpp}
48 ifeq ($(HAVE_TOLUA),1)
50 %_tolua.cpp: $$(TOLUA_$$(subst /,_,$$*))
51 $(SILENT) echo "$(INDENT_PRINT)--- Generating Lua package C++ file $(@F)"
52 $(SILENT)cat $(addprefix $(SRCDIR)/,$(subst $(SRCDIR)/,,$(filter %.tolua,$^))) > $(patsubst %.cpp,%.pkg,$@)
53 $(SILENT)$(TOLUAPP) -n $(TOLUA_PKGPREFIX_$(subst /,_,$*))$(notdir $*) $(patsubst %.cpp,%.pkg,$@) | \
54 sed -e 's/^\(.*Generated automatically .*\) on .*$$/\1/' | \
55 awk '/^#if defined/ { f=1 }; f { t = t "\n" $$0 }; !f {print}; f && /^#endif/ {print "extern \"C\" {" t "\n}\n"; f=0}' | \
56 awk '/^\*\/$$/ { print; while ((getline line < "$(BASEDIR)/doc/headers/lichead_c.GPL_WRE") > 0) print line }; ! /^\*\/$$/ { print }' \
59 endif # HAVE_TOLUA is 1
62 ifeq ($(OBJSSUBMAKE),1)
63 .PHONY: warning_tolua_wrapper
64 warning_tolua_wrapper:
65 $(SILENT)echo -e "$(INDENT_PRINT)--> $(TRED)Omitting Lua compatibility wrapper$(TNORMAL) (tolua++[-devel] not installed)"
66 endif # OBJSSUBMAKE is 1
68 endif # __buildsys_lua_mk_