← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcpp-plugin-sdk-cpp/ScriptPlugin] Rev 13: merge

 

Merge authors:
  poy (poy)
------------------------------------------------------------
revno: 13 [merge]
committer: poy <poy@xxxxxxxxxx>
branch nick: ScriptPlugin
timestamp: Fri 2013-04-26 17:15:28 +0200
message:
  merge
modified:
  projects/make/Makefile


--
lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/ScriptPlugin
https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/ScriptPlugin

Your team Dcplusplus-team is subscribed to branch lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/ScriptPlugin.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/ScriptPlugin/+edit-subscription
=== modified file 'projects/make/Makefile'
--- projects/make/Makefile	2013-02-05 19:23:30 +0000
+++ projects/make/Makefile	2013-04-26 15:15:28 +0000
@@ -1,18 +1,20 @@
 # This is a rudimentary Makefile that compiles files from the pluginsdk & src directories into a
 # shared library. Adapt to your needs.
 
-TARGET = ScriptPlugin # Rename to your plugin's name.
+# Rename to your plugin's name.
+TARGET = ScriptPlugin
 
-CPPFLAGS += -march=i686 # Remove if your target architecture is not x86.
+CC = gcc
+CXX = g++
 
 CPPFLAGS += -Wall -Wextra -g -pipe -O3 -I../../
 CXXFLAGS += -std=gnu++0x
-LINKFLAGS += -static-libgcc -static-libstdc++ -g -O3 -shared -Wl,--add-stdcall-alias
+LINKFLAGS += -static-libgcc -g -O3 -shared -Wl,--add-stdcall-alias
+LINKXXFLAGS += -static-libstdc++
 
 VPATH = ../../
 
 OUTPUT_DIR = build
-OUTPUT_OPTION = -o $(OUTPUT_DIR)/$@
 
 OBJS = \
 	pluginsdk/Config.o \
@@ -31,28 +33,40 @@
 	src/ScriptInstance.o \
 	src/stdafx.o
 
-ifeq ($(OS), Windows_NT)
+ifeq ($(findstring mingw, $(shell gcc -dumpmachine)),)
+	LIBEXT = .so
+else
 	CPPFLAGS += -D_WIN32_WINNT=0x502 -DWINVER=0x502 -D_WIN32_IE=0x600 \
 				-DNOMINMAX -DSTRICT -DWIN32_LEAN_AND_MEAN \
 				-DWIN32 -D_WIN32 -DUNICODE -D_UNICODE
+	LIBEXT = .dll
 	OBJS += src/resource.o
-	LIBEXT = .dll
+	OUTPUT_DIR := $(OUTPUT_DIR)-mingw
+endif
+
+ifeq ($(findstring x86_64, $(shell gcc -dumpmachine)),)
+	CPPFLAGS += -march=i686
+	OUTPUT_DIR := $(OUTPUT_DIR)-x86
+else
+	OUTPUT_DIR := $(OUTPUT_DIR)-x64
+endif
+
+ifeq ($(OS), Windows_NT)
 	ifeq ($(findstring Cygwin, $(SHELL)),)
 		MKDIR = if not exist $(subst /,\,$1) md $(subst /,\,$1)
 		RMDIR = if exist $(subst /,\,$1) rd /s /q $(subst /,\,$1)
 	else
 		MKDIR = mkdir -p $1
-		RMDIR += $(RM) -r $1
+		RMDIR = $(RM) -r $1
 	endif
 else
-	LIBEXT = .so
 	MKDIR = mkdir -p $1
-	RMDIR += $(RM) -r $1
+	RMDIR = $(RM) -r $1
 endif
 
 # boost
 CPPFLAGS += -I../../boost
-ifeq ($(OS), Windows_NT)
+ifneq ($(findstring mingw, $(shell gcc -dumpmachine)),)
 	CPPFLAGS += -DBOOST_ALL_NO_LIB -DBOOST_USE_WINDOWS_H
 endif
 OBJS += \
@@ -68,7 +82,7 @@
 
 # lua
 CPPFLAGS += -I../../lua
-ifneq ($(OS), Windows_NT)
+ifeq ($(findstring mingw, $(shell gcc -dumpmachine)),)
 	CPPFLAGS += -DLUA_USE_LINUX=1
 	LINKFLAGS += -lm -ldl
 endif
@@ -78,22 +92,31 @@
 	lua/lopcodes.o lua/loslib.o lua/lparser.o lua/lstate.o lua/lstring.o lua/lstrlib.o \
 	lua/ltable.o lua/ltablib.o lua/ltm.o lua/lundump.o lua/lvm.o lua/lzio.o
 
-all: \
-	ensure-dirs \
-	$(TARGET)
+TARGET := $(OUTPUT_DIR)/$(TARGET)$(LIBEXT)
+OBJS := $(addprefix $(OUTPUT_DIR)/, $(OBJS))
+
+all: $(TARGET)
 
 $(TARGET): $(OBJS)
-	cd $(OUTPUT_DIR) && $(CXX) $^ $(LINKFLAGS) -o $@$(LIBEXT)
-
-ensure-dirs:
+	$(CXX) $^ $(LINKFLAGS) $(LINKXXFLAGS) $(OUTPUT_OPTION)
+
+$(OUTPUT_DIR)/%.o: %.c
+	$(COMPILE.c) $< $(OUTPUT_OPTION)
+
+$(OUTPUT_DIR)/%.o: %.cpp
+	$(COMPILE.cpp) $< $(OUTPUT_OPTION)
+
+$(OUTPUT_DIR)/%.o: %.rc
+	windres $< $(OUTPUT_OPTION)
+
+$(OBJS): | $(OUTPUT_DIR)
+
+$(OUTPUT_DIR):
 	$(call MKDIR,$(OUTPUT_DIR)/pluginsdk)
 	$(call MKDIR,$(OUTPUT_DIR)/src)
 	$(call MKDIR,$(OUTPUT_DIR)/boost/libs/filesystem/src)
 	$(call MKDIR,$(OUTPUT_DIR)/boost/libs/system/src)
 	$(call MKDIR,$(OUTPUT_DIR)/lua)
 
-src/resource.o:
-	windres ../../src/resource.rc $(OUTPUT_OPTION)
-
-clear:
+clean:
 	$(call RMDIR,$(OUTPUT_DIR))