diff options
| author | Oscar Lim <olim@ucla.edu> | 2016-01-24 22:53:37 -0800 |
|---|---|---|
| committer | Oscar Lim <olim@ucla.edu> | 2016-02-10 23:45:49 -0800 |
| commit | 7499b422e3f07bf25704cbf7989e845f89697fa8 (patch) | |
| tree | 524d8a262a9d61486b858e70c64f8aedbda43095 /src/Makefile | |
| download | luasystem-7499b422e3f07bf25704cbf7989e845f89697fa8.tar.gz luasystem-7499b422e3f07bf25704cbf7989e845f89697fa8.tar.bz2 luasystem-7499b422e3f07bf25704cbf7989e845f89697fa8.zip | |
Support for gettime and sleep functions
Provide `gettime` and `sleep` functions with at least 1 millisecond
resolution.
Diffstat (limited to 'src/Makefile')
| -rw-r--r-- | src/Makefile | 257 |
1 files changed, 257 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..25f468d --- /dev/null +++ b/src/Makefile | |||
| @@ -0,0 +1,257 @@ | |||
| 1 | # luasystem | ||
| 2 | # | ||
| 3 | # Definitions in this section can be overriden on the command line or in the | ||
| 4 | # environment. | ||
| 5 | # | ||
| 6 | |||
| 7 | # PLAT: linux macosx win32 mingw | ||
| 8 | # platform to build for | ||
| 9 | PLAT?=linux | ||
| 10 | |||
| 11 | # LUA_VERSION: 5.1 5.2 5.3 | ||
| 12 | # lua version to build against | ||
| 13 | LUA_VERSION?=5.1 | ||
| 14 | |||
| 15 | # MYCFLAGS: to be set by user if needed | ||
| 16 | MYCFLAGS= | ||
| 17 | |||
| 18 | # MYLDFLAGS: to be set by user if needed | ||
| 19 | MYLDFLAGS= | ||
| 20 | |||
| 21 | # where lua headers are found for macosx builds | ||
| 22 | # LUAINC_macosx: | ||
| 23 | # /opt/local/include | ||
| 24 | LUAINC_macosx_base?=/opt/local/include | ||
| 25 | LUAINC_macosx?=$(LUAINC_macosx_base)/lua/$(LUA_VERSION) | ||
| 26 | # FIXME default should this default to fink or to macports? | ||
| 27 | # What happens when more than one Lua version is installed? | ||
| 28 | LUAPREFIX_macosx?=/opt/local | ||
| 29 | CDIR_macosx?=lib/lua/$(LUA_VERSION) | ||
| 30 | LDIR_macosx?=share/lua/$(LUA_VERSION) | ||
| 31 | |||
| 32 | # LUAINC_linux: | ||
| 33 | # /usr/include/lua$(LUA_VERSION) | ||
| 34 | # /usr/local/include | ||
| 35 | # /usr/local/include/lua$(LUA_VERSION) | ||
| 36 | # where lua headers are found for linux builds | ||
| 37 | LUAINC_linux_base?=/usr/include | ||
| 38 | LUAINC_linux?=$(LUAINC_linux_base)/lua/$(LUA_VERSION) | ||
| 39 | LUAPREFIX_linux?=/usr/local | ||
| 40 | CDIR_linux?=lib/lua/$(LUA_VERSION) | ||
| 41 | LDIR_linux?=share/lua/$(LUA_VERSION) | ||
| 42 | |||
| 43 | # LUAINC_freebsd: | ||
| 44 | # /usr/local/include/lua$(LUA_VERSION) | ||
| 45 | # where lua headers are found for linux builds | ||
| 46 | LUAINC_freebsd_base?=/usr/local/include/ | ||
| 47 | LUAINC_freebsd?=$(LUAINC_freebsd_base)/lua$(LUA_VERSION) | ||
| 48 | LUAPREFIX_freebsd?=/usr/local/ | ||
| 49 | CDIR_freebsd?=lib/lua/$(LUA_VERSION) | ||
| 50 | LDIR_freebsd?=share/lua/$(LUA_VERSION) | ||
| 51 | |||
| 52 | # where lua headers are found for mingw builds | ||
| 53 | # LUAINC_mingw: | ||
| 54 | # /opt/local/include | ||
| 55 | LUAINC_mingw_base?=/usr/include | ||
| 56 | LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUA_VERSION) | ||
| 57 | LUALIB_mingw_base?=/usr/bin | ||
| 58 | LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUA_VERSION)/lua$(subst .,,$(LUA_VERSION)).dll | ||
| 59 | LUAPREFIX_mingw?=/usr | ||
| 60 | CDIR_mingw?=lua/$(LUA_VERSION) | ||
| 61 | LDIR_mingw?=lua/$(LUA_VERSION)/lua | ||
| 62 | |||
| 63 | |||
| 64 | # LUAINC_win32: | ||
| 65 | # LUALIB_win32: | ||
| 66 | # where lua headers and libraries are found for win32 builds | ||
| 67 | LUAPREFIX_win32?= | ||
| 68 | LUAINC_win32?=$(LUAPREFIX_win32)/include/lua/$(LUA_VERSION) | ||
| 69 | PLATFORM_win32?=Release | ||
| 70 | CDIR_win32?=bin/lua/$(LUA_VERSION)/$(PLATFORM_win32) | ||
| 71 | LDIR_win32?=bin/lua/$(LUA_VERSION)/$(PLATFORM_win32)/lua | ||
| 72 | LUALIB_win32?=$(LUAPREFIX_win32)/lib/lua/$(LUA_VERSION)/$(PLATFORM_win32) | ||
| 73 | LUALIBNAME_win32?=lua$(subst .,,$(LUA_VERSION)).lib | ||
| 74 | |||
| 75 | |||
| 76 | # prefix: /usr/local /usr /opt/local /sw | ||
| 77 | # the top of the default install tree | ||
| 78 | prefix?=$(LUAPREFIX_$(PLAT)) | ||
| 79 | |||
| 80 | CDIR?=$(CDIR_$(PLAT)) | ||
| 81 | LDIR?=$(LDIR_$(PLAT)) | ||
| 82 | |||
| 83 | # DESTDIR: (no default) | ||
| 84 | # used by package managers to install into a temporary destination | ||
| 85 | DESTDIR= | ||
| 86 | |||
| 87 | #------ | ||
| 88 | # Definitions below can be overridden on the make command line, but | ||
| 89 | # shouldn't have to be. | ||
| 90 | |||
| 91 | |||
| 92 | #------ | ||
| 93 | # Install directories | ||
| 94 | # | ||
| 95 | |||
| 96 | INSTALL_DIR=install -d | ||
| 97 | INSTALL_DATA=install -m644 | ||
| 98 | INSTALL_EXEC=install | ||
| 99 | INSTALL_TOP=$(DESTDIR)$(prefix) | ||
| 100 | |||
| 101 | INSTALL_TOP_LDIR=$(INSTALL_TOP)/$(LDIR) | ||
| 102 | INSTALL_TOP_CDIR=$(INSTALL_TOP)/$(CDIR) | ||
| 103 | |||
| 104 | INSTALL_LDIR=$(INSTALL_TOP_LDIR)/system | ||
| 105 | INSTALL_CDIR=$(INSTALL_TOP_CDIR)/system | ||
| 106 | |||
| 107 | #------ | ||
| 108 | # Supported platforms | ||
| 109 | # | ||
| 110 | PLATS= macosx linux win32 mingw | ||
| 111 | |||
| 112 | #------ | ||
| 113 | # Compiler and linker settings | ||
| 114 | # for Mac OS X | ||
| 115 | SO_macosx=so | ||
| 116 | O_macosx=o | ||
| 117 | CC_macosx=gcc | ||
| 118 | DEF_macosx= | ||
| 119 | CFLAGS_macosx= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \ | ||
| 120 | -fvisibility=hidden | ||
| 121 | LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o | ||
| 122 | LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc | ||
| 123 | |||
| 124 | #------ | ||
| 125 | # Compiler and linker settings | ||
| 126 | # for Linux | ||
| 127 | SO_linux=so | ||
| 128 | O_linux=o | ||
| 129 | CC_linux=gcc | ||
| 130 | DEF_linux= | ||
| 131 | CFLAGS_linux= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \ | ||
| 132 | -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden | ||
| 133 | LDFLAGS_linux=-O -shared -fpic -o | ||
| 134 | LD_linux=gcc | ||
| 135 | |||
| 136 | #------ | ||
| 137 | # Compiler and linker settings | ||
| 138 | # for FreeBSD | ||
| 139 | SO_freebsd=so | ||
| 140 | O_freebsd=o | ||
| 141 | CC_freebsd=gcc | ||
| 142 | DEF_freebsd= | ||
| 143 | CFLAGS_freebsd= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \ | ||
| 144 | -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden | ||
| 145 | LDFLAGS_freebsd=-O -shared -fpic -o | ||
| 146 | LD_freebsd=gcc | ||
| 147 | |||
| 148 | #------ | ||
| 149 | # Compiler and linker settings | ||
| 150 | # for MingW | ||
| 151 | SO_mingw=dll | ||
| 152 | O_mingw=o | ||
| 153 | CC_mingw=gcc | ||
| 154 | DEF_mingw=-DWINVER=0x0501 | ||
| 155 | CFLAGS_mingw= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \ | ||
| 156 | -fvisibility=hidden | ||
| 157 | LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -o | ||
| 158 | LD_mingw=gcc | ||
| 159 | |||
| 160 | |||
| 161 | #------ | ||
| 162 | # Compiler and linker settings | ||
| 163 | # for Win32 | ||
| 164 | SO_win32=dll | ||
| 165 | O_win32=obj | ||
| 166 | CC_win32=cl | ||
| 167 | DEF_win32= //D "WIN32" //D "NDEBUG" //D "_WINDOWS" //D "_USRDLL" \ | ||
| 168 | //D "_CRT_SECURE_NO_WARNINGS" //D "_WINDLL" | ||
| 169 | CFLAGS_win32=//I "$(LUAINC)" $(DEF) //O2 //Ot //MD //W3 //nologo | ||
| 170 | LDFLAGS_win32= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \ | ||
| 171 | //MANIFEST //MANIFESTFILE:"intermediate.manifest" \ | ||
| 172 | //MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ | ||
| 173 | //SUBSYSTEM:WINDOWS //OPT:REF //OPT:ICF //DYNAMICBASE:NO \ | ||
| 174 | //MACHINE:X86 /LIBPATH:"$(shell cmd //c echo $(LUALIB))" \ | ||
| 175 | $(LUALIBNAME_win32) //OUT: | ||
| 176 | LD_win32=cl | ||
| 177 | |||
| 178 | .SUFFIXES: .obj | ||
| 179 | |||
| 180 | .c.obj: | ||
| 181 | $(CC) $(CFLAGS) //Fo"$@" //c $< | ||
| 182 | |||
| 183 | #------ | ||
| 184 | # Output file names | ||
| 185 | # | ||
| 186 | SO=$(SO_$(PLAT)) | ||
| 187 | O=$(O_$(PLAT)) | ||
| 188 | SOLIB=core.$(SO) | ||
| 189 | |||
| 190 | #------ | ||
| 191 | # Settings selected for platform | ||
| 192 | # | ||
| 193 | CC=$(CC_$(PLAT)) | ||
| 194 | DEF=$(DEF_$(PLAT)) | ||
| 195 | CFLAGS=$(MYCFLAGS) $(CFLAGS_$(PLAT)) | ||
| 196 | LDFLAGS=$(MYLDFLAGS) $(LDFLAGS_$(PLAT)) | ||
| 197 | LD=$(LD_$(PLAT)) | ||
| 198 | LUAINC= $(LUAINC_$(PLAT)) | ||
| 199 | LUALIB= $(LUALIB_$(PLAT)) | ||
| 200 | |||
| 201 | #------ | ||
| 202 | # Objects | ||
| 203 | # | ||
| 204 | OBJS=core.$(O) compat.$(O) time.$(O) | ||
| 205 | |||
| 206 | #------ | ||
| 207 | # Targets | ||
| 208 | # | ||
| 209 | default: $(PLAT) | ||
| 210 | |||
| 211 | freebsd: | ||
| 212 | $(MAKE) all PLAT=freebsd | ||
| 213 | |||
| 214 | macosx: | ||
| 215 | $(MAKE) all PLAT=macosx | ||
| 216 | |||
| 217 | win32: | ||
| 218 | $(MAKE) all PLAT=win32 | ||
| 219 | |||
| 220 | linux: | ||
| 221 | $(MAKE) all PLAT=linux | ||
| 222 | |||
| 223 | mingw: | ||
| 224 | $(MAKE) all PLAT=mingw | ||
| 225 | |||
| 226 | none: | ||
| 227 | @echo "Please run" | ||
| 228 | @echo " make PLATFORM" | ||
| 229 | @echo "where PLATFORM is one of these:" | ||
| 230 | @echo " $(PLATS)" | ||
| 231 | |||
| 232 | all: $(SOLIB) | ||
| 233 | |||
| 234 | $(SOLIB): $(OBJS) | ||
| 235 | $(LD) $(OBJS) $(LDFLAGS)$@ | ||
| 236 | |||
| 237 | install: all | ||
| 238 | $(INSTALL_DIR) $(INSTALL_TOP_LDIR) | ||
| 239 | $(INSTALL_DIR) $(INSTALL_CDIR) | ||
| 240 | $(INSTALL_EXEC) $(SOLIB) $(INSTALL_CDIR)/$(SOLIB) | ||
| 241 | |||
| 242 | local: | ||
| 243 | $(MAKE) install INSTALL_TOP_CDIR=.. INSTALL_TOP_LDIR=.. | ||
| 244 | |||
| 245 | clean: | ||
| 246 | rm -f $(SOLIB) $(OBJS) ../system/core.so | ||
| 247 | |||
| 248 | print: | ||
| 249 | @echo PLAT=$(PLAT) | ||
| 250 | @echo LUA_VERSION=$(LUA_VERSION) | ||
| 251 | @echo prefix=$(prefix) | ||
| 252 | @echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT)) | ||
| 253 | @echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT)) | ||
| 254 | @echo INSTALL_TOP_CDIR=$(INSTALL_TOP_CDIR) | ||
| 255 | @echo INSTALL_TOP_LDIR=$(INSTALL_TOP_LDIR) | ||
| 256 | |||
| 257 | .PHONY: all $(PLATS) default clean none | ||
