]> git.proxmox.com Git - rustc.git/blob - src/libuv/config-unix.mk
Imported Upstream version 0.7
[rustc.git] / src / libuv / config-unix.mk
1 # Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 # IN THE SOFTWARE.
20
21 E=
22 CSTDFLAG=--std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter
23 CFLAGS += -g
24 CPPFLAGS += -I$(SRCDIR)/src
25 LDFLAGS=-lm
26
27 CPPFLAGS += -D_LARGEFILE_SOURCE
28 CPPFLAGS += -D_FILE_OFFSET_BITS=64
29
30 RUNNER_SRC=test/runner-unix.c
31 RUNNER_CFLAGS=$(CFLAGS) -I$(SRCDIR)/test
32 RUNNER_LDFLAGS=-L"$(CURDIR)" -luv -Xlinker -rpath -Xlinker "$(CURDIR)"
33
34 OBJS += src/unix/async.o
35 OBJS += src/unix/core.o
36 OBJS += src/unix/dl.o
37 OBJS += src/unix/error.o
38 OBJS += src/unix/fs.o
39 OBJS += src/unix/getaddrinfo.o
40 OBJS += src/unix/loop.o
41 OBJS += src/unix/loop-watcher.o
42 OBJS += src/unix/pipe.o
43 OBJS += src/unix/poll.o
44 OBJS += src/unix/process.o
45 OBJS += src/unix/signal.o
46 OBJS += src/unix/stream.o
47 OBJS += src/unix/tcp.o
48 OBJS += src/unix/thread.o
49 OBJS += src/unix/threadpool.o
50 OBJS += src/unix/timer.o
51 OBJS += src/unix/tty.o
52 OBJS += src/unix/udp.o
53 OBJS += src/fs-poll.o
54 OBJS += src/uv-common.o
55 OBJS += src/inet.o
56
57 ifeq (sunos,$(OS))
58 CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
59 LDFLAGS+=-lkstat -lnsl -lsendfile -lsocket
60 # Library dependencies are not transitive.
61 RUNNER_LDFLAGS += $(LDFLAGS)
62 OBJS += src/unix/sunos.o
63 endif
64
65 ifeq (aix,$(OS))
66 CPPFLAGS += -D_ALL_SOURCE -D_XOPEN_SOURCE=500
67 LDFLAGS+= -lperfstat
68 OBJS += src/unix/aix.o
69 endif
70
71 ifeq (darwin,$(OS))
72 CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
73 LDFLAGS+=-framework CoreServices -dynamiclib -install_name "@rpath/libuv.dylib"
74 SOEXT = dylib
75 OBJS += src/unix/darwin.o
76 OBJS += src/unix/kqueue.o
77 OBJS += src/unix/fsevents.o
78 endif
79
80 ifeq (linux,$(OS))
81 CSTDFLAG += -D_GNU_SOURCE
82 ifeq (android,$(host))
83 LDFLAGS+=-ldl
84 OBJS += src/unix/android.o
85 else
86 LDFLAGS+=-ldl -lrt
87 endif
88 RUNNER_CFLAGS += -D_GNU_SOURCE
89 OBJS += src/unix/linux-core.o \
90 src/unix/linux-inotify.o \
91 src/unix/linux-syscalls.o
92 endif
93
94 ifeq (freebsd,$(OS))
95 LDFLAGS+=-lkvm
96 OBJS += src/unix/freebsd.o
97 OBJS += src/unix/kqueue.o
98 endif
99
100 ifeq (dragonfly,$(OS))
101 LDFLAGS+=-lkvm
102 OBJS += src/unix/freebsd.o
103 OBJS += src/unix/kqueue.o
104 endif
105
106 ifeq (netbsd,$(OS))
107 LDFLAGS+=-lkvm
108 OBJS += src/unix/netbsd.o
109 OBJS += src/unix/kqueue.o
110 endif
111
112 ifeq (openbsd,$(OS))
113 LDFLAGS+=-lkvm
114 OBJS += src/unix/openbsd.o
115 OBJS += src/unix/kqueue.o
116 endif
117
118 ifneq (,$(findstring cygwin,$(OS)))
119 # We drop the --std=c89, it hides CLOCK_MONOTONIC on cygwin
120 CSTDFLAG = -D_GNU_SOURCE
121 LDFLAGS+=
122 OBJS += src/unix/cygwin.o
123 endif
124
125 ifneq (android,$(host))
126 ifeq (sunos,$(OS))
127 RUNNER_LDFLAGS += -pthreads
128 else
129 RUNNER_LDFLAGS += -pthread
130 endif
131 endif
132
133 libuv.a: $(OBJS)
134 $(AR) rcs $@ $^
135
136 libuv.$(SOEXT): override CFLAGS += -fPIC
137 libuv.$(SOEXT): $(OBJS)
138 $(CC) -shared -o $@ $^ $(LDFLAGS)
139
140 include/uv-private/uv-unix.h: \
141 include/uv-private/uv-bsd.h \
142 include/uv-private/uv-darwin.h \
143 include/uv-private/uv-linux.h \
144 include/uv-private/uv-sunos.h \
145 include/uv-private/uv-android.h
146
147 src/unix/internal.h: src/unix/linux-syscalls.h
148
149 src/.buildstamp src/unix/.buildstamp test/.buildstamp:
150 mkdir -p $(dir $@)
151 touch $@
152
153 src/unix/%.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/internal.h src/unix/.buildstamp
154 $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
155
156 src/%.o: src/%.c include/uv.h include/uv-private/uv-unix.h src/.buildstamp
157 $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
158
159 test/%.o: test/%.c include/uv.h test/.buildstamp
160 $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
161
162 clean-platform:
163 -rm -f libuv.a libuv.$(SOEXT) test/run-{tests,benchmarks}.dSYM
164
165 distclean-platform:
166 -rm -f libuv.a libuv.$(SOEXT) test/run-{tests,benchmarks}.dSYM