1# 2# c-ares Makefile for djgpp/gcc/Watt-32. 3# Copyright (C) Gisle Vanem <gvanem@yahoo.no> 4# SPDX-License-Identifier: MIT 5# 6include src/lib/Makefile.inc 7 8OBJ_DIR = djgpp 9OBJECTS = $(addprefix $(OBJ_DIR)/, \ 10 $(CSOURCES:.c=.o)) 11 12CSRC = $(addprefix src/lib/, $(CSOURCES)) 13#CSRC := $(filter-out src/lib/windows_port.c, $(CSOURCES)) 14 15OBJ_SUBDIRS = $(OBJ_DIR)/dsa $(OBJ_DIR)/event $(OBJ_DIR)/legacy $(OBJ_DIR)/record $(OBJ_DIR)/str $(OBJ_DIR)/util 16 17VPATH = src/lib src/tools 18 19# 20# Root directory for Waterloo tcp/ip. 21# WATT_ROOT should be set during Watt-32 install. 22# 23WATT32_ROOT = $(realpath $(WATT_ROOT)) 24WATT32_LIB = $(WATT32_ROOT)/lib/libwatt.a 25 26CFLAGS = -g -O2 -I./include -I./src/lib -I./src/lib/include \ 27 -I$(WATT32_ROOT)/inc \ 28 -Wall \ 29 -Wextra \ 30 -Waggregate-return \ 31 -Wcast-align \ 32 -Wcast-qual \ 33 -Wconversion \ 34 -Wdeclaration-after-statement \ 35 -Wdouble-promotion \ 36 -Wfloat-equal \ 37 -Winit-self \ 38 -Wjump-misses-init \ 39 -Wlogical-op \ 40 -Wmissing-braces \ 41 -Wmissing-declarations \ 42 -Wmissing-format-attribute \ 43 -Wmissing-include-dirs \ 44 -Wmissing-prototypes \ 45 -Wnested-externs \ 46 -Wno-coverage-mismatch \ 47 -Wold-style-definition \ 48 -Wpacked \ 49 -Wpointer-arith \ 50 -Wshadow \ 51 -Wsign-conversion \ 52 -Wstrict-overflow \ 53 -Wstrict-prototypes \ 54 -Wtrampolines \ 55 -Wundef \ 56 -Wunreachable-code \ 57 -Wunused \ 58 -Wvariadic-macros \ 59 -Wvla \ 60 -Wwrite-strings \ 61 -Werror=implicit-int \ 62 -Werror=implicit-function-declaration \ 63 -Wno-long-long \ 64 -DWATT32 -DHAVE_CONFIG_H \ 65 -D_REENTRANT \ 66 -DCARES_NO_DEPRECATED \ 67 -Dselect=select_s 68 69# Can't enable -Wredundant-decls due to WATT32 issues 70 71 72LDFLAGS = -s 73 74ifeq ($(OS),Windows_NT) 75 # 76 # Windows hosted djgpp cross compiler. Get it from: 77 # https://github.com/andrewwutw/build-djgpp/releases 78 # 79 DJ_PREFIX ?= c:/some-path/djgpp/bin/i586-pc-msdosdjgpp- 80 CC = $(DJ_PREFIX)gcc 81 82else 83 # 84 # The normal djgpp 'gcc' for MSDOS. 85 # 86 CC = gcc 87endif 88 89GENERATED = src/lib/ares_config.h \ 90 include/ares_build.h 91 92TARGETS = libcares.a adig.exe ahost.exe 93 94.SECONDARY: $(OBJ_DIR)/ares_getopt.o 95 96all: $(OBJ_DIR) $(OBJ_SUBDIRS) $(GENERATED) $(TARGETS) 97 @echo Welcome to c-ares. 98 99libcares.a: $(OBJECTS) 100 ar rs $@ $(OBJECTS) 101 102src/lib/ares_config.h: src/lib/config-dos.h 103 cp --update $< $@ 104 105include/ares_build.h: include/ares_build.h.dist 106 cp --update $< $@ 107 108%.exe: src/tools/%.c $(OBJ_DIR)/ares_getopt.o libcares.a 109 $(call compile_and_link, $@, $^ $(WATT32_LIB)) 110 111# Clean generated files and objects. 112# 113clean: 114 - rm -f depend.dj $(GENERATED) $(OBJ_DIR)/*.o 115 - rmdir $(OBJ_SUBDIRS) 116 117# Clean everything 118# 119realclean vclean: clean 120 - rm -f $(TARGETS) $(TARGETS:.exe=.map) 121 122.PHONY: obj_subdirs $(OBJ_SUBDIRS) 123 124obj_subdirs: $(OBJ_SUBDIRS) 125 126$(OBJ_SUBDIRS): 127 mkdir $@ 128 129$(OBJ_DIR)/%.o: %.c 130 $(CC) $(CFLAGS) -o $@ -c $< 131 @echo 132 133define compile_and_link 134 $(CC) -o $(1) $(CFLAGS) $(LDFLAGS) -Wl,--print-map,--sort-common $(2) > $(1:.exe=.map) 135 @echo 136endef 137 138DEP_REPLACE = sed -e 's@\(.*\)\.o: @\n$$(OBJ_DIR)\/\1.o: @' \ 139 -e 's@$(WATT32_ROOT)@$$(WATT32_ROOT)@g' 140 141# 142# One may have to do 'make -f Makefile.dj clean' first in case 143# a foreign 'curl_config.h' is making trouble. 144# 145depend: $(GENERATED) Makefile.dj 146 $(CC) -MM $(CFLAGS) $(CSRC) | $(DEP_REPLACE) > depend.dj 147 148-include depend.dj 149 150