#
# c-ares Makefile for djgpp/gcc/Watt-32.
#   By Gisle Vanem <giva@bgnett.no> 2004.
#
# $Id$

TOPDIR = ..

include ../packages/DOS/common.dj

include Makefile.inc

CFLAGS += -DWATT32 -DHAVE_AF_INET6 -DHAVE_PF_INET6 -DHAVE_FIONBIO \
          -DHAVE_STRUCT_IN6_ADDR -DHAVE_SOCKADDR_IN6_SIN6_SCOPE_ID \
          -DHAVE_SYS_TIME_H -DHAVE_STRUCT_SOCKADDR_IN6 -DHAVE_STRUCT_ADDRINFO \
          -DHAVE_SIGNAL_H -DHAVE_SIG_ATOMIC_T -DRETSIGTYPE='void' -DHAVE_PROCESS_H \
          -DHAVE_ARPA_NAMESER_H -DNS_INADDRSZ=4 -DHAVE_RECV -DHAVE_SEND \
          -DSEND_TYPE_ARG1='int'   -DSEND_QUAL_ARG2='const' \
          -DSEND_TYPE_ARG2='void*' -DSEND_TYPE_ARG3='int' \
          -DSEND_TYPE_ARG4='int'   -DSEND_TYPE_RETV='int' \
          -DRECV_TYPE_ARG1='int'   -DRECV_TYPE_ARG2='void*' \
          -DRECV_TYPE_ARG3='int'   -DRECV_TYPE_ARG4='int' \
          -DRECV_TYPE_RETV='int'   -DHAVE_STRUCT_TIMEVAL \
          -Dselect=select_s        -UHAVE_CONFIG_H

LDFLAGS = -s

ifeq ($(USE_DEBUG),1)
  EX_LIBS  = ../lib/libcurl.a
  OBJ_HACK = $(OBJECTS)
else
  OBJ_HACK = libcares.a
endif

ifeq ($(USE_SSL),1)
  EX_LIBS += $(OPENSSL_ROOT)/lib/libssl.a $(OPENSSL_ROOT)/lib/libcrypt.a
endif

ifeq ($(USE_ZLIB),1)
  EX_LIBS += $(ZLIB_ROOT)/libz.a
endif

ifeq ($(USE_IDNA),1)
  EX_LIBS += $(LIBIDN_ROOT)/lib/dj_obj/libidn.a -liconv
endif

EX_LIBS += $(WATT32_ROOT)/lib/libwatt.a

OBJECTS = $(addprefix $(OBJ_DIR)/, $(CSOURCES:.c=.o))

all: $(OBJ_DIR) libcares.a ahost.exe adig.exe
	@echo Welcome to c-ares.

libcares.a: $(OBJECTS)
	ar rs $@ $?

ahost.exe: ahost.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS)

adig.exe: adig.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS)

clean:
	rm -f $(OBJECTS) libcares.a

vclean realclean: clean
	rm -f ahost.exe adig.exe depend.dj
	- rmdir $(OBJ_DIR)

-include depend.dj

