From 01fe4e73a695587d7aacbb1a6b998807b7917f64 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 29 Jan 2013 14:39:41 +0100 Subject: [PATCH] build: add OS= make switch Overrides the platform detection heuristic. Useful for cross-compiling. --- Makefile | 10 +++------- README.md | 6 +++++- config-unix.mk | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index ef2b3525836..a0958fed5dd 100644 --- a/Makefile +++ b/Makefile @@ -18,21 +18,17 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') - -ifdef MSVC -uname_S := MINGW -endif +OS ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"') CPPFLAGS += -Iinclude -Iinclude/uv-private -ifeq (Darwin,$(uname_S)) +ifeq (darwin,$(OS)) SOEXT = dylib else SOEXT = so endif -ifneq (,$(findstring MINGW,$(uname_S))) +ifneq (,$(findstring mingw,$(OS))) include config-mingw.mk else include config-unix.mk diff --git a/README.md b/README.md index b4cb4849fd8..351be597db9 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,11 @@ To build via Makefile simply execute: make -To build with Visual Studio run the vcbuilds.bat file which will +MinGW users should run this instead: + + make OS=mingw + +To build with Visual Studio run the vcbuild.bat file which will checkout the GYP code into build/gyp and generate the uv.sln and related files. diff --git a/config-unix.mk b/config-unix.mk index 66c74ee19fe..1468f21e68d 100644 --- a/config-unix.mk +++ b/config-unix.mk @@ -54,7 +54,7 @@ OBJS += src/fs-poll.o OBJS += src/uv-common.o OBJS += src/inet.o -ifeq (SunOS,$(uname_S)) +ifeq (sunos,$(OS)) CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 LDFLAGS+=-lkstat -lnsl -lsendfile -lsocket # Library dependencies are not transitive. @@ -62,13 +62,13 @@ RUNNER_LDFLAGS += $(LDFLAGS) OBJS += src/unix/sunos.o endif -ifeq (AIX,$(uname_S)) +ifeq (aix,$(OS)) CPPFLAGS += -Isrc/ares/config_aix -D_ALL_SOURCE -D_XOPEN_SOURCE=500 LDFLAGS+= -lperfstat OBJS += src/unix/aix.o endif -ifeq (Darwin,$(uname_S)) +ifeq (darwin,$(OS)) CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 LDFLAGS+=-framework CoreServices -dynamiclib -install_name "@rpath/libuv.dylib" SOEXT = dylib @@ -77,7 +77,7 @@ OBJS += src/unix/kqueue.o OBJS += src/unix/fsevents.o endif -ifeq (Linux,$(uname_S)) +ifeq (linux,$(OS)) CSTDFLAG += -D_GNU_SOURCE LDFLAGS+=-ldl -lrt RUNNER_CFLAGS += -D_GNU_SOURCE @@ -86,38 +86,38 @@ OBJS += src/unix/linux/linux-core.o \ src/unix/linux/syscalls.o endif -ifeq (FreeBSD,$(uname_S)) +ifeq (freebsd,$(OS)) LDFLAGS+=-lkvm OBJS += src/unix/freebsd.o OBJS += src/unix/kqueue.o endif -ifeq (DragonFly,$(uname_S)) +ifeq (dragonfly,$(OS)) LDFLAGS+=-lkvm OBJS += src/unix/freebsd.o OBJS += src/unix/kqueue.o endif -ifeq (NetBSD,$(uname_S)) +ifeq (netbsd,$(OS)) LDFLAGS+=-lkvm OBJS += src/unix/netbsd.o OBJS += src/unix/kqueue.o endif -ifeq (OpenBSD,$(uname_S)) +ifeq (openbsd,$(OS)) LDFLAGS+=-lkvm OBJS += src/unix/openbsd.o OBJS += src/unix/kqueue.o endif -ifneq (,$(findstring CYGWIN,$(uname_S))) +ifneq (,$(findstring cygwin,$(OS))) # We drop the --std=c89, it hides CLOCK_MONOTONIC on cygwin CSTDFLAG = -D_GNU_SOURCE LDFLAGS+= OBJS += src/unix/cygwin.o endif -ifeq (SunOS,$(uname_S)) +ifeq (sunos,$(OS)) RUNNER_LDFLAGS += -pthreads else RUNNER_LDFLAGS += -pthread