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