diff options
Diffstat (limited to 'Makefile.dj')
-rw-r--r-- | Makefile.dj | 119 |
1 files changed, 68 insertions, 51 deletions
diff --git a/Makefile.dj b/Makefile.dj index f891f7f..a88aae2 100644 --- a/Makefile.dj +++ b/Makefile.dj @@ -1,85 +1,102 @@ # # c-ares Makefile for djgpp/gcc/Watt-32. -# By Gisle Vanem <gvanem@yahoo.no> 2004. +# By Gisle Vanem <gvanem@yahoo.no> 2004 - 2020. # +include src/lib/Makefile.inc +CSOURCES := $(addprefix src/lib/, $(CSOURCES)) +CSOURCES := $(filter-out src/lib/windows_port.c, $(CSOURCES)) -TOPDIR = .. +VPATH = src/lib src/tools -DEPEND_PREREQ = ares_config.h +# +# Root directory for Waterloo tcp/ip. +# WATT_ROOT should be set during Watt-32 install. +# +WATT32_ROOT = $(realpath $(WATT_ROOT)) +WATT32_LIB = $(WATT32_ROOT)/lib/libwatt.a -include ../packages/DOS/common.dj -include Makefile.inc +OBJ_DIR = djgpp -CFLAGS += -DWATT32 -Dselect=select_s +CFLAGS = -g -O2 -I./include -I./src/lib \ + -I$(WATT32_ROOT)/inc -Wall \ + -DWATT32 -DHAVE_CONFIG_H \ + -Dselect=select_s LDFLAGS = -s -ifeq ($(USE_CURLDEBUG),1) - EX_LIBS = ../lib/libcurl.a - OBJ_HACK = $(OBJECTS) -else - OBJ_HACK = libcares.a -endif +ifeq ($(OS),Windows_NT) + # + # Windows hosted djgpp cross compiler. Get it from: + # https://github.com/andrewwutw/build-djgpp/releases + # + DJ_PREFIX ?= c:/some-path/djgpp/bin/i586-pc-msdosdjgpp- + CC = $(DJ_PREFIX)gcc -ifeq ($(USE_SSL),1) - EX_LIBS += $(OPENSSL_ROOT)/lib/libssl.a $(OPENSSL_ROOT)/lib/libcrypt.a +else + # + # The normal djgpp 'gcc' for MSDOS. + # + CC = gcc endif -ifeq ($(USE_ZLIB),1) - EX_LIBS += $(ZLIB_ROOT)/libz.a -endif +OBJECTS = $(addprefix $(OBJ_DIR)/, \ + $(notdir $(CSOURCES:.c=.o))) -ifeq ($(USE_IDNA),1) - EX_LIBS += $(LIBIDN_ROOT)/lib/dj_obj/libidn.a -liconv -endif +GENERATED = src/lib/ares_config.h \ + include/ares_build.h -EX_LIBS += $(WATT32_ROOT)/lib/libwatt.a +TARGETS = libcares.a acountry.exe adig.exe ahost.exe -OBJECTS = $(addprefix $(OBJ_DIR)/, $(CSOURCES:.c=.o)) +.SECONDARY: $(OBJ_DIR)/ares_getopt.o -all: $(OBJ_DIR) ares_config.h libcares.a ahost.exe adig.exe acountry.exe +all: $(OBJ_DIR) $(GENERATED) $(TARGETS) @echo Welcome to c-ares. libcares.a: $(OBJECTS) - ar rs $@ $? - -ares_config.h: config-dos.h - $(COPY) $^ $@ + ar rs $@ $(OBJECTS) -ahost.exe: ahost.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK) - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS) +src/lib/ares_config.h: src/lib/config-dos.h + cp --update $< $@ -adig.exe: adig.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK) - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS) +include/ares_build.h: include/ares_build.h.dist + cp --update $< $@ -acountry.exe: acountry.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK) - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(EX_LIBS) +%.exe: src/tools/%.c $(OBJ_DIR)/ares_getopt.o libcares.a + $(call compile_and_link, $@, $^ $(WATT32_LIB)) -# clean generated files +# Clean generated files and objects. # -genclean: - - $(DELETE) ares_config.h +clean: + - rm -f depend.dj $(GENERATED) $(OBJ_DIR)/*.o + - rmdir $(OBJ_DIR) -# clean object files and subdir +# Clean everything # -objclean: genclean - - $(DELETE) $(OBJ_DIR)$(DS)*.o - - $(RMDIR) $(OBJ_DIR) +realclean vclean: clean + - rm -f $(TARGETS) $(TARGETS:.exe=.map) -# clean without removing built library and programs -# -clean: objclean - - $(DELETE) depend.dj +$(OBJ_DIR): + - mkdir $@ + +$(OBJ_DIR)/%.o: %.c + $(CC) $(CFLAGS) -o $@ -c $< + @echo + +define compile_and_link + $(CC) -o $(1) $(CFLAGS) $(LDFLAGS) -Wl,--print-map,--sort-common $(2) > $(1:.exe=.map) + @echo +endef + +DEP_REPLACE = sed -e 's@\(.*\)\.o: @\n$$(OBJ_DIR)\/\1.o: @' \ + -e 's@$(WATT32_ROOT)@$$(WATT32_ROOT)@g' -# clean everything # -realclean vclean: clean - - $(DELETE) libcares.a - - $(DELETE) acountry.exe - - $(DELETE) adig.exe - - $(DELETE) ahost.exe - - $(DELETE) libcares.a +# One may have to do 'make -f Makefile.dj clean' first in case +# a foreign 'curl_config.h' is making trouble. +# +depend: $(GENERATED) Makefile.dj + $(CC) -MM $(CFLAGS) $(CSOURCES) | $(DEP_REPLACE) > depend.dj -include depend.dj |