xref: /freebsd/contrib/lua/src/Makefile (revision 2e3f49888ec8851bafb22011533217487764fdb0)
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 ios 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
118ios:
119	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_IOS"
120
121Linux linux:	linux-noreadline
122
123linux-noreadline:
124	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl"
125
126linux-readline:
127	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE" SYSLIBS="-Wl,-E -ldl -lreadline"
128
129Darwin macos macosx:
130	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" SYSLIBS="-lreadline"
131
132mingw:
133	$(MAKE) "LUA_A=lua54.dll" "LUA_T=lua.exe" \
134	"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
135	"SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe
136	$(MAKE) "LUAC_T=luac.exe" luac.exe
137
138posix:
139	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX"
140
141SunOS solaris:
142	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_REENTRANT" SYSLIBS="-ldl"
143
144# Targets that do not create files (not all makes understand .PHONY).
145.PHONY: all $(PLATS) help test clean default o a depend echo
146
147# Compiler modules may use special flags.
148llex.o:
149	$(CC) $(CFLAGS) $(CMCFLAGS) -c llex.c
150
151lparser.o:
152	$(CC) $(CFLAGS) $(CMCFLAGS) -c lparser.c
153
154lcode.o:
155	$(CC) $(CFLAGS) $(CMCFLAGS) -c lcode.c
156
157# DO NOT DELETE
158
159lapi.o: lapi.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
160 lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lstring.h \
161 ltable.h lundump.h lvm.h
162lauxlib.o: lauxlib.c lprefix.h lua.h luaconf.h lauxlib.h
163lbaselib.o: lbaselib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
164lcode.o: lcode.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \
165 llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \
166 ldo.h lgc.h lstring.h ltable.h lvm.h
167lcorolib.o: lcorolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
168lctype.o: lctype.c lprefix.h lctype.h lua.h luaconf.h llimits.h
169ldblib.o: ldblib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
170ldebug.o: ldebug.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
171 lobject.h ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h \
172 ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lvm.h
173ldo.o: ldo.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
174 lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lopcodes.h \
175 lparser.h lstring.h ltable.h lundump.h lvm.h
176ldump.o: ldump.c lprefix.h lua.h luaconf.h lobject.h llimits.h lstate.h \
177 ltm.h lzio.h lmem.h lundump.h
178lfunc.o: lfunc.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
179 llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h
180lgc.o: lgc.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
181 llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h
182linit.o: linit.c lprefix.h lua.h luaconf.h lualib.h lauxlib.h
183liolib.o: liolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
184llex.o: llex.c lprefix.h lua.h luaconf.h lctype.h llimits.h ldebug.h \
185 lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lgc.h llex.h lparser.h \
186 lstring.h ltable.h
187lmathlib.o: lmathlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
188lmem.o: lmem.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
189 llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h
190loadlib.o: loadlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
191lobject.o: lobject.c lprefix.h lua.h luaconf.h lctype.h llimits.h \
192 ldebug.h lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h \
193 lvm.h
194lopcodes.o: lopcodes.c lprefix.h lopcodes.h llimits.h lua.h luaconf.h
195loslib.o: loslib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
196lparser.o: lparser.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \
197 llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \
198 ldo.h lfunc.h lstring.h lgc.h ltable.h
199lstate.o: lstate.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \
200 lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h llex.h \
201 lstring.h ltable.h
202lstring.o: lstring.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \
203 lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h
204lstrlib.o: lstrlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
205ltable.o: ltable.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
207ltablib.o: ltablib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
208ltm.o: ltm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
209 llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h
210lua.o: lua.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
211luac.o: luac.c lprefix.h lua.h luaconf.h lauxlib.h ldebug.h lstate.h \
212 lobject.h llimits.h ltm.h lzio.h lmem.h lopcodes.h lopnames.h lundump.h
213lundump.o: lundump.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \
214 lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h \
215 lundump.h
216lutf8lib.o: lutf8lib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
217lvm.o: lvm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
218 llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h \
219 ltable.h lvm.h ljumptab.h
220lzio.o: lzio.c lprefix.h lua.h luaconf.h llimits.h lmem.h lstate.h \
221 lobject.h ltm.h lzio.h
222
223# (end of Makefile)
224