From bb0b31301a43e740f30cf438f9f2b3e68fbd7698 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 25 May 2013 18:07:38 +0800 Subject: Add MingW support. --- src/makefile | 114 ++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 36 deletions(-) (limited to 'src/makefile') diff --git a/src/makefile b/src/makefile index a75d5a6..a6e0033 100644 --- a/src/makefile +++ b/src/makefile @@ -12,7 +12,7 @@ # # make PLAT=linux DEBUG=DEBUG LUAV=5.2 prefix=/sw -# PLAT: linux macosx win32 +# PLAT: linux macosx win32 mingw # platform to build for PLAT?=linux @@ -33,6 +33,9 @@ LUAINC_macosx?=$(LUAINC_macosx_base)/lua$(LUAV) # FIXME default should this default to fink or to macports? # What happens when more than one Lua version is installed? LUAPREFIX_macosx?=/opt/local +CDIR_macosx?=lib/lua/$(LUAV) +LDIR_macosx?=share/lua/$(LUAV) + # LUAINC_linux: # /usr/include/lua$(LUAV) @@ -42,19 +45,38 @@ LUAPREFIX_macosx?=/opt/local LUAINC_linux_base?=/usr/include LUAINC_linux?=$(LUAINC_linux_base)/lua$(LUAV) LUAPREFIX_linux?=/usr/local +CDIR_linux?=lib/lua/$(LUAV) +LDIR_linux?=share/lua/$(LUAV) + +# where lua headers are found for mingw builds +# LUAINC_mingw: +# /opt/local/include +LUAINC_mingw_base?=/usr/include +LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUAV) +LUALIB_mingw_base?=/usr/bin +LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUAV)/lua$(subst .,,$(LUAV)).dll +LUAPREFIX_mingw?=/usr +CDIR_mingw?=lua/$(LUAV) +LDIR_mingw?=lua/$(LUAV)/lua + # LUAINC_win32: # LUALIB_win32: # where lua headers and libraries are found for win32 builds LUAINC_win32?="../../lua-5.1.3/src" -LUALIB_win32?="../../lua-5.1.3" +LUALIB_win32?=/LIBPATH:"../../lua-5.1.3" lua$(LUAV).lib + LUAPREFIX_win32?= -# FIXME default should be where lua-for-windows puts lua +CDIR_win32?=lua/$(LUAV) +LDIR_win32?=lua/$(LUAV)/lua # prefix: /usr/local /usr /opt/local /sw # the top of the default install tree prefix?=$(LUAPREFIX_$(PLAT)) +CDIR?=$(CDIR_$(PLAT)) +LDIR?=$(LDIR_$(PLAT)) + # DESTDIR: (no default) # used by package managers to install into a temporary destination DESTDIR= @@ -63,13 +85,6 @@ DESTDIR= # Definitions below can be overridden on the make command line, but # shouldn't have to be. -print: - @echo PLAT=$(PLAT) - @echo LUAV=$(LUAV) - @echo DEBUG=$(DEBUG) - @echo prefix=$(prefix) - @echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT)) - @echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT)) #------ # Install directories @@ -80,18 +95,28 @@ INSTALL_DATA=install -m644 INSTALL_EXEC=install INSTALL_TOP=$(DESTDIR)$(prefix) -INSTALL_TOP_SHARE=$(INSTALL_TOP)/share/lua/$(LUAV) -INSTALL_TOP_LIB=$(INSTALL_TOP)/lib/lua/$(LUAV) +INSTALL_TOP_LDIR=$(INSTALL_TOP)/$(LDIR) +INSTALL_TOP_CDIR=$(INSTALL_TOP)/$(CDIR) + +INSTALL_SOCKET_LDIR=$(INSTALL_TOP_LDIR)/socket +INSTALL_SOCKET_CDIR=$(INSTALL_TOP_CDIR)/socket +INSTALL_MIME_LDIR=$(INSTALL_TOP_LDIR)/mime +INSTALL_MIME_CDIR=$(INSTALL_TOP_CDIR)/mime -INSTALL_SOCKET_SHARE=$(INSTALL_TOP_SHARE)/socket -INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket -INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime -INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime +print: + @echo PLAT=$(PLAT) + @echo LUAV=$(LUAV) + @echo DEBUG=$(DEBUG) + @echo prefix=$(prefix) + @echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT)) + @echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT)) + @echo INSTALL_TOP_CDIR=$(INSTALL_TOP_CDIR) + @echo INSTALL_TOP_LDIR=$(INSTALL_TOP_LDIR) #------ # Supported platforms # -PLATS= macosx linux win32 +PLATS= macosx linux win32 mingw #------ # Compiler and linker settings @@ -117,12 +142,28 @@ CC_linux=gcc DEF_linux=-DLUASOCKET_$(DEBUG) -DLUA_COMPAT_MODULE \ -DLUASOCKET_API='__attribute__((visibility("default")))' \ -DMIME_API='__attribute__((visibility("default")))' -CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra -Wimplicit -O2 -ggdb3 -fpic \ - -fvisibility=hidden +CFLAGS_linux= -I$(LUAINC) $(DEF) -pedantic -Wall -Wshadow -Wextra \ + -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden LDFLAGS_linux=-O -shared -fpic -o LD_linux=gcc SOCKET_linux=usocket.o +#------ +# Compiler and linker settings +# for MingW +SO_mingw=dll +O_mingw=o +CC_mingw=gcc +DEF_mingw= -DLUASOCKET_$(DEBUG) -DLUA_COMPAT_MODULE -DWINVER=0x0501 \ + -DLUASOCKET_API='__declspec(dllexport)' \ + -DMIME_API='__declspec(dllexport)' +CFLAGS_mingw= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \ + -fvisibility=hidden +LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lwsock32 -lws2_32 -o +LD_mingw=gcc +SOCKET_mingw=wsocket.o + + #------ # Compiler and linker settings # for Win32 @@ -135,12 +176,10 @@ DEF_win32= /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" \ /D "LUASOCKET_$(DEBUG)" CFLAGS_win32=/I "$(LUAINC)" $(DEF) /O2 /Ot /MD /W3 /nologo LDFLAGS_win32= /nologo /link /NOLOGO /DLL /INCREMENTAL:NO \ - /LIBPATH:"$(LUALIB)" \ - /MANIFEST \ - /MANIFESTFILE:"intermediate.manifest" \ + /MANIFEST /MANIFESTFILE:"intermediate.manifest" \ /MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /DYNAMICBASE:NO \ - /MACHINE:X86 ws2_32.lib lua$(LUAV).lib /OUT: + /MACHINE:X86 $(LUALIB) ws2_32.lib /OUT: LD_win32=cl SOCKET_win32=wsocket.obj @@ -223,7 +262,7 @@ SERIAL_OBJS:=\ #------ # Files to install # -TO_SOCKET_SHARE= \ +TO_SOCKET_LDIR= \ http.lua \ url.lua \ tp.lua \ @@ -231,7 +270,7 @@ TO_SOCKET_SHARE= \ headers.lua \ smtp.lua -TO_TOP_SHARE= \ +TO_TOP_LDIR= \ ltn12.lua \ socket.lua \ mime.lua @@ -250,6 +289,9 @@ win32: linux: $(MAKE) all-unix PLAT=linux +mingw: + $(MAKE) all PLAT=mingw + none: @echo "Please run" @echo " make PLATFORM" @@ -273,21 +315,21 @@ $(SERIAL_SO): $(SERIAL_OBJS) $(LD) $(SERIAL_OBJS) $(LDFLAGS)$@ install: - $(INSTALL_DIR) $(INSTALL_TOP_SHARE) - $(INSTALL_DATA) $(TO_TOP_SHARE) $(INSTALL_TOP_SHARE) - $(INSTALL_DIR) $(INSTALL_SOCKET_SHARE) - $(INSTALL_DATA) $(TO_SOCKET_SHARE) $(INSTALL_SOCKET_SHARE) - $(INSTALL_DIR) $(INSTALL_SOCKET_LIB) - $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_LIB)/core.$(SO) - $(INSTALL_DIR) $(INSTALL_MIME_LIB) - $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_LIB)/core.$(SO) + $(INSTALL_DIR) $(INSTALL_TOP_LDIR) + $(INSTALL_DATA) $(TO_TOP_LDIR) $(INSTALL_TOP_LDIR) + $(INSTALL_DIR) $(INSTALL_SOCKET_LDIR) + $(INSTALL_DATA) $(TO_SOCKET_LDIR) $(INSTALL_SOCKET_LDIR) + $(INSTALL_DIR) $(INSTALL_SOCKET_CDIR) + $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_CDIR)/core.$(SO) + $(INSTALL_DIR) $(INSTALL_MIME_CDIR) + $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_CDIR)/core.$(SO) install-unix: install - $(INSTALL_EXEC) $(UNIX_SO) $(INSTALL_SOCKET_LIB)/$(UNIX_SO) - $(INSTALL_EXEC) $(SERIAL_SO) $(INSTALL_SOCKET_LIB)/$(SERIAL_SO) + $(INSTALL_EXEC) $(UNIX_SO) $(INSTALL_SOCKET_CDIR)/$(UNIX_SO) + $(INSTALL_EXEC) $(SERIAL_SO) $(INSTALL_SOCKET_CDIR)/$(SERIAL_SO) local: - $(MAKE) install INSTALL_TOP_LIB=.. INSTALL_TOP_SHARE=.. + $(MAKE) install INSTALL_TOP_CDIR=.. INSTALL_TOP_LDIR=.. clean: rm -f $(SOCKET_SO) $(SOCKET_OBJS) $(SERIAL_OBJS) -- cgit v1.2.3-55-g6feb