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