config-unix.mk 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. E=
  21. CSTDFLAG=--std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter
  22. CFLAGS += -g
  23. CPPFLAGS += -I$(SRCDIR)/src
  24. LDFLAGS=-lm
  25. CPPFLAGS += -D_LARGEFILE_SOURCE
  26. CPPFLAGS += -D_FILE_OFFSET_BITS=64
  27. RUNNER_SRC=test/runner-unix.c
  28. RUNNER_CFLAGS=$(CFLAGS) -I$(SRCDIR)/test
  29. RUNNER_LDFLAGS=-L"$(CURDIR)" -luv
  30. HAVE_DTRACE=
  31. DTRACE_OBJS=
  32. DTRACE_HEADER=
  33. OBJS += src/unix/async.o
  34. OBJS += src/unix/core.o
  35. OBJS += src/unix/dl.o
  36. OBJS += src/unix/error.o
  37. OBJS += src/unix/fs.o
  38. OBJS += src/unix/getaddrinfo.o
  39. OBJS += src/unix/loop.o
  40. OBJS += src/unix/loop-watcher.o
  41. OBJS += src/unix/pipe.o
  42. OBJS += src/unix/poll.o
  43. OBJS += src/unix/process.o
  44. OBJS += src/unix/signal.o
  45. OBJS += src/unix/stream.o
  46. OBJS += src/unix/tcp.o
  47. OBJS += src/unix/thread.o
  48. OBJS += src/unix/threadpool.o
  49. OBJS += src/unix/timer.o
  50. OBJS += src/unix/tty.o
  51. OBJS += src/unix/udp.o
  52. OBJS += src/fs-poll.o
  53. OBJS += src/uv-common.o
  54. OBJS += src/inet.o
  55. OBJS += src/version.o
  56. ifeq (sunos,$(PLATFORM))
  57. HAVE_DTRACE=1
  58. CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
  59. LDFLAGS+=-lkstat -lnsl -lsendfile -lsocket
  60. # Library dependencies are not transitive.
  61. OBJS += src/unix/sunos.o
  62. OBJS += src/unix/dtrace.o
  63. DTRACE_OBJS += src/unix/core.o
  64. endif
  65. ifeq (aix,$(PLATFORM))
  66. CPPFLAGS += -D_ALL_SOURCE -D_XOPEN_SOURCE=500
  67. LDFLAGS+= -lperfstat
  68. OBJS += src/unix/aix.o
  69. endif
  70. ifeq (darwin,$(PLATFORM))
  71. HAVE_DTRACE=1
  72. # dtrace(1) probes contain dollar signs on OS X. Mute the warnings they
  73. # generate but only when CC=clang, -Wno-dollar-in-identifier-extension
  74. # is a clang extension.
  75. ifeq (__clang__,$(shell sh -c "$(CC) -dM -E - </dev/null | grep -ow __clang__"))
  76. CFLAGS += -Wno-dollar-in-identifier-extension
  77. endif
  78. CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
  79. LDFLAGS += -framework Foundation \
  80. -framework CoreServices \
  81. -framework ApplicationServices
  82. SOEXT = dylib
  83. OBJS += src/unix/darwin.o
  84. OBJS += src/unix/kqueue.o
  85. OBJS += src/unix/fsevents.o
  86. OBJS += src/unix/proctitle.o
  87. OBJS += src/unix/darwin-proctitle.o
  88. endif
  89. ifeq (linux,$(PLATFORM))
  90. CSTDFLAG += -D_GNU_SOURCE
  91. LDFLAGS+=-ldl -lrt
  92. RUNNER_CFLAGS += -D_GNU_SOURCE
  93. OBJS += src/unix/linux-core.o \
  94. src/unix/linux-inotify.o \
  95. src/unix/linux-syscalls.o \
  96. src/unix/proctitle.o
  97. endif
  98. ifeq (freebsd,$(PLATFORM))
  99. HAVE_DTRACE=1
  100. LDFLAGS+=-lkvm
  101. OBJS += src/unix/freebsd.o
  102. OBJS += src/unix/kqueue.o
  103. endif
  104. ifeq (dragonfly,$(PLATFORM))
  105. LDFLAGS+=-lkvm
  106. OBJS += src/unix/freebsd.o
  107. OBJS += src/unix/kqueue.o
  108. endif
  109. ifeq (netbsd,$(PLATFORM))
  110. LDFLAGS+=-lkvm
  111. OBJS += src/unix/netbsd.o
  112. OBJS += src/unix/kqueue.o
  113. endif
  114. ifeq (openbsd,$(PLATFORM))
  115. LDFLAGS+=-lkvm
  116. OBJS += src/unix/openbsd.o
  117. OBJS += src/unix/kqueue.o
  118. endif
  119. ifneq (,$(findstring cygwin,$(PLATFORM)))
  120. # We drop the --std=c89, it hides CLOCK_MONOTONIC on cygwin
  121. CSTDFLAG = -D_GNU_SOURCE
  122. LDFLAGS+=
  123. OBJS += src/unix/cygwin.o
  124. endif
  125. ifeq (sunos,$(PLATFORM))
  126. RUNNER_LDFLAGS += -pthreads
  127. else
  128. RUNNER_LDFLAGS += -pthread
  129. endif
  130. ifeq ($(HAVE_DTRACE), 1)
  131. DTRACE_HEADER = src/unix/uv-dtrace.h
  132. CPPFLAGS += -Isrc/unix
  133. CFLAGS += -DHAVE_DTRACE
  134. endif
  135. ifneq (darwin,$(PLATFORM))
  136. # Must correspond with UV_VERSION_MAJOR and UV_VERSION_MINOR in src/version.c
  137. SO_LDFLAGS = -Wl,-soname,libuv.so.0.10
  138. endif
  139. RUNNER_LDFLAGS += $(LDFLAGS)
  140. libuv.a: $(OBJS)
  141. $(AR) rcs $@ $^
  142. libuv.$(SOEXT): override CFLAGS += -fPIC
  143. libuv.$(SOEXT): $(OBJS:%.o=%.pic.o)
  144. $(CC) -shared -o $@ $^ $(LDFLAGS) $(SO_LDFLAGS)
  145. include/uv-private/uv-unix.h: \
  146. include/uv-private/uv-bsd.h \
  147. include/uv-private/uv-darwin.h \
  148. include/uv-private/uv-linux.h \
  149. include/uv-private/uv-sunos.h
  150. src/unix/internal.h: src/unix/linux-syscalls.h
  151. src/.buildstamp src/unix/.buildstamp test/.buildstamp:
  152. mkdir -p $(@D)
  153. touch $@
  154. src/unix/%.o src/unix/%.pic.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/internal.h src/unix/.buildstamp $(DTRACE_HEADER)
  155. $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
  156. src/%.o src/%.pic.o: src/%.c include/uv.h include/uv-private/uv-unix.h src/.buildstamp
  157. $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
  158. test/%.o: test/%.c include/uv.h test/.buildstamp
  159. $(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
  160. clean-platform:
  161. $(RM) test/run-{tests,benchmarks}.dSYM $(OBJS) $(OBJS:%.o=%.pic.o) src/unix/uv-dtrace.h
  162. src/unix/uv-dtrace.h: src/unix/uv-dtrace.d
  163. dtrace -h -xnolibs -s $< -o $@
  164. src/unix/dtrace.o: src/unix/uv-dtrace.d $(DTRACE_OBJS)
  165. dtrace -G -s $^ -o $@
  166. src/unix/dtrace.pic.o: src/unix/uv-dtrace.d $(DTRACE_OBJS:%.o=%.pic.o)
  167. dtrace -G -s $^ -o $@