From 53bedd1eb5120f1f2ca8e1492f2c53400b0c2918 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Fri, 16 Aug 2013 11:17:15 +0100 Subject: [PATCH] made separate targets for each example --- examples/Makefile | 66 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 16294c5a..bcbac0c6 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,28 +1,56 @@ -CFLAGS= -W -Wall -I.. -pthread -g +CFLAGS = -W -Wall -I.. -pthread -g -pipe $(COPT) +DLL_FLAGS = -DLUA_COMPAT_ALL -I../lua-5.2.1/src -all: - OS=`uname`; \ - test "$$OS" = Linux && LIBS="-ldl" ; \ - $(CC) $(CFLAGS) hello.c ../mongoose.c $$LIBS $(ADD) -o hello; - $(CC) $(CFLAGS) upload.c ../mongoose.c $$LIBS $(ADD) -o upload; - $(CC) $(CFLAGS) post.c ../mongoose.c $$LIBS $(ADD) -o post; - $(CC) $(CFLAGS) -DUSE_WEBSOCKET websocket.c ../mongoose.c $$LIBS $(ADD) -o websocket; - $(CC) $(CFLAGS) chat.c ../mongoose.c $$LIBS $(ADD) -o chat +ifeq ($(OS),Windows_NT) +else + UNAME_S := $(shell uname -s) + DLL_FLAGS += -shared + + ifeq ($(UNAME_S),Linux) + CFLAGS += -ldl + endif + + ifeq ($(UNAME_S),Darwin) + # DLL_FLAGS += -bundle -undefined dynamic_lookup -dynamiclib + DLL_FLAGS += -flat_namespace -undefined suppress -dynamiclib + endif +endif + +all: hello upload post websocket chat lua_dll + +hello: + $(CC) $(CFLAGS) hello.c ../mongoose.c -o $@ + +upload: + $(CC) $(CFLAGS) upload.c ../mongoose.c -o $@ + +post: + $(CC) $(CFLAGS) post.c ../mongoose.c -o $@ + +websocket: + $(CC) $(CFLAGS) -DUSE_WEBSOCKET websocket.c ../mongoose.c -o $@ + +chat: + $(CC) $(CFLAGS) chat.c ../mongoose.c -o $@ + +lua_dll: + $(CC) $(CFLAGS) $(DLL_FLAGS) lua_dll.c -o $@.so -MSVC = e:/vc6 +MSVC = ../../vc6 CL = $(MSVC)/bin/cl CLFLAGS = /MD /TC /nologo $(DBG) /W3 /DNO_SSL \ - /I$(MSVC)/include /I.. /Dsnprintf=_snprintf \ - /link /incremental:no /libpath:$(MSVC)/lib /machine:IX86 + /I$(MSVC)/include /I.. /Dsnprintf=_snprintf +LFLAGS = /link /incremental:no /libpath:$(MSVC)/lib /machine:IX86 windows: - $(CL) upload.c ../mongoose.c $(CLFLAGS) - $(CL) hello.c ../mongoose.c $(CLFLAGS) - $(CL) upload.c ../mongoose.c $(CLFLAGS) - $(CL) post.c ../mongoose.c $(CLFLAGS) - $(CL) post.c ../mongoose.c $(CLFLAGS) - $(CL) /DUSE_WEBSOCKET websocket.c ../mongoose.c $(CLFLAGS) + $(CL) upload.c ../mongoose.c $(CLFLAGS) $(LFLAGS) + $(CL) hello.c ../mongoose.c $(CLFLAGS) $(LFLAGS) + $(CL) upload.c ../mongoose.c $(CLFLAGS) $(LFLAGS) + $(CL) post.c ../mongoose.c $(CLFLAGS) $(LFLAGS) + $(CL) post.c ../mongoose.c $(CLFLAGS) $(LFLAGS) + $(CL) /DUSE_WEBSOCKET websocket.c ../mongoose.c $(CLFLAGS) $(LFLAGS) +#$(CL) lua_dll.c $(CLFLAGS) $(DLL_FLAGS) /DLL $(LFLAGS) /SUBSYSTEM:WINDOWS /ENTRY:luaopen_lua_dll /EXPORT:luaopen_lua_dll /out:lua_dll.dll clean: - rm -rf hello upload post websocket chat *.exe *.dSYM *.obj + rm -rf hello upload post websocket chat *.exe *.dSYM *.obj .*o