Skip to content

Commit

Permalink
build: add OS= make switch
Browse files Browse the repository at this point in the history
Overrides the platform detection heuristic. Useful for cross-compiling.
  • Loading branch information
bnoordhuis committed Jan 29, 2013
1 parent 93f61b7 commit 01fe4e7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
10 changes: 3 additions & 7 deletions Makefile
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -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.

Expand Down
20 changes: 10 additions & 10 deletions config-unix.mk
Expand Up @@ -54,21 +54,21 @@ 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.
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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 01fe4e7

Please sign in to comment.