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

include Makefile.inc

WATT32_ROOT = $(subst \,/,$(WATT_ROOT))

CC      = gcc
CFLAGS  = -O2 -Wall -DWATT32 -Dselect=select_s -DHAVE_AF_INET6 \
          -DHAVE_PF_INET6 -DHAVE_IOCTLSOCKET -DHAVE_STRUCT_IN6_ADDR \
          -DHAVE_STRUCT_SOCKADDR_IN6 -DHAVE_STRUCT_ADDRINFO \
          -DHAVE_ARPA_NAMESER_H -DNS_INADDRSZ=4 \
          -DHAVE_SYS_TIME_H -DHAVE_TIME_H \
          -DTIME_WITH_SYS_TIME -DHAVE_STRUCT_TIMEVAL \
          -DHAVE_SOCKADDR_IN6_SIN6_SCOPE_ID -I$(WATT32_ROOT)/inc

LDFLAGS = -s
EX_LIBS = $(WATT32_ROOT)/lib/libwatt.a

OBJ_DIR = djgpp

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

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

$(OBJ_DIR):
	- mkdir $(OBJ_DIR)

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

ahost.exe: ahost.c libcares.a
	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS)

adig.exe: adig.c libcares.a
	$(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)

$(OBJ_DIR)/%.o: %.c
	$(CC) $(CFLAGS) -o $@ -c $<
	@echo

depend:
	$(CC) -MM $(CFLAGS) $(CSOURCES) | \
	sed -e 's/^\([a-zA-Z0-9_-]*\.o:\)/$$(OBJ_DIR)\/\1/' > depend.dj

-include depend.dj
