• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# c-ares Makefile for djgpp/gcc/Watt-32.
3#   By Gisle Vanem <gvanem@yahoo.no> 2004 - 2020.
4#
5include src/lib/Makefile.inc
6
7CSOURCES := $(addprefix src/lib/, $(CSOURCES))
8CSOURCES := $(filter-out src/lib/windows_port.c, $(CSOURCES))
9
10VPATH = src/lib src/tools
11
12#
13# Root directory for Waterloo tcp/ip.
14# WATT_ROOT should be set during Watt-32 install.
15#
16WATT32_ROOT = $(realpath $(WATT_ROOT))
17WATT32_LIB  = $(WATT32_ROOT)/lib/libwatt.a
18
19OBJ_DIR = djgpp
20
21CFLAGS = -g -O2 -I./include -I./src/lib \
22         -I$(WATT32_ROOT)/inc -Wall \
23         -DWATT32 -DHAVE_CONFIG_H   \
24         -Dselect=select_s
25
26LDFLAGS = -s
27
28ifeq ($(OS),Windows_NT)
29  #
30  # Windows hosted djgpp cross compiler. Get it from:
31  #   https://github.com/andrewwutw/build-djgpp/releases
32  #
33  DJ_PREFIX ?= c:/some-path/djgpp/bin/i586-pc-msdosdjgpp-
34  CC = $(DJ_PREFIX)gcc
35
36else
37  #
38  # The normal djgpp 'gcc' for MSDOS.
39  #
40  CC = gcc
41endif
42
43OBJECTS = $(addprefix $(OBJ_DIR)/, \
44            $(notdir $(CSOURCES:.c=.o)))
45
46GENERATED = src/lib/ares_config.h \
47            include/ares_build.h
48
49TARGETS = libcares.a acountry.exe adig.exe ahost.exe
50
51.SECONDARY: $(OBJ_DIR)/ares_getopt.o
52
53all: $(OBJ_DIR) $(GENERATED) $(TARGETS)
54	@echo Welcome to c-ares.
55
56libcares.a: $(OBJECTS)
57	ar rs $@ $(OBJECTS)
58
59src/lib/ares_config.h: src/lib/config-dos.h
60	cp --update $< $@
61
62include/ares_build.h: include/ares_build.h.dist
63	cp --update $< $@
64
65%.exe: src/tools/%.c $(OBJ_DIR)/ares_getopt.o libcares.a
66	$(call compile_and_link, $@, $^ $(WATT32_LIB))
67
68# Clean generated files and objects.
69#
70clean:
71	- rm -f depend.dj $(GENERATED) $(OBJ_DIR)/*.o
72	- rmdir $(OBJ_DIR)
73
74# Clean everything
75#
76realclean vclean: clean
77	- rm -f $(TARGETS) $(TARGETS:.exe=.map)
78
79$(OBJ_DIR):
80	- mkdir $@
81
82$(OBJ_DIR)/%.o: %.c
83	$(CC) $(CFLAGS) -o $@ -c $<
84	@echo
85
86define compile_and_link
87  $(CC) -o $(1) $(CFLAGS) $(LDFLAGS) -Wl,--print-map,--sort-common $(2) > $(1:.exe=.map)
88  @echo
89endef
90
91DEP_REPLACE = sed -e 's@\(.*\)\.o: @\n$$(OBJ_DIR)\/\1.o: @' \
92                  -e 's@$(WATT32_ROOT)@$$(WATT32_ROOT)@g'
93
94#
95# One may have to do 'make -f Makefile.dj clean' first in case
96# a foreign 'curl_config.h' is making trouble.
97#
98depend: $(GENERATED) Makefile.dj
99	$(CC) -MM $(CFLAGS) $(CSOURCES) | $(DEP_REPLACE) > depend.dj
100
101-include depend.dj
102
103