11cb0ef41Sopenharmony_ci# 21cb0ef41Sopenharmony_ci# c-ares Makefile for djgpp/gcc/Watt-32. 31cb0ef41Sopenharmony_ci# Copyright (C) Gisle Vanem <gvanem@yahoo.no> 41cb0ef41Sopenharmony_ci# SPDX-License-Identifier: MIT 51cb0ef41Sopenharmony_ci# 61cb0ef41Sopenharmony_ciinclude src/lib/Makefile.inc 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciCSOURCES := $(addprefix src/lib/, $(CSOURCES)) 91cb0ef41Sopenharmony_ciCSOURCES := $(filter-out src/lib/windows_port.c, $(CSOURCES)) 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciVPATH = src/lib src/tools 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci# 141cb0ef41Sopenharmony_ci# Root directory for Waterloo tcp/ip. 151cb0ef41Sopenharmony_ci# WATT_ROOT should be set during Watt-32 install. 161cb0ef41Sopenharmony_ci# 171cb0ef41Sopenharmony_ciWATT32_ROOT = $(realpath $(WATT_ROOT)) 181cb0ef41Sopenharmony_ciWATT32_LIB = $(WATT32_ROOT)/lib/libwatt.a 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciOBJ_DIR = djgpp 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciCFLAGS = -g -O2 -I./include -I./src/lib \ 231cb0ef41Sopenharmony_ci -I$(WATT32_ROOT)/inc -Wall \ 241cb0ef41Sopenharmony_ci -DWATT32 -DHAVE_CONFIG_H \ 251cb0ef41Sopenharmony_ci -Dselect=select_s 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciLDFLAGS = -s 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciifeq ($(OS),Windows_NT) 301cb0ef41Sopenharmony_ci # 311cb0ef41Sopenharmony_ci # Windows hosted djgpp cross compiler. Get it from: 321cb0ef41Sopenharmony_ci # https://github.com/andrewwutw/build-djgpp/releases 331cb0ef41Sopenharmony_ci # 341cb0ef41Sopenharmony_ci DJ_PREFIX ?= c:/some-path/djgpp/bin/i586-pc-msdosdjgpp- 351cb0ef41Sopenharmony_ci CC = $(DJ_PREFIX)gcc 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_cielse 381cb0ef41Sopenharmony_ci # 391cb0ef41Sopenharmony_ci # The normal djgpp 'gcc' for MSDOS. 401cb0ef41Sopenharmony_ci # 411cb0ef41Sopenharmony_ci CC = gcc 421cb0ef41Sopenharmony_ciendif 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ciOBJECTS = $(addprefix $(OBJ_DIR)/, \ 451cb0ef41Sopenharmony_ci $(notdir $(CSOURCES:.c=.o))) 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ciGENERATED = src/lib/ares_config.h \ 481cb0ef41Sopenharmony_ci include/ares_build.h 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ciTARGETS = libcares.a adig.exe ahost.exe 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ci.SECONDARY: $(OBJ_DIR)/ares_getopt.o 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ciall: $(OBJ_DIR) $(GENERATED) $(TARGETS) 551cb0ef41Sopenharmony_ci @echo Welcome to c-ares. 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_cilibcares.a: $(OBJECTS) 581cb0ef41Sopenharmony_ci ar rs $@ $(OBJECTS) 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_cisrc/lib/ares_config.h: src/lib/config-dos.h 611cb0ef41Sopenharmony_ci cp --update $< $@ 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ciinclude/ares_build.h: include/ares_build.h.dist 641cb0ef41Sopenharmony_ci cp --update $< $@ 651cb0ef41Sopenharmony_ci 661cb0ef41Sopenharmony_ci%.exe: src/tools/%.c $(OBJ_DIR)/ares_getopt.o libcares.a 671cb0ef41Sopenharmony_ci $(call compile_and_link, $@, $^ $(WATT32_LIB)) 681cb0ef41Sopenharmony_ci 691cb0ef41Sopenharmony_ci# Clean generated files and objects. 701cb0ef41Sopenharmony_ci# 711cb0ef41Sopenharmony_ciclean: 721cb0ef41Sopenharmony_ci - rm -f depend.dj $(GENERATED) $(OBJ_DIR)/*.o 731cb0ef41Sopenharmony_ci - rmdir $(OBJ_DIR) 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ci# Clean everything 761cb0ef41Sopenharmony_ci# 771cb0ef41Sopenharmony_cirealclean vclean: clean 781cb0ef41Sopenharmony_ci - rm -f $(TARGETS) $(TARGETS:.exe=.map) 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_ci$(OBJ_DIR): 811cb0ef41Sopenharmony_ci - mkdir $@ 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci$(OBJ_DIR)/%.o: %.c 841cb0ef41Sopenharmony_ci $(CC) $(CFLAGS) -o $@ -c $< 851cb0ef41Sopenharmony_ci @echo 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_cidefine compile_and_link 881cb0ef41Sopenharmony_ci $(CC) -o $(1) $(CFLAGS) $(LDFLAGS) -Wl,--print-map,--sort-common $(2) > $(1:.exe=.map) 891cb0ef41Sopenharmony_ci @echo 901cb0ef41Sopenharmony_ciendef 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ciDEP_REPLACE = sed -e 's@\(.*\)\.o: @\n$$(OBJ_DIR)\/\1.o: @' \ 931cb0ef41Sopenharmony_ci -e 's@$(WATT32_ROOT)@$$(WATT32_ROOT)@g' 941cb0ef41Sopenharmony_ci 951cb0ef41Sopenharmony_ci# 961cb0ef41Sopenharmony_ci# One may have to do 'make -f Makefile.dj clean' first in case 971cb0ef41Sopenharmony_ci# a foreign 'curl_config.h' is making trouble. 981cb0ef41Sopenharmony_ci# 991cb0ef41Sopenharmony_cidepend: $(GENERATED) Makefile.dj 1001cb0ef41Sopenharmony_ci $(CC) -MM $(CFLAGS) $(CSOURCES) | $(DEP_REPLACE) > depend.dj 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_ci-include depend.dj 1031cb0ef41Sopenharmony_ci 104