lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | # |
| 2 | # Watcom / OpenWatcom / Win32 makefile for cares. |
| 3 | # Quick hack by Guenter; comments to: /dev/nul |
| 4 | # |
| 5 | |
| 6 | !ifndef %watcom |
| 7 | !error WATCOM environment variable not set! |
| 8 | !else |
| 9 | SYS_INCL = -I$(%watcom)\h\nt -I$(%watcom)\h |
| 10 | SYS_LIBS = $(%watcom)\lib386\nt;$(%watcom)\lib386 |
| 11 | !endif |
| 12 | |
| 13 | !ifdef %libname |
| 14 | LIBNAME = $(%libname) |
| 15 | !else |
| 16 | LIBNAME = cares |
| 17 | !endif |
| 18 | TARGETS = $(LIBNAME).dll $(LIBNAME)_imp.lib $(LIBNAME).lib |
| 19 | DEMOS = adig.exe ahost.exe acountry.exe |
| 20 | |
| 21 | CC = wcc386 |
| 22 | LD = wlink |
| 23 | AR = wlib |
| 24 | RC = wrc |
| 25 | |
| 26 | !ifdef __LOADDLL__ |
| 27 | ! loaddll wcc386 wccd386 |
| 28 | ! loaddll wpp386 wppd386 |
| 29 | ! loaddll wlib wlibd |
| 30 | !endif |
| 31 | |
| 32 | !if $(__VERSION__) < 1250 |
| 33 | RM = del /q /f 2>NUL |
| 34 | !else |
| 35 | RM = rm -f |
| 36 | !endif |
| 37 | MD = mkdir |
| 38 | RD = rmdir /q /s 2>NUL |
| 39 | CP = copy |
| 40 | |
| 41 | CFLAGS = -3r -mf -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm & |
| 42 | -wcd=201 -bt=nt -d+ -dWIN32 -dCARES_BUILDING_LIBRARY & |
| 43 | -dNTDDI_VERSION=0x05010000 -I. $(SYS_INCL) |
| 44 | |
| 45 | LFLAGS = option quiet, map, caseexact, eliminate |
| 46 | |
| 47 | !ifdef %debug |
| 48 | DEBUG = -dDEBUG=1 -dDEBUGBUILD |
| 49 | CFLAGS += -d3 $(DEBUG) |
| 50 | LFLAGS += debug all |
| 51 | !else |
| 52 | CFLAGS += -d0 |
| 53 | !endif |
| 54 | |
| 55 | CFLAGS += -d_WIN32_WINNT=0x0501 |
| 56 | |
| 57 | # |
| 58 | # Change to suite. |
| 59 | # |
| 60 | !ifdef %use_watt32 |
| 61 | CFLAGS += -dWATT32 -I$(%watt_root)\inc |
| 62 | !endif |
| 63 | |
| 64 | OBJ_BASE = WC_Win32.obj |
| 65 | LINK_ARG = $(OBJ_BASE)\dyn\wlink.arg |
| 66 | LIB_ARG = $(OBJ_BASE)\stat\wlib.arg |
| 67 | |
| 68 | # In order to process Makefile.inc wmake must be called with -u switch! |
| 69 | !ifneq __MAKEOPTS__ -u |
| 70 | !error You MUST call wmake with the -u switch! |
| 71 | !else |
| 72 | !include Makefile.inc |
| 73 | !endif |
| 74 | |
| 75 | OBJS = $(CSOURCES:.c=.obj) |
| 76 | OBJS = $OBJ_DIR\$(OBJS: = $OBJ_DIR\) |
| 77 | |
| 78 | # |
| 79 | # Use $(OBJS) as a template to generate $(OBJS_STAT) and $(OBJS_DYN). |
| 80 | # |
| 81 | OBJ_DIR = $(OBJ_BASE)\stat |
| 82 | OBJS_STAT = $+ $(OBJS) $- |
| 83 | |
| 84 | OBJ_DIR = $(OBJ_BASE)\dyn |
| 85 | OBJS_DYN = $+ $(OBJS) $- |
| 86 | |
| 87 | ARESBUILDH = ares_build.h |
| 88 | RESOURCE = $(OBJ_BASE)\dyn\cares.res |
| 89 | |
| 90 | all: $(ARESBUILDH) $(OBJ_BASE) $(TARGETS) $(DEMOS) .SYMBOLIC |
| 91 | @echo Welcome to cares |
| 92 | |
| 93 | $(OBJ_BASE): |
| 94 | -$(MD) $^@ |
| 95 | -$(MD) $^@\stat |
| 96 | -$(MD) $^@\dyn |
| 97 | -$(MD) $^@\demos |
| 98 | |
| 99 | $(ARESBUILDH): .EXISTSONLY |
| 100 | $(CP) $^@.dist $^@ |
| 101 | |
| 102 | $(LIBNAME).dll: $(OBJS_DYN) $(RESOURCE) $(LINK_ARG) |
| 103 | $(LD) name $^@ @$]@ |
| 104 | |
| 105 | $(LIBNAME).lib: $(OBJS_STAT) $(LIB_ARG) |
| 106 | $(AR) -q -b -c $^@ @$]@ |
| 107 | |
| 108 | adig.exe: $(OBJ_BASE)\demos\adig.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib |
| 109 | $(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib |
| 110 | |
| 111 | ahost.exe: $(OBJ_BASE)\demos\ahost.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib |
| 112 | $(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib |
| 113 | |
| 114 | acountry.exe: $(OBJ_BASE)\demos\acountry.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib |
| 115 | $(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib |
| 116 | |
| 117 | clean: .SYMBOLIC |
| 118 | -$(RM) $(OBJS_STAT) |
| 119 | -$(RM) $(OBJS_DYN) |
| 120 | -$(RM) $(RESOURCE) $(LINK_ARG) $(LIB_ARG) |
| 121 | |
| 122 | vclean realclean: clean .SYMBOLIC |
| 123 | -$(RM) $(TARGETS) $(LIBNAME).map |
| 124 | -$(RM) $(DEMOS) $(DEMOS:.exe=.map) |
| 125 | -$(RD) $(OBJ_BASE)\stat |
| 126 | -$(RD) $(OBJ_BASE)\dyn |
| 127 | -$(RD) $(OBJ_BASE)\demos |
| 128 | -$(RD) $(OBJ_BASE) |
| 129 | |
| 130 | .ERASE |
| 131 | $(RESOURCE): cares.rc .AUTODEPEND |
| 132 | $(RC) $(DEBUG) -q -r -zm -I..\include $(SYS_INCL) $[@ -fo=$^@ |
| 133 | |
| 134 | .ERASE |
| 135 | .c{$(OBJ_BASE)\dyn}.obj: |
| 136 | $(CC) $(CFLAGS) -bd $[@ -fo=$^@ |
| 137 | |
| 138 | .ERASE |
| 139 | .c{$(OBJ_BASE)\stat}.obj: |
| 140 | $(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@ |
| 141 | |
| 142 | .ERASE |
| 143 | .c{$(OBJ_BASE)\demos}.obj: |
| 144 | $(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@ |
| 145 | |
| 146 | $(LINK_ARG): $(__MAKEFILES__) |
| 147 | %create $^@ |
| 148 | @%append $^@ system nt dll |
| 149 | @%append $^@ file { $(OBJS_DYN) } |
| 150 | @%append $^@ option res=$(RESOURCE), implib=$(LIBNAME)_imp.lib |
| 151 | @%append $^@ $(LFLAGS) |
| 152 | @%append $^@ libpath $(SYS_LIBS) |
| 153 | # @%append $^@ library clib3r.lib |
| 154 | !ifdef %use_watt32 |
| 155 | @%append $^@ library $(%watt_root)\lib\wattcpw_imp.lib |
| 156 | !else |
| 157 | @%append $^@ library ws2_32.lib |
| 158 | !endif |
| 159 | |
| 160 | $(LIB_ARG): $(__MAKEFILES__) |
| 161 | %create $^@ |
| 162 | @for %f in ($(OBJS_STAT)) do @%append $^@ +- %f |
| 163 | |
| 164 | |