Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
build: fix make test on darwin and sunos
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Nov 10, 2012
1 parent f352e40 commit 62332ea
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
8 changes: 5 additions & 3 deletions .gitignore
@@ -1,14 +1,16 @@
*.swp
*.[oa]
*.so
*.lo
*.la
*.l[oa]
*.opensdf
*.orig
*.sdf
*.suo
core
vgcore.*

/libuv.so
/libuv.dylib

/out/
/build/gyp

Expand Down
10 changes: 8 additions & 2 deletions Makefile
Expand Up @@ -26,6 +26,12 @@ endif

CPPFLAGS += -Iinclude -Iinclude/uv-private

ifeq (Darwin,$(uname_S))
SOEXT = dylib
else
SOEXT = so
endif

ifneq (,$(findstring MINGW,$(uname_S)))
include config-mingw.mk
else
Expand All @@ -37,10 +43,10 @@ BENCHMARKS=test/blackhole-server.c test/echo-server.c test/dns-server.c test/ben

all: libuv.a

test/run-tests$(E): test/run-tests.c test/runner.c $(RUNNER_SRC) $(TESTS) libuv.so
test/run-tests$(E): test/run-tests.c test/runner.c $(RUNNER_SRC) $(TESTS) libuv.$(SOEXT)
$(CC) $(CPPFLAGS) $(RUNNER_CFLAGS) -o $@ $^ $(RUNNER_LIBS) $(RUNNER_LINKFLAGS)

test/run-benchmarks$(E): test/run-benchmarks.c test/runner.c $(RUNNER_SRC) $(BENCHMARKS) libuv.so
test/run-benchmarks$(E): test/run-benchmarks.c test/runner.c $(RUNNER_SRC) $(BENCHMARKS) libuv.$(SOEXT)
$(CC) $(CPPFLAGS) $(RUNNER_CFLAGS) -o $@ $^ $(RUNNER_LIBS) $(RUNNER_LINKFLAGS)

test/echo.o: test/echo.c test/echo.h
Expand Down
23 changes: 12 additions & 11 deletions config-unix.mk
Expand Up @@ -27,6 +27,10 @@ LINKFLAGS=-lm
CPPFLAGS += -D_LARGEFILE_SOURCE
CPPFLAGS += -D_FILE_OFFSET_BITS=64

RUNNER_SRC=test/runner-unix.c
RUNNER_CFLAGS=$(CFLAGS) -Itest
RUNNER_LINKFLAGS=-L"$(PWD)" -luv -Xlinker -rpath -Xlinker "$(PWD)"

OBJS += src/unix/async.o
OBJS += src/unix/core.o
OBJS += src/unix/dl.o
Expand Down Expand Up @@ -55,6 +59,8 @@ ifeq (SunOS,$(uname_S))
EV_CONFIG=config_sunos.h
CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
LINKFLAGS+=-lkstat -lnsl -lsendfile -lsocket
# Library dependencies are not transitive.
RUNNER_LINKFLAGS += $(LINKFLAGS)
OBJS += src/unix/sunos.o
endif

Expand All @@ -68,7 +74,8 @@ endif
ifeq (Darwin,$(uname_S))
EV_CONFIG=config_darwin.h
CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
LINKFLAGS+=-framework CoreServices
LINKFLAGS+=-framework CoreServices -dynamiclib -install_name "@rpath/libuv.dylib"
SOEXT = dylib
OBJS += src/unix/darwin.o
OBJS += src/unix/kqueue.o
OBJS += src/unix/fsevents.o
Expand All @@ -78,6 +85,7 @@ ifeq (Linux,$(uname_S))
EV_CONFIG=config_linux.h
CSTDFLAG += -D_GNU_SOURCE
LINKFLAGS+=-ldl -lrt
RUNNER_CFLAGS += -D_GNU_SOURCE
OBJS += src/unix/linux/linux-core.o \
src/unix/linux/inotify.o \
src/unix/linux/syscalls.o
Expand Down Expand Up @@ -119,25 +127,18 @@ LINKFLAGS+=
OBJS += src/unix/cygwin.o
endif

# Need _GNU_SOURCE for strdup?
RUNNER_CFLAGS=$(CFLAGS) -D_GNU_SOURCE -Itest
RUNNER_LINKFLAGS=$(LINKFLAGS) -Wl,-rpath="$(PWD)" -L"$(PWD)" -luv

ifeq (SunOS,$(uname_S))
RUNNER_LINKFLAGS += -pthreads
else
RUNNER_LINKFLAGS += -pthread
endif

RUNNER_LIBS=
RUNNER_SRC=test/runner-unix.c

libuv.a: $(OBJS)
$(AR) rcs $@ $^

libuv.so: CFLAGS += -fPIC
libuv.so: $(OBJS)
$(CC) -shared -o $@ $^
libuv.$(SOEXT): CFLAGS += -fPIC
libuv.$(SOEXT): $(OBJS)
$(CC) -shared -o $@ $^ $(LINKFLAGS)

src/%.o: src/%.c include/uv.h include/uv-private/uv-unix.h
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
Expand Down

0 comments on commit 62332ea

Please sign in to comment.