4 # System and target names
5 SYSTEM
=$(shell uname
-o
)
6 ifeq ($(SYSTEM
), Cygwin
)
8 DLIB
= $(MODULE
)$(SOEXT
)
12 DLIB
= $(MODULE
)$(SOEXT
)
13 DLIBV
= $(DLIB
).
$(VERSION
)
20 LUABIN
=$(LUA
)/bin
/lua50
24 LUAWB
=$(LUA
)/doc
/luawb
29 LUADOCHOME
=$(LUAUTIL
)/luadoc20
30 LUADOC20
=$(LUADOCHOME
)/luadoc20.lua
31 LUADOCOPTS
=$(shell cat
$(LUADOCHOME
)/luadoc20
/luadoc.config
) --noindexpage
32 LUADOCBIN
=$(LUABIN
) -e
"LUADOC_HOME='$(LUADOCHOME)'" $(LUADOC20
)
35 LUALINT
=$(LUAUTIL
)/lualint
/lualint
37 # Lua 5.1 package compatibility
38 LUACOMPAT
=$(LUA
)/modules
/compat-5.1r4
39 COMPATOBJ
=$(LUACOMPAT
)/compat-5.1.o
40 COMPATINC
=$(LUACOMPAT
)
43 TOLUA
=$(LUA
)/..
/tolua
++-1.0.6
44 TOLUABIN
=$(TOLUA
)/bin
/tolua
++106
46 TOLUAINC
=$(TOLUA
)/include/
47 BINDC
= $(MODULE
)bind.c
48 BINDOBJ
= $(MODULE
)bind.o
49 BINDCXX
= $(MODULE
)bind.
cpp
50 BINDH
= $(MODULE
)bind.h
51 BINDHPP
= $(MODULE
)bind.hpp
55 ifeq ($(USE_CPLUSPLUS
), yes
)
63 INCS
= -I
$(LUAINC
) -I
$(TOLUAINC
) -I
$(LUACOMPAT
)
64 CFLAGS
= $(INCS
) $(WARN
) $(USERCFLAGS
)
65 CXXFLAGS
= $(INCS
) $(WARN
) $(USERCXXFLAGS
)
66 LDFLAGS
= -L
$(TOLUALIB
) $(USERLDFLAGS
)
69 # Libraries to link against
72 ifeq ($(USE_READLINE
), yes
)
73 LIBS
+= -lreadline
-lncurses
-lhistory
75 ifeq ($(USE_TOLUA
), yes
)
76 LIBDIR
+= -L
$(TOLUALIB
)
81 INSTALL_DIR
=$(INSTALL_ROOT
)
82 INSTALL_SHARE
=$(INSTALL_DIR
)/share
/lua
/5.0
83 INSTALL_LIB
=$(INSTALL_DIR
)/lib
/lua
/5.0
86 SUBST
= $(shell cat ..
/luadoc20
/luadoc.config
)
92 # Primary module is Lua, Secondary is C
93 mall
: $(DLIBV
) $(MODULE
)/core
$(SOEXT
)
97 mall
: $(DLIBV
) $(DLIB
)
102 ifeq ($(SYSTEM
), Cygwin
)
103 $(DLIB
): $(OBJS
) $(COMPATOBJ
) $(CXXOBJS
) Makefile.deps Makefile
104 $(LD
) -o
$@
-shared
-Wl
,--export-all-symbols
,--output-def
,$(MODULE
).def
,--out-implib
,$(DLIB
).a
$(LDFLAGS
) $(OBJS
) $(COMPATOBJ
) $(CXXOBJS
) $(LIBDIR
) $(LIBS
) -L
$(LUALIB
) -llua
$X -llualib
$X $(USERLIBDIR
) $(USERLIBS
)
106 $(DLIBV
): $(OBJS
) $(COMPATOBJ
) $(CXXOBJS
) Makefile.deps Makefile
107 $(LD
) -o
$@
-shared
$(LDFLAGS
) $(OBJS
) $(COMPATOBJ
) $(CXXOBJS
) $(LIBDIR
) $(LIBS
) $(USERLIBDIR
) $(USERLIBS
)
110 ln
-f
-s
$(DLIBV
) $(DLIB
)
113 $(SLIB
): $(OBJS
) $(CXXOBJS
) Makefile Makefile.deps
114 ar rcu
$(SLIB
) $(OBJS
) $(CXXOBJS
)
117 $(MODULE
)/core
$(SOEXT
): $(DLIBV
)
119 cp
$(DLIBV
) $(MODULE
)/core
$(SOEXT
)
121 $(BINDC
) $(BINDH
): $(PKG
)
122 $(TOLUABIN
) -1 -o
$(BINDC
) -H
$(BINDH
) $(PKG
)
124 $(BINDCXX
) $(BINDHPP
): $(PKG
)
125 $(TOLUABIN
) -1 -o
$(BINDCXX
) -H
$(BINDHPP
) $(PKG
)
129 .SUFFIXES
: .o .s .c .
cpp .
cxx .lch .lc .lua
132 $(CC
) -c
$(CFLAGS
) -o
$@
$<
138 $(CXX
) -c
$(CXXFLAGS
) -o
$@
$<
141 $(CXX
) -c
-Wa
,-alh
,-L
-dA
$(CXXFLAGS
) -o
$@
$< > $*.L
149 .PHONY
: install webbook
clean uclean depend
test testa
152 # Entries in the WEBBOOK based documentation
154 mkdir
-p
$(LUAWB
)/en
/modules
/$(MODULE
)
155 if
test -e manual.html
; then cp
-f manual.html
$(LUAWB
)/en
/modules
/$(MODULE
); fi
156 if
test -e
$(MODULE
).html
; then cp
-f
$(MODULE
).html
$(LUAWB
)/en
/modules
/$(MODULE
); fi
157 if
test -e README
; then cp
-f README
$(LUAWB
)/en
/modules
/$(MODULE
); fi
158 if
test -e README.leu
; then cp
-f README
$(LUAWB
)/en
/modules
/$(MODULE
); fi
159 if
test -e
$(DOCDIR
); then for i in
$(DOCS
); do cp
-f
$(DOCDIR
)/$$i $(LUAWB
)/en
/modules
/$(MODULE
); done
; fi
165 rm -f
$(OBJS
) $(CXXOBJS
) $(BINDC
) $(BINDCXX
) $(BINDH
) $(BINDHPP
) \
166 $(SLIB
) $(DLIB
).
$(VERSION
) $(DLIB
) $(DLIB
).a
$(MODULE
).def \
167 lib
$(DLIB
).
$(VERSION
) lib
$(DLIB
) \
168 core core.
* a.out
*~ Makefile.deps \
178 mdepend
: Makefile.deps
180 ifeq ($(USE_BINDDEPEND
), yes
)
181 Makefile.deps
: $(BINDH
) $(BINDHPP
) $(OBJS
:.o
=.c
) $(CXXOBJS
:.o
=.
cpp) $(HDRS
)
183 Makefile.deps
:$(OBJS
:.o
=.c
) $(CXXOBJS
:.o
=.
cpp) $(HDRS
)
186 test -z
"$(CXXOBJS)" ||
$(CXX
) -MM
$(CXXFLAGS
) $(CXXOBJS
:.o
=.
cpp) >> Makefile.deps
187 test -z
"$(OBJS)" ||
$(CC
) -MM
$(CFLAGS
) $(OBJS
:.o
=.c
) >> Makefile.deps
191 @if
test -e
test.lua
; then \
192 $(LUABIN
) -l
$(MODULE
) test.lua
$(LOG
); \
196 ifeq ($(SYSTEM
), Cygwin
)
197 @if
test -e
test.lua
; then
$(LUABIN
) -e
"LUA_LIBNAME='lib?.dll'" -l
$(MODULE
) test.lua
; fi
199 @if
test -e
test.lua
; then
$(LUABIN
) -e
"LUA_LIBNAME='lib?.so'" -l
$(MODULE
) test.lua
; fi
207 $(LUADOCBIN
) $(LUADOCOPTS
) -d .
$(MODULE
).lua
215 # Install <module>.lua if LMOD == yes
216 mkdir
-p
$(INSTALL_SHARE
)
217 cp
$(MODULE
).lua
$(INSTALL_SHARE
)
219 # Install core.<soext> if CMOD == yes
220 mkdir
-p
$(INSTALL_LIB
)/$(MODULE
)
221 cp
$(DLIBV
) $(INSTALL_LIB
)/$(MODULE
)/core
$(SOEXT
)
226 ifeq ($(SYSTEM
), Cygwin
)
228 # Install <module>.dll if LMOD != yes
229 mkdir
-p
$(INSTALL_LIB
)
230 cp
$(DLIB
) $(INSTALL_LIB
)
231 # if test -e $(MODULE).lua; then \
232 # mkdir -p $(INSTALL_SHARE); \
233 # cp $(MODULE).lua $(INSTALL_SHARE); \
237 # Install <module>.so if LMOD != yes
238 mkdir
-p
$(INSTALL_LIB
)
239 cp
$(DLIBV
) $(INSTALL_LIB
)/$(DLIB
)
240 # if test -e $(MODULE).lua; then \
241 # mkdir -p $(INSTALL_SHARE); \
242 # cp $(MODULE).lua $(INSTALL_SHARE); \
246 # Finally, do a module private install
249 cd
$(INSTALL_LIB
); rm -f
$(DLIB
) $(SLIB
)
250 cd
$(INSTALL_LIB
); rm -rf
$(MODULE
)
251 cd
$(INSTALL_SHARE
); rm -f
$(MODULE
).lua
254 @echo
"DLIB = "$(DLIB
)
255 @echo
"DLIBV = "$(DLIBV
)
272 ifneq ($(USE_DEPS
), no
)
273 -include Makefile.deps