added ranlib when library is created with ar.
[platform/upstream/c-ares.git] / Makefile.netware
1 #################################################################
2 # $Id$
3 #
4 ## Makefile for building libares (NetWare version - gnu make)
5 ## Use: make -f Makefile.netware
6 ##
7 ## Comments to: Guenter Knauf http://www.gknw.de/phpbb
8 #
9 #################################################################
10
11 # Edit the path below to point to the base of your Novell NDK.
12 ifndef NDKBASE
13 NDKBASE = c:/novell
14 endif
15
16 ifndef INSTDIR
17 INSTDIR = ../curl-$(LIBCURL_VERSION_STR)-bin-nw
18 endif
19
20 # Edit the vars below to change NLM target settings.
21 TARGETS = adig.nlm ahost.nlm
22 LTARGET = libcares.$(LIBEXT)
23 VERSION = $(LIBCARES_VERSION)
24 COPYR   = Copyright (C) 1996 - 2007, Daniel Stenberg, <daniel@haxx.se>
25 DESCR   = cURL $(subst .def,,$(notdir $@)) $(LIBCARES_VERSION_STR) - http://curl.haxx.se
26 MTSAFE  = YES
27 STACK   = 64000
28 SCREEN  = none
29 #EXPORTS        =
30 # Comment the line below if you dont want to load protected automatically.
31 #LDRING = 3
32
33 # Edit the var below to point to your lib architecture.
34 ifndef LIBARCH
35 LIBARCH = LIBC
36 endif
37
38 # must be equal to DEBUG or NDEBUG
39 DB      = NDEBUG
40 # DB    = DEBUG
41 # DB    = CURLDEBUG
42 # Optimization: -O<n> or debugging: -g
43 ifeq ($(DB),NDEBUG)
44         OPT     = -O2
45         OBJDIR  = release
46 else
47         OPT     = -g
48         OBJDIR  = debug
49 endif
50
51 # Include the version info retrieved from curlver.h
52 -include $(OBJDIR)/version.inc
53
54 # The following line defines your compiler.
55 ifdef METROWERKS
56         CC = mwccnlm
57 else
58         CC = gcc
59 endif
60 YACC    = bison -y
61 CP      = cp -afv
62 # RM    = rm -f
63 # if you want to mark the target as MTSAFE you will need a tool for
64 # generating the xdc data for the linker; here's a minimal tool:
65 # http://www.gknw.com/development/prgtools/mkxdc.zip
66 MPKXDC  = mkxdc
67
68 # Global flags for all compilers
69 CFLAGS  = $(OPT) -D$(DB) -DNETWARE -DHAVE_CONFIG_H -nostdinc
70
71 ifeq ($(CC),mwccnlm)
72 LD      = mwldnlm
73 LDFLAGS = -nostdlib $(PRELUDE) $(OBJEXE) $(<:.def=.o) -o $@ -commandfile
74 AR      = mwldnlm
75 ARFLAGS = -type library -w nocmdline $(OBJDIR)/*.o -o
76 LIBEXT  = lib
77 #RANLIB =
78 CFLAGS  += -msgstyle gcc -gccinc -inline off -opt nointrinsics -proc 586
79 CFLAGS  += -relax_pointers
80 #CFLAGS += -w on
81 ifeq ($(LIBARCH),LIBC)
82         PRELUDE = $(SDK_LIBC)/imports/libcpre.o
83         CFLAGS += -align 4
84 else
85         PRELUDE = "$(METROWERKS)/Novell Support/libraries/runtime/prelude.obj"
86 #       CFLAGS += -include "$(METROWERKS)/Novell Support/headers/nlm_prefix.h"
87         CFLAGS += -align 1
88 endif
89 else
90 LD      = nlmconv
91 LDFLAGS = -T
92 AR      = ar
93 ARFLAGS = -cq
94 LIBEXT  = a
95 RANLIB  = ranlib
96 CFLAGS  += -fno-builtin -fpcc-struct-return -fno-strict-aliasing
97 CFLAGS  += -Wall -Wno-format -Wno-uninitialized # -pedantic
98 ifeq ($(LIBARCH),LIBC)
99         PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o
100 else
101         PRELUDE = $(SDK_CLIB)/imports/clibpre.gcc.o
102         CFLAGS += -include $(NDKBASE)/nlmconv/genlm.h
103 endif
104 endif
105
106 NDK_ROOT = $(NDKBASE)/ndk
107 SDK_CLIB = $(NDK_ROOT)/nwsdk
108 SDK_LIBC = $(NDK_ROOT)/libc
109
110 ifeq ($(LIBARCH),LIBC)
111         INCLUDES += -I$(SDK_LIBC)/include -I$(SDK_LIBC)/include/nks
112         # INCLUDES += -I$(SDK_LIBC)/include/winsock
113         CFLAGS += -D_POSIX_SOURCE
114 #       CFLAGS += -D__ANSIC__
115 else
116         INCLUDES += -I$(SDK_CLIB)/include/nlm -I$(SDK_CLIB)/include
117         # INCLUDES += -I$(SDK_CLIB)/include/nlm/obsolete
118         CFLAGS += -DNETDB_USE_INTERNET
119 endif
120 CFLAGS  += -I. $(INCLUDES)
121
122 ifeq ($(MTSAFE),YES)
123         XDCOPT = -n
124 endif
125 ifeq ($(MTSAFE),NO)
126         XDCOPT = -u
127 endif
128
129 ifeq ($(findstring linux,$(OSTYPE)),linux)
130 DL      = '
131 #-include $(NDKBASE)/nlmconv/ncpfs.inc
132 endif
133
134 # Makefile.inc provides the CSOURCES and HHEADERS defines
135 include Makefile.inc
136
137 OBJLIB  := $(patsubst %.c,$(OBJDIR)/%.o,$(strip $(CSOURCES)))
138 OBJEXE  = $(OBJLIB) $(OBJDIR)/ares_getopt.o  
139
140 .PHONY: lib nlm prebuild dist install clean
141
142 lib: prebuild $(LTARGET)
143
144 nlm: prebuild $(TARGETS) 
145
146 prebuild: $(OBJDIR) $(OBJDIR)/version.inc config.h arpa/nameser.h
147
148 dist: all
149         -$(RM) $(OBJLIB) $(OBJDIR)/*.map $(OBJDIR)/*.ncv
150         -$(RM) $(OBJDIR)/*.def $(OBJDIR)/*.xdc $(OBJDIR)/version.inc
151
152 install: $(INSTDIR) all
153         @$(CP) *.nlm $(INSTDIR)
154         @$(CP) ../CHANGES $(INSTDIR)
155         @$(CP) ../COPYING $(INSTDIR)
156         @$(CP) ../README $(INSTDIR)
157         @$(CP) ../RELEASE-NOTES $(INSTDIR)
158
159 clean:
160         -$(RM) $(LTARGET) $(TARGETS) config.h
161         -$(RM) -r $(OBJDIR)
162         -$(RM) -r arpa
163
164 %.$(LIBEXT): $(OBJLIB)
165         @echo Creating $@
166         @-$(RM) $@
167         @$(AR) $(ARFLAGS) $@ $^
168 ifdef RANLIB
169         @$(RANLIB) $@
170 endif
171
172 %.nlm: $(OBJDIR)/%.def $(OBJDIR)/%.o $(OBJDIR)/%.xdc $(OBJEXE)
173         @echo Linking $@
174         @-$(RM) $@
175         @$(LD) $(LDFLAGS) $<
176
177 $(INSTDIR):
178         @mkdir $(INSTDIR)
179
180 $(OBJDIR):
181         @mkdir $(OBJDIR)
182
183 $(OBJDIR)/%.o: %.c
184 #       @echo Compiling $<
185         $(CC) $(CFLAGS) -c $< -o $@
186
187 $(OBJDIR)/version.inc: ares_version.h $(OBJDIR)
188         @echo Creating $@
189         @awk -f ../packages/NetWare/get_ver.awk $< > $@
190
191 $(OBJDIR)/%.xdc: Makefile.netware
192         @echo Creating $@
193         @$(MPKXDC) $(XDCOPT) $@
194
195 $(OBJDIR)/%.def: Makefile.netware
196         @echo Creating $@
197         @echo $(DL)# DEF file for linking with $(LD)$(DL) > $@
198         @echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
199         @echo $(DL)# All your changes will be lost!!$(DL) >> $@
200         @echo $(DL)#$(DL) >> $@
201         @echo $(DL)copyright "$(COPYR)"$(DL) >> $@
202         @echo $(DL)description "$(DESCR)"$(DL) >> $@
203         @echo $(DL)version $(VERSION)$(DL) >> $@
204 ifdef NLMTYPE
205         @echo $(DL)type $(NLMTYPE)$(DL) >> $@
206 endif
207 ifdef STACK
208         @echo $(DL)stack $(STACK)$(DL) >> $@
209 endif
210 ifdef SCREEN
211         @echo $(DL)screenname "$(SCREEN)"$(DL) >> $@
212 else
213         @echo $(DL)screenname "DEFAULT"$(DL) >> $@
214 endif
215 ifeq ($(DB),DEBUG)
216         @echo $(DL)debug$(DL) >> $@
217 endif
218         @echo $(DL)threadname "$^"$(DL) >> $@
219 ifdef XDCOPT
220         @echo $(DL)xdcdata $(@:.def=.xdc)$(DL) >> $@
221 endif
222 ifeq ($(LDRING),0)
223         @echo $(DL)flag_on 16$(DL) >> $@
224 endif
225 ifeq ($(LDRING),3)
226         @echo $(DL)flag_on 512$(DL) >> $@
227 endif
228 ifeq ($(LIBARCH),CLIB)
229         @echo $(DL)start _Prelude$(DL) >> $@
230         @echo $(DL)exit _Stop$(DL) >> $@
231         @echo $(DL)import @$(SDK_CLIB)/imports/clib.imp$(DL) >> $@
232         @echo $(DL)import @$(SDK_CLIB)/imports/threads.imp$(DL) >> $@
233         @echo $(DL)import @$(SDK_CLIB)/imports/nlmlib.imp$(DL) >> $@
234         @echo $(DL)import @$(SDK_CLIB)/imports/socklib.imp$(DL) >> $@
235         @echo $(DL)module clib$(DL) >> $@
236 else
237         @echo $(DL)flag_on 64$(DL) >> $@
238         @echo $(DL)pseudopreemption$(DL) >> $@
239         @echo $(DL)start _LibCPrelude$(DL) >> $@
240         @echo $(DL)exit _LibCPostlude$(DL) >> $@
241         @echo $(DL)check _LibCCheckUnload$(DL) >> $@
242         @echo $(DL)import @$(SDK_LIBC)/imports/libc.imp$(DL) >> $@
243         @echo $(DL)import @$(SDK_LIBC)/imports/netware.imp$(DL) >> $@
244         @echo $(DL)module libc$(DL) >> $@
245 endif
246 ifdef MODULES
247         @echo $(DL)module $(MODULES)$(DL) >> $@
248 endif
249 ifdef EXPORTS
250         @echo $(DL)export $(EXPORTS)$(DL) >> $@
251 endif
252 ifdef IMPORTS
253         @echo $(DL)import $(IMPORTS)$(DL) >> $@
254 endif
255 ifeq ($(LD),nlmconv)
256         @echo $(DL)input $(OBJEXE)$(DL) >> $@
257         @echo $(DL)input $(PRELUDE)$(DL) >> $@
258         @echo $(DL)output $(notdir $(@:.def=.nlm))$(DL) >> $@
259 endif
260
261 config.h: Makefile.netware
262         @echo Creating $@
263         @echo $(DL)/* $@ for NetWare target.$(DL) > $@
264         @echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
265         @echo $(DL)** All your changes will be lost!!$(DL) >> $@
266         @echo $(DL)*/$(DL) >> $@
267         @echo $(DL)#ifndef NETWARE$(DL) >> $@
268         @echo $(DL)#error This $(notdir $@) is created for NetWare platform!$(DL) >> $@
269         @echo $(DL)#endif$(DL) >> $@
270         @echo $(DL)#define OS "i586-pc-NetWare"$(DL) >> $@
271         @echo $(DL)#define VERSION "$(LIBCARES_VERSION_STR)"$(DL) >> $@
272         @echo $(DL)#define PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/"$(DL) >> $@
273         @echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
274         @echo $(DL)#define HAVE_ARPA_NAMESER_H 1$(DL) >> $@
275         @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
276         @echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
277         @echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
278         @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
279         @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
280         @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
281         @echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
282         @echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
283         @echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
284         @echo $(DL)#define HAVE_INET_NTOA 1$(DL) >> $@
285         @echo $(DL)#define HAVE_INET_PTON 1$(DL) >> $@
286         @echo $(DL)#define HAVE_INTTYPES_H 1$(DL) >> $@
287         @echo $(DL)#define HAVE_LIMITS_H 1$(DL) >> $@
288         @echo $(DL)#define HAVE_LONGLONG 1$(DL) >> $@
289         @echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
290         @echo $(DL)#define HAVE_NETINET_IN_H 1$(DL) >> $@
291         @echo $(DL)#define HAVE_RECV 1$(DL) >> $@
292         @echo $(DL)#define HAVE_SELECT 1$(DL) >> $@
293         @echo $(DL)#define HAVE_SEND 1$(DL) >> $@
294         @echo $(DL)#define HAVE_SETJMP_H 1$(DL) >> $@
295         @echo $(DL)#define HAVE_SIGNAL 1$(DL) >> $@
296         @echo $(DL)#define HAVE_SIGNAL_H 1$(DL) >> $@
297         @echo $(DL)#define HAVE_SIG_ATOMIC_T 1$(DL) >> $@
298         @echo $(DL)#define HAVE_SOCKET 1$(DL) >> $@
299         @echo $(DL)#define HAVE_STDINT_H 1$(DL) >> $@
300         @echo $(DL)#define HAVE_STDLIB_H 1$(DL) >> $@
301         @echo $(DL)#define HAVE_STRCASECMP 1$(DL) >> $@
302         @echo $(DL)#define HAVE_STRDUP 1$(DL) >> $@
303         @echo $(DL)#define HAVE_STRFTIME 1$(DL) >> $@
304         @echo $(DL)#define HAVE_STRING_H 1$(DL) >> $@
305         @echo $(DL)#define HAVE_STRLCAT 1$(DL) >> $@
306         @echo $(DL)#define HAVE_STRLCPY 1$(DL) >> $@
307         @echo $(DL)#define HAVE_STRSTR 1$(DL) >> $@
308         @echo $(DL)#define HAVE_SYS_PARAM_H 1$(DL) >> $@
309         @echo $(DL)#define HAVE_SYS_SELECT_H 1$(DL) >> $@
310         @echo $(DL)#define HAVE_SYS_STAT_H 1$(DL) >> $@
311         @echo $(DL)#define HAVE_SYS_TIME_H 1$(DL) >> $@
312         @echo $(DL)#define HAVE_TERMIOS_H 1$(DL) >> $@
313         @echo $(DL)#define HAVE_TIME_H 1$(DL) >> $@
314         @echo $(DL)#define HAVE_UNAME 1$(DL) >> $@
315         @echo $(DL)#define HAVE_UNISTD_H 1$(DL) >> $@
316         @echo $(DL)#define RECV_TYPE_ARG1 int$(DL) >> $@
317         @echo $(DL)#define RECV_TYPE_ARG2 char *$(DL) >> $@
318         @echo $(DL)#define RECV_TYPE_ARG3 int$(DL) >> $@
319         @echo $(DL)#define RECV_TYPE_ARG4 int$(DL) >> $@
320         @echo $(DL)#define RECV_TYPE_RETV int$(DL) >> $@
321         @echo $(DL)#define RETSIGTYPE void$(DL) >> $@
322         @echo $(DL)#define SEND_QUAL_ARG2$(DL) >> $@
323         @echo $(DL)#define SEND_TYPE_ARG1 int$(DL) >> $@
324         @echo $(DL)#define SEND_TYPE_ARG2 char *$(DL) >> $@
325         @echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
326         @echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
327         @echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
328         @echo $(DL)#define SIZEOF_CURL_OFF_T 4$(DL) >> $@
329         @echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
330         @echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
331         @echo $(DL)#define HAVE_AF_INET6 1$(DL) >> $@
332         @echo $(DL)#define HAVE_PF_INET6 1$(DL) >> $@
333         @echo $(DL)#define HAVE_STRUCT_ADDRINFO 1$(DL) >> $@
334         @echo $(DL)#define HAVE_STRUCT_IN6_ADDR 1$(DL) >> $@
335         @echo $(DL)#define HAVE_STRUCT_SOCKADDR_IN6 1$(DL) >> $@
336         @echo $(DL)#define HAVE_STRUCT_TIMEVAL 1$(DL) >> $@
337         @echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
338         @echo $(DL)#define SIZEOF_STRUCT_IN_ADDR 4$(DL) >> $@
339 ifdef NW_WINSOCK
340         @echo $(DL)#define HAVE_CLOSESOCKET 1$(DL) >> $@
341 else
342         @echo $(DL)#define HAVE_SYS_TYPES_H 1$(DL) >> $@
343         @echo $(DL)#define HAVE_SYS_SOCKET_H 1$(DL) >> $@
344         @echo $(DL)#define HAVE_SYS_SOCKIO_H 1$(DL) >> $@
345         @echo $(DL)#define HAVE_NETDB_H 1$(DL) >> $@
346 endif
347         @echo $(DL)#ifdef __GNUC__$(DL) >> $@
348         @echo $(DL)#define HAVE_VARIADIC_MACROS_GCC 1$(DL) >> $@
349         @echo $(DL)#else$(DL) >> $@
350         @echo $(DL)#define HAVE_VARIADIC_MACROS_C99 1$(DL) >> $@
351         @echo $(DL)#endif$(DL) >> $@
352 ifdef OLD_NOVELLSDK
353         @echo $(DL)#define socklen_t int$(DL) >> $@
354 endif
355
356 arpa/nameser.h: nameser.h
357         @echo Fix missing header $@
358         @-mkdir arpa
359         @$(CP) $< arpa
360
361