xref: /freebsd/contrib/lua/src/Makefile (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
1# Makefile for building Lua
2# See ../doc/readme.html for installation and customization instructions.
3
4# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
5
6# Your platform. See PLATS for possible values.
7PLAT= guess
8
9CC= gcc -std=gnu99
10CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_3 $(SYSCFLAGS) $(MYCFLAGS)
11LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
12LIBS= -lm $(SYSLIBS) $(MYLIBS)
13
14AR= ar rcu
15RANLIB= ranlib
16RM= rm -f
17UNAME= uname
18
19SYSCFLAGS=
20SYSLDFLAGS=
21SYSLIBS=
22
23MYCFLAGS=
24MYLDFLAGS=
25MYLIBS=
26MYOBJS=
27
28# Special flags for compiler modules; -Os reduces code size.
29CMCFLAGS=
30
31# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
32
33PLATS= guess aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris
34
35LUA_A=	liblua.a
36CORE_O=	lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o
37LIB_O=	lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o
38BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
39
40LUA_T=	lua
41LUA_O=	lua.o
42
43LUAC_T=	luac
44LUAC_O=	luac.o
45
46ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
47ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
48ALL_A= $(LUA_A)
49
50# Targets start here.
51default: $(PLAT)
52
53all:	$(ALL_T)
54
55o:	$(ALL_O)
56
57a:	$(ALL_A)
58
59$(LUA_A): $(BASE_O)
60	$(AR) $@ $(BASE_O)
61	$(RANLIB) $@
62
63$(LUA_T): $(LUA_O) $(LUA_A)
64	$(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
65
66$(LUAC_T): $(LUAC_O) $(LUA_A)
67	$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
68
69test:
70	./lua -v
71
72clean:
73	$(RM) $(ALL_T) $(ALL_O)
74
75depend:
76	@$(CC) $(CFLAGS) -MM l*.c
77
78echo:
79	@echo "PLAT= $(PLAT)"
80	@echo "CC= $(CC)"
81	@echo "CFLAGS= $(CFLAGS)"
82	@echo "LDFLAGS= $(SYSLDFLAGS)"
83	@echo "LIBS= $(LIBS)"
84	@echo "AR= $(AR)"
85	@echo "RANLIB= $(RANLIB)"
86	@echo "RM= $(RM)"
87	@echo "UNAME= $(UNAME)"
88
89# Convenience targets for popular platforms.
90ALL= all
91
92help:
93	@echo "Do 'make PLATFORM' where PLATFORM is one of these:"
94	@echo "   $(PLATS)"
95	@echo "See doc/readme.html for complete instructions."
96
97guess:
98	@echo Guessing `$(UNAME)`
99	@$(MAKE) `$(UNAME)`
100
101AIX aix:
102	$(MAKE) $(ALL) CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" SYSLDFLAGS="-brtl -bexpall"
103
104bsd:
105	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-Wl,-E"
106
107c89:
108	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_C89" CC="gcc -std=c89"
109	@echo ''
110	@echo '*** C89 does not guarantee 64-bit integers for Lua.'
111	@echo ''
112
113FreeBSD NetBSD OpenBSD freebsd:
114	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE -I/usr/include/edit" SYSLIBS="-Wl,-E -ledit" CC="cc"
115
116generic: $(ALL)
117
118Linux linux:	linux-noreadline
119
120linux-noreadline:
121	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl"
122
123linux-readline:
124	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE" SYSLIBS="-Wl,-E -ldl -lreadline"
125
126Darwin macos macosx:
127	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" SYSLIBS="-lreadline"
128
129mingw:
130	$(MAKE) "LUA_A=lua54.dll" "LUA_T=lua.exe" \
131	"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
132	"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
133	$(MAKE) "LUAC_T=luac.exe" luac.exe
134
135posix:
136	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX"
137
138SunOS solaris:
139	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_REENTRANT" SYSLIBS="-ldl"
140
141# Targets that do not create files (not all makes understand .PHONY).
142.PHONY: all $(PLATS) help test clean default o a depend echo
143
144# Compiler modules may use special flags.
145llex.o:
146	$(CC) $(CFLAGS) $(CMCFLAGS) -c llex.c
147
148lparser.o:
149	$(CC) $(CFLAGS) $(CMCFLAGS) -c lparser.c
150
151lcode.o:
152	$(CC) $(CFLAGS) $(CMCFLAGS) -c lcode.c
153
154# DO NOT DELETE
155
156lapi.o: lapi.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
157 lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lstring.h \
158 ltable.h lundump.h lvm.h
159lauxlib.o: lauxlib.c lprefix.h lua.h luaconf.h lauxlib.h
160lbaselib.o: lbaselib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
161lcode.o: lcode.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \
162 llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \
163 ldo.h lgc.h lstring.h ltable.h lvm.h
164lcorolib.o: lcorolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
165lctype.o: lctype.c lprefix.h lctype.h lua.h luaconf.h llimits.h
166ldblib.o: ldblib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
167ldebug.o: ldebug.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
168 lobject.h ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h \
169 ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lvm.h
170ldo.o: ldo.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
171 lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lopcodes.h \
172 lparser.h lstring.h ltable.h lundump.h lvm.h
173ldump.o: ldump.c lprefix.h lua.h luaconf.h lobject.h llimits.h lstate.h \
174 ltm.h lzio.h lmem.h lundump.h
175lfunc.o: lfunc.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
176 llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h
177lgc.o: lgc.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
178 llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h
179linit.o: linit.c lprefix.h lua.h luaconf.h lualib.h lauxlib.h
180liolib.o: liolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
181llex.o: llex.c lprefix.h lua.h luaconf.h lctype.h llimits.h ldebug.h \
182 lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lgc.h llex.h lparser.h \
183 lstring.h ltable.h
184lmathlib.o: lmathlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
185lmem.o: lmem.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
186 llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h
187loadlib.o: loadlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
188lobject.o: lobject.c lprefix.h lua.h luaconf.h lctype.h llimits.h \
189 ldebug.h lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h \
190 lvm.h
191lopcodes.o: lopcodes.c lprefix.h lopcodes.h llimits.h lua.h luaconf.h
192loslib.o: loslib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
193lparser.o: lparser.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \
194 llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \
195 ldo.h lfunc.h lstring.h lgc.h ltable.h
196lstate.o: lstate.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
197 lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h llex.h \
198 lstring.h ltable.h
199lstring.o: lstring.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \
200 lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h
201lstrlib.o: lstrlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
202ltable.o: ltable.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
203 llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h
204ltablib.o: ltablib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
205ltm.o: ltm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
206 llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h
207lua.o: lua.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
208luac.o: luac.c lprefix.h lua.h luaconf.h lauxlib.h ldebug.h lstate.h \
209 lobject.h llimits.h ltm.h lzio.h lmem.h lopcodes.h lopnames.h lundump.h
210lundump.o: lundump.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \
211 lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h \
212 lundump.h
213lutf8lib.o: lutf8lib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
214lvm.o: lvm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
215 llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h \
216 ltable.h lvm.h ljumptab.h
217lzio.o: lzio.c lprefix.h lua.h luaconf.h llimits.h lmem.h lstate.h \
218 lobject.h ltm.h lzio.h
219
220# (end of Makefile)
221