From bce60be30fe8e9c1b0eb33128c23c93d7bca5303 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Wed, 27 May 2009 09:31:38 +0000 Subject: Decent makefiles! --- src/makefile | 156 ++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 122 insertions(+), 34 deletions(-) (limited to 'src/makefile') diff --git a/src/makefile b/src/makefile index b614f77..3351997 100644 --- a/src/makefile +++ b/src/makefile @@ -1,39 +1,86 @@ +PLAT = none +INSTALL_DATA=cp +INSTALL_EXEC=cp +INSTALL_TOP= /opt/local +LUAINC= $(LUAINC_$(PLAT)) + #------ -# Load configuration +# Install directories # -include ../config +INSTALL_TOP_SHARE=$(INSTALL_TOP)/share/lua/5.1 +INSTALL_TOP_LIB=$(INSTALL_TOP)/lib/lua/5.1 +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 #------ -# Hopefully no need to change anything below this line +# Output file names # +EXT=so +SOCKET_V=2.0.3 +MIME_V=1.0.3 +SOCKET_SO=socket.$(EXT).$(SOCKET_V) +MIME_SO=mime.$(EXT).$(MIME_V) +UNIX_SO=unix.$(EXT) #------ -# Modules belonging to socket-core -# +# Compiler and linker settings +# for Mac OS X +LUAINC_macosx= -I/opt/local/include +CC_macosx=gcc +DEF_macosx= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN \ + -DLUASOCKET_API='__attribute__((visibility("default")))' \ + -DMIME_API='__attribute__((visibility("default")))' +CFLAGS_macosx= $(LUAINC) $(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common \ + -fvisibility=hidden +LDFLAGS_macosx= -bundle -undefined dynamic_lookup +LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc -#$(COMPAT)/compat-5.1.o \ +#------ +# Compiler and linker settings +# for Linux +LUAINC_linux= -I/usr/local/include/lua5.1 +CC_linux=gcc +DEF_linux=-DLUASOCKET_DEBUG \ + -DLUASOCKET_API='__attribute__((visibility("default")))' \ + -DMIME_API='__attribute__((visibility("default")))' +CFLAGS_linux= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic \ + -fvisibility=hidden +LDFLAGS_linux=-O -shared -fpic +LD_linux= gcc -SOCKET_OBJS:= \ +#------ +# Settings selected for platform +# +CC=$(CC_$(PLAT)) +DEF=$(DEF_$(PLAT)) +CFLAGS=$(CFLAGS_$(PLAT)) +LDFLAGS=$(LDFLAGS_$(PLAT)) +LD=$(LD_$(PLAT)) + +#------ +# Modules belonging to socket-core +# +SOCKET_OBJS= \ luasocket.o \ timeout.o \ buffer.o \ io.o \ - auxiliar.o \ + auxiliar.o \ options.o \ inet.o \ - tcp.o \ - udp.o \ + usocket.o \ except.o \ select.o \ - usocket.o + tcp.o \ + udp.o #------ # Modules belonging mime-core # -#$(COMPAT)/compat-5.1.o \ - -MIME_OBJS:=\ - mime.o +MIME_OBJS= \ + mime.o #------ # Modules belonging unix (local domain sockets) @@ -47,7 +94,35 @@ UNIX_OBJS:=\ usocket.o \ unix.o -all: $(SOCKET_SO) $(MIME_SO) +#------ +# Files to install +# +TO_SOCKET_SHARE:= \ + http.lua \ + url.lua \ + tp.lua \ + ftp.lua \ + headers.lua \ + smtp.lua + +TO_TOP_SHARE:= \ + ltn12.lua \ + socket.lua \ + mime.lua + +default: $(PLAT) + +macosx: + $(MAKE) all PLAT=macosx + +linux: + $(MAKE) all PLAT=linux + +none: + @echo "Please choose a platform:" + @echo " $(PLATS)" + +all: $(SOCKET_SO) $(MIME_SO) $(SOCKET_SO): $(SOCKET_OBJS) $(LD) $(LDFLAGS) -o $@ $(SOCKET_OBJS) @@ -58,6 +133,25 @@ $(MIME_SO): $(MIME_OBJS) $(UNIX_SO): $(UNIX_OBJS) $(LD) $(LDFLAGS) -o $@ $(UNIX_OBJS) +install: + mkdir -p $(INSTALL_TOP_SHARE) + $(INSTALL_DATA) $(TO_TOP_SHARE) $(INSTALL_TOP_SHARE) + mkdir -p $(INSTALL_SOCKET_SHARE) + $(INSTALL_DATA) $(TO_SOCKET_SHARE) $(INSTALL_SOCKET_SHARE) + mkdir -p $(INSTALL_SOCKET_LIB) + $(INSTALL_EXEC) $(SOCKET_SO) $(INSTALL_SOCKET_LIB)/core.$(EXT) + mkdir -p $(INSTALL_MIME_LIB) + $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_LIB)/core.$(EXT) + +local: + $(MAKE) install INSTALL_TOP_LIB=.. INSTALL_TOP_SHARE=.. + +clean: + rm -f $(SOCKET_SO) $(SOCKET_OBJS) + rm -f $(MIME_SO) $(UNIX_SO) $(MIME_OBJS) $(UNIX_OBJS) + +.PHONY: all $(PLATS) default clean echo none + #------ # List of dependencies # @@ -66,25 +160,19 @@ buffer.o: buffer.c buffer.h io.h timeout.h except.o: except.c except.h inet.o: inet.c inet.h socket.h io.h timeout.h usocket.h io.o: io.c io.h timeout.h -luasocket.o: luasocket.c luasocket.h auxiliar.h except.h timeout.h \ - buffer.h io.h inet.h socket.h usocket.h tcp.h udp.h select.h +luasocket.o: luasocket.c luasocket.h auxiliar.h except.h \ + timeout.h buffer.h io.h inet.h socket.h usocket.h tcp.h \ + udp.h select.h mime.o: mime.c mime.h -options.o: options.c auxiliar.h options.h socket.h io.h timeout.h \ - usocket.h inet.h +options.o: options.c auxiliar.h options.h socket.h io.h \ + timeout.h usocket.h inet.h select.o: select.c socket.h io.h timeout.h usocket.h select.h -tcp.o: tcp.c auxiliar.h socket.h io.h timeout.h usocket.h inet.h \ - options.h tcp.h buffer.h +tcp.o: tcp.c auxiliar.h socket.h io.h timeout.h usocket.h \ + inet.h options.h tcp.h buffer.h timeout.o: timeout.c auxiliar.h timeout.h -udp.o: udp.c auxiliar.h socket.h io.h timeout.h usocket.h inet.h \ - options.h udp.h -unix.o: unix.c auxiliar.h socket.h io.h timeout.h usocket.h options.h \ - unix.h buffer.h +udp.o: udp.c auxiliar.h socket.h io.h timeout.h usocket.h \ + inet.h options.h udp.h +unix.o: unix.c auxiliar.h socket.h io.h timeout.h usocket.h \ + options.h unix.h buffer.h usocket.o: usocket.c socket.h io.h timeout.h usocket.h - -clean: - rm -f $(SOCKET_SO) $(SOCKET_OBJS) - rm -f $(MIME_SO) $(UNIX_SO) $(MIME_OBJS) $(UNIX_OBJS) - -#------ -# End of makefile configuration -# +wsocket.o: wsocket.c socket.h io.h timeout.h usocket.h -- cgit v1.2.3-55-g6feb