1 # Copyright Joyent, Inc. and other Node contributors. All rights reserved.
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:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
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
21 OS ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
25 src/ares__close_sockets.o \
26 src/ares_create_query.o \
29 src/ares_expand_name.o \
30 src/ares_expand_string.o \
32 src/ares_free_hostent.o \
33 src/ares_free_string.o \
34 src/ares_gethostbyaddr.o \
35 src/ares_gethostbyname.o \
36 src/ares__get_hostent.o \
37 src/ares_getnameinfo.o \
41 src/ares_library_init.o \
46 src/ares_parse_aaaa_reply.o \
47 src/ares_parse_a_reply.o \
48 src/ares_parse_mx_reply.o \
49 src/ares_parse_naptr_reply.o \
50 src/ares_parse_ns_reply.o \
51 src/ares_parse_ptr_reply.o \
52 src/ares_parse_soa_reply.o \
53 src/ares_parse_srv_reply.o \
54 src/ares_parse_txt_reply.o \
57 src/ares__read_line.o \
60 src/ares_strcasecmp.o \
71 CFLAGS += -I. -I$(SRCDIR)/include -DHAVE_CONFIG_H
73 ARES_CONFIG_OS = $(OS)
77 ifneq (,$(findstring mingw,$(OS)))
78 ARES_CONFIG_OS = win32
79 OBJS += src/windows_port.o
80 OBJS += src/ares_getenv.o
81 OBJS += src/ares_platform.o
83 LDFLAGS += -lws2_32.lib -liphlpapi.lib
84 else # else a posix system
85 CFLAGS += -g --std=gnu89 -pedantic
86 CFLAGS += -Wall -Wextra -Wno-unused-parameter
87 CFLAGS += -D_LARGEFILE_SOURCE
88 CFLAGS += -D_FILE_OFFSET_BITS=64
91 ifneq (,$(findstring cygwin,$(OS)))
92 ARES_CONFIG_OS = cygwin
93 CFLAGS += -D_GNU_SOURCE
96 ifeq (dragonflybsd,$(OS))
97 ARES_CONFIG_OS = freebsd
101 CFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
102 LDFLAGS += -dynamiclib -install_name "@rpath/libcares.dylib"
107 CFLAGS += -D_GNU_SOURCE
111 CFLAGS += -D_GNU_SOURCE
115 LDFLAGS += -lsocket -lnsl
116 CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
119 CFLAGS += -I$(SRCDIR)/config/$(ARES_CONFIG_OS)
121 ifneq (,$(findstring libcares.$(SOEXT),$(MAKECMDGOALS)))
122 CFLAGS += -DCARES_BUILDING_LIBRARY
124 CFLAGS += -DCARES_STATICLIB
136 libcares.$(SOEXT): override CFLAGS += -fPIC
137 libcares.$(SOEXT): $(OBJS:%.o=%.pic.o)
138 $(CC) -shared -o $@ $^ $(LDFLAGS)
140 src/%.o src/%.pic.o: src/%.c include/ares.h include/ares_version.h \
141 include/nameser.h src/.buildstamp \
142 $(SRCDIR)/config/$(ARES_CONFIG_OS)/ares_config.h
143 $(CC) $(CFLAGS) -c $< -o $@
147 $(RM) -f libcares.a libcares.$(SOEXT) src/*.o src/.buildstamp