diff options
Diffstat (limited to 'src/makefile')
| -rw-r--r-- | src/makefile | 114 |
1 files changed, 78 insertions, 36 deletions
diff --git a/src/makefile b/src/makefile index a75d5a6..a6e0033 100644 --- a/src/makefile +++ b/src/makefile | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | # | 12 | # |
| 13 | # make PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw | 13 | # make PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw |
| 14 | 14 | ||
| 15 | # PLAT: linux macosx win32 | 15 | # PLAT: linux macosx win32 mingw |
| 16 | # platform to build for | 16 | # platform to build for |
| 17 | PLAT?=linux | 17 | PLAT?=linux |
| 18 | 18 | ||
| @@ -33,6 +33,9 @@ LUAINC_macosx?=$(LUAINC_macosx_base)/lua$(LUAV) | |||
| 33 | # FIXME default should this default to fink or to macports? | 33 | # FIXME default should this default to fink or to macports? |
| 34 | # What happens when more than one Lua version is installed? | 34 | # What happens when more than one Lua version is installed? |
| 35 | LUAPREFIX_macosx?=/opt/local | 35 | LUAPREFIX_macosx?=/opt/local |
| 36 | CDIR_macosx?=lib/lua/$(LUAV) | ||
| 37 | LDIR_macosx?=share/lua/$(LUAV) | ||
| 38 | |||
| 36 | 39 | ||
| 37 | # LUAINC_linux: | 40 | # LUAINC_linux: |
| 38 | # /usr/include/lua$(LUAV) | 41 | # /usr/include/lua$(LUAV) |
| @@ -42,19 +45,38 @@ LUAPREFIX_macosx?=/opt/local | |||
| 42 | LUAINC_linux_base?=/usr/include | 45 | LUAINC_linux_base?=/usr/include |
| 43 | LUAINC_linux?=$(LUAINC_linux_base)/lua$(LUAV) | 46 | LUAINC_linux?=$(LUAINC_linux_base)/lua$(LUAV) |
| 44 | LUAPREFIX_linux?=/usr/local | 47 | LUAPREFIX_linux?=/usr/local |
| 48 | CDIR_linux?=lib/lua/$(LUAV) | ||
| 49 | LDIR_linux?=share/lua/$(LUAV) | ||
| 50 | |||
| 51 | # where lua headers are found for mingw builds | ||
| 52 | # LUAINC_mingw: | ||
| 53 | # /opt/local/include | ||
| 54 | LUAINC_mingw_base?=/usr/include | ||
| 55 | LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUAV) | ||
| 56 | LUALIB_mingw_base?=/usr/bin | ||
| 57 | LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUAV)/lua$(subst .,,$(LUAV)).dll | ||
| 58 | LUAPREFIX_mingw?=/usr | ||
| 59 | CDIR_mingw?=lua/$(LUAV) | ||
| 60 | LDIR_mingw?=lua/$(LUAV)/lua | ||
| 61 | |||
| 45 | 62 | ||
| 46 | # LUAINC_win32: | 63 | # LUAINC_win32: |
| 47 | # LUALIB_win32: | 64 | # LUALIB_win32: |
| 48 | # where lua headers and libraries are found for win32 builds | 65 | # where lua headers and libraries are found for win32 builds |
| 49 | LUAINC_win32?="../../lua-5.1.3/src" | 66 | LUAINC_win32?="../../lua-5.1.3/src" |
| 50 | LUALIB_win32?="../../lua-5.1.3" | 67 | LUALIB_win32?=/LIBPATH:"../../lua-5.1.3" lua$(LUAV).lib |
| 68 | |||
| 51 | LUAPREFIX_win32?= | 69 | LUAPREFIX_win32?= |
| 52 | # FIXME default should be where lua-for-windows puts lua | 70 | CDIR_win32?=lua/$(LUAV) |
| 71 | LDIR_win32?=lua/$(LUAV)/lua | ||
| 53 | 72 | ||
| 54 | # prefix: /usr/local /usr /opt/local /sw | 73 | # prefix: /usr/local /usr /opt/local /sw |
| 55 | # the top of the default install tree | 74 | # the top of the default install tree |
| 56 | prefix?=$(LUAPREFIX_$(PLAT)) | 75 | prefix?=$(LUAPREFIX_$(PLAT)) |
| 57 | 76 | ||
| 77 | CDIR?=$(CDIR_$(PLAT)) | ||
| 78 | LDIR?=$(LDIR_$(PLAT)) | ||
| 79 | |||
| 58 | # DESTDIR: (no default) | 80 | # DESTDIR: (no default) |
| 59 | # used by package managers to install into a temporary destination | 81 | # used by package managers to install into a temporary destination |
| 60 | DESTDIR= | 82 | DESTDIR= |
| @@ -63,13 +85,6 @@ DESTDIR= | |||
| 63 | # Definitions below can be overridden on the make command line, but | 85 | # Definitions below can be overridden on the make command line, but |
| 64 | # shouldn't have to be. | 86 | # shouldn't have to be. |
| 65 | 87 | ||
| 66 | print: | ||
| 67 | @echo PLAT=$(PLAT) | ||
| 68 | @echo LUAV=$(LUAV) | ||
| 69 | @echo DEBUG=$(DEBUG) | ||
| 70 | @echo prefix=$(prefix) | ||
| 71 | @echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT)) | ||
| 72 | @echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT)) | ||
| 73 | 88 | ||
| 74 | #------ | 89 | #------ |
| 75 | # Install directories | 90 | # Install directories |
| @@ -80,18 +95,28 @@ INSTALL_DATA=install -m644 | |||
| 80 | INSTALL_EXEC=install | 95 | INSTALL_EXEC=install |
| 81 | INSTALL_TOP=$(DESTDIR)$(prefix) | 96 | INSTALL_TOP=$(DESTDIR)$(prefix) |
| 82 | 97 | ||
| 83 | INSTALL_TOP_SHARE=$(INSTALL_TOP)/share/lua/$(LUAV) | 98 | INSTALL_TOP_LDIR=$(INSTALL_TOP)/$(LDIR) |
| 84 | INSTALL_TOP_LIB=$(INSTALL_TOP)/lib/lua/$(LUAV) | 99 | INSTALL_TOP_CDIR=$(INSTALL_TOP)/$(CDIR) |
| 100 | |||
| 101 | INSTALL_SOCKET_LDIR=$(INSTALL_TOP_LDIR)/socket | ||
| 102 | INSTALL_SOCKET_CDIR=$(INSTALL_TOP_CDIR)/socket | ||
| 103 | INSTALL_MIME_LDIR=$(INSTALL_TOP_LDIR)/mime | ||
| 104 | INSTALL_MIME_CDIR=$(INSTALL_TOP_CDIR)/mime | ||
| 85 | 105 | ||
| 86 | INSTALL_SOCKET_SHARE=$(INSTALL_TOP_SHARE)/socket | 106 | print: |
| 87 | INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket | 107 | @echo PLAT=$(PLAT) |
| 88 | INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime | 108 | @echo LUAV=$(LUAV) |
| 89 | INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime | 109 | @echo DEBUG=$(DEBUG) |
| 110 | @echo prefix=$(prefix) | ||
| 111 | @echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT)) | ||
| 112 | @echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT)) | ||
| 113 | @echo INSTALL_TOP_CDIR=$(INSTALL_TOP_CDIR) | ||
| 114 | @echo INSTALL_TOP_LDIR=$(INSTALL_TOP_LDIR) | ||
| 90 | 115 | ||
| 91 | #------ | 116 | #------ |
| 92 | # Supported platforms | 117 | # Supported platforms |
| 93 | # | 118 | # |
| 94 | PLATS= macosx linux win32 | 119 | PLATS= macosx linux win32 mingw |
| 95 | 120 | ||
| 96 | #------ | 121 | #------ |
| 97 | # Compiler and linker settings | 122 | # Compiler and linker settings |
| @@ -117,14 +142,30 @@ CC_linux=gcc | |||
| 117 | DEF_linux=-DLUASOCKET_$(DEBUG) -DLUA_COMPAT_MODULE \ | 142 | DEF_linux=-DLUASOCKET_$(DEBUG) -DLUA_COMPAT_MODULE \ |
| 118 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ | 143 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ |
| 119 | -DMIME_API='__attribute__((visibility("default")))' | 144 | -DMIME_API='__attribute__((visibility("default")))' |
| 120 | CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra -Wimplicit -O2 -ggdb3 -fpic \ | 145 | CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra \ |
| 121 | -fvisibility=hidden | 146 | -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden |
| 122 | LDFLAGS_linux=-O -shared -fpic -o | 147 | LDFLAGS_linux=-O -shared -fpic -o |
| 123 | LD_linux=gcc | 148 | LD_linux=gcc |
| 124 | SOCKET_linux=usocket.o | 149 | SOCKET_linux=usocket.o |
| 125 | 150 | ||
| 126 | #------ | 151 | #------ |
| 127 | # Compiler and linker settings | 152 | # Compiler and linker settings |
| 153 | # for MingW | ||
| 154 | SO_mingw=dll | ||
| 155 | O_mingw=o | ||
| 156 | CC_mingw=gcc | ||
| 157 | DEF_mingw= -DLUASOCKET_$(DEBUG) -DLUA_COMPAT_MODULE -DWINVER=0x0501 \ | ||
| 158 | -DLUASOCKET_API='__declspec(dllexport)' \ | ||
| 159 | -DMIME_API='__declspec(dllexport)' | ||
| 160 | CFLAGS_mingw= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \ | ||
| 161 | -fvisibility=hidden | ||
| 162 | LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lwsock32 -lws2_32 -o | ||
| 163 | LD_mingw=gcc | ||
| 164 | SOCKET_mingw=wsocket.o | ||
| 165 | |||
| 166 | |||
| 167 | #------ | ||
| 168 | # Compiler and linker settings | ||
| 128 | # for Win32 | 169 | # for Win32 |
| 129 | SO_win32=dll | 170 | SO_win32=dll |
| 130 | O_win32=obj | 171 | O_win32=obj |
| @@ -135,12 +176,10 @@ DEF_win32= /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" \ | |||
| 135 | /D "LUASOCKET_$(DEBUG)" | 176 | /D "LUASOCKET_$(DEBUG)" |
| 136 | CFLAGS_win32=/I "$(LUAINC)" $(DEF) /O2 /Ot /MD /W3 /nologo | 177 | CFLAGS_win32=/I "$(LUAINC)" $(DEF) /O2 /Ot /MD /W3 /nologo |
| 137 | LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \ | 178 | LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \ |
| 138 | /LIBPATH:"$(LUALIB)" \ | 179 | /MANIFEST /MANIFESTFILE:"intermediate.manifest" \ |
| 139 | /MANIFEST \ | ||
| 140 | /MANIFESTFILE:"intermediate.manifest" \ | ||
| 141 | /MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ | 180 | /MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ |
| 142 | /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /DYNAMICBASE:NO \ | 181 | /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /DYNAMICBASE:NO \ |
| 143 | /MACHINE:X86 ws2_32.lib lua$(LUAV).lib /OUT: | 182 | /MACHINE:X86 $(LUALIB) ws2_32.lib /OUT: |
| 144 | LD_win32=cl | 183 | LD_win32=cl |
| 145 | SOCKET_win32=wsocket.obj | 184 | SOCKET_win32=wsocket.obj |
| 146 | 185 | ||
| @@ -223,7 +262,7 @@ SERIAL_OBJS:=\ | |||
| 223 | #------ | 262 | #------ |
| 224 | # Files to install | 263 | # Files to install |
| 225 | # | 264 | # |
| 226 | TO_SOCKET_SHARE= \ | 265 | TO_SOCKET_LDIR= \ |
| 227 | http.lua \ | 266 | http.lua \ |
| 228 | url.lua \ | 267 | url.lua \ |
| 229 | tp.lua \ | 268 | tp.lua \ |
| @@ -231,7 +270,7 @@ TO_SOCKET_SHARE= \ | |||
| 231 | headers.lua \ | 270 | headers.lua \ |
| 232 | smtp.lua | 271 | smtp.lua |
| 233 | 272 | ||
| 234 | TO_TOP_SHARE= \ | 273 | TO_TOP_LDIR= \ |
| 235 | ltn12.lua \ | 274 | ltn12.lua \ |
| 236 | socket.lua \ | 275 | socket.lua \ |
| 237 | mime.lua | 276 | mime.lua |
| @@ -250,6 +289,9 @@ win32: | |||
| 250 | linux: | 289 | linux: |
| 251 | $(MAKE) all-unix PLAT=linux | 290 | $(MAKE) all-unix PLAT=linux |
| 252 | 291 | ||
| 292 | mingw: | ||
| 293 | $(MAKE) all PLAT=mingw | ||
| 294 | |||
| 253 | none: | 295 | none: |
| 254 | @echo "Please run" | 296 | @echo "Please run" |
| 255 | @echo " make PLATFORM" | 297 | @echo " make PLATFORM" |
| @@ -273,21 +315,21 @@ $(SERIAL_SO): $(SERIAL_OBJS) | |||
| 273 | $(LD) $(SERIAL_OBJS) $(LDFLAGS)$@ | 315 | $(LD) $(SERIAL_OBJS) $(LDFLAGS)$@ |
| 274 | 316 | ||
| 275 | install: | 317 | install: |
| 276 | $(INSTALL_DIR) $(INSTALL_TOP_SHARE) | 318 | $(INSTALL_DIR) $(INSTALL_TOP_LDIR) |
| 277 | $(INSTALL_DATA) $(TO_TOP_SHARE) $(INSTALL_TOP_SHARE) | 319 | $(INSTALL_DATA) $(TO_TOP_LDIR) $(INSTALL_TOP_LDIR) |
| 278 | $(INSTALL_DIR) $(INSTALL_SOCKET_SHARE) | 320 | $(INSTALL_DIR) $(INSTALL_SOCKET_LDIR) |
| 279 | $(INSTALL_DATA) $(TO_SOCKET_SHARE) $(INSTALL_SOCKET_SHARE) | 321 | $(INSTALL_DATA) $(TO_SOCKET_LDIR) $(INSTALL_SOCKET_LDIR) |
| 280 | $(INSTALL_DIR) $(INSTALL_SOCKET_LIB) | 322 | $(INSTALL_DIR) $(INSTALL_SOCKET_CDIR) |
| 281 | $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_LIB)/core.$(SO) | 323 | $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_CDIR)/core.$(SO) |
| 282 | $(INSTALL_DIR) $(INSTALL_MIME_LIB) | 324 | $(INSTALL_DIR) $(INSTALL_MIME_CDIR) |
| 283 | $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_LIB)/core.$(SO) | 325 | $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_CDIR)/core.$(SO) |
| 284 | 326 | ||
| 285 | install-unix: install | 327 | install-unix: install |
| 286 | $(INSTALL_EXEC) $(UNIX_SO) $(INSTALL_SOCKET_LIB)/$(UNIX_SO) | 328 | $(INSTALL_EXEC) $(UNIX_SO) $(INSTALL_SOCKET_CDIR)/$(UNIX_SO) |
| 287 | $(INSTALL_EXEC) $(SERIAL_SO) $(INSTALL_SOCKET_LIB)/$(SERIAL_SO) | 329 | $(INSTALL_EXEC) $(SERIAL_SO) $(INSTALL_SOCKET_CDIR)/$(SERIAL_SO) |
| 288 | 330 | ||
| 289 | local: | 331 | local: |
| 290 | $(MAKE) install INSTALL_TOP_LIB=.. INSTALL_TOP_SHARE=.. | 332 | $(MAKE) install INSTALL_TOP_CDIR=.. INSTALL_TOP_LDIR=.. |
| 291 | 333 | ||
| 292 | clean: | 334 | clean: |
| 293 | rm -f $(SOCKET_SO) $(SOCKET_OBJS) $(SERIAL_OBJS) | 335 | rm -f $(SOCKET_SO) $(SOCKET_OBJS) $(SERIAL_OBJS) |
