aff8420d29fac026af95c663725aec2755613b4f
[yazproxy-moved-to-github.git] / win / makefile
1 # Copyright (C) 1998-2008 Index Data
2 # All rights reserved.
3
4 ###########################################################
5 ############### Parameters 
6 ###########################################################
7
8 DEBUG=0   # 0 for release, 1 for debug
9
10 # YAZ and YAZ++
11 YAZ_DIR=..\..\yaz
12 YAZPP_DIR=..\..\yazpp
13
14 # iconv charcter conversion utility
15 HAVE_ICONV=1
16 ICONV_DIR=\iconv-1.9.2.win32
17
18 # libxslt
19 HAVE_LIBXSLT=1
20 LIBXSLT_DIR=\libxslt-1.1.23+.win32
21
22 # libxml2 (used by libxslt)
23 HAVE_LIBXML2=1
24 LIBXML2_DIR=\libxml2-2.6.32+.win32
25
26 # zlib compression (used by libxml2)
27 ZLIB_DIR=\zlib-1.2.3.win32
28
29 # get WIN32 binaries for libxslt, libxml, iconv, zlib from here:
30 # http://www.zlatkovic.com/libxml.en.html
31
32 default: all
33
34 all: dirs dll proxy iconv libxml2 libxslt yaz yazpp
35
36 NSIS="c:\program files\nsis\makensis-bz2.exe"
37
38 nsis: all
39         $(NSIS) yazpp.nsi
40
41 nsishelp:
42         $(NSIS)
43
44 # The current directory is supposed to be something like
45 # ..../yaz/win, everything is relative to that
46 ROOTDIR=..   # The home of yaz++
47
48 INCLDIR=$(ROOTDIR)\include  # our includes
49 LIBDIR=$(ROOTDIR)\lib       # We produce .lib, .exp etc there
50 BINDIR=$(ROOTDIR)\bin       # We produce exes and dlls there
51 WINDIR=$(ROOTDIR)\win       # all these Win make things
52 SRCDIR=$(ROOTDIR)\src       # for the case we move them under src
53 PROXYDIR=$(ROOTDIR)\proxy
54 ZOOMDIR=$(ROOTDIR)\zoom
55
56 !if $(DEBUG)
57 OBJDIR=$(WINDIR)\dobj       # where we store intermediate files
58 !else
59 OBJDIR=$(WINDIR)\obj        # where we store intermediate files
60 !endif
61
62 TMPDIR=$(ROOTDIR)\win\tmp
63 TMP=$(TMPDIR)
64
65 YAZPROXY_DLL=$(BINDIR)\yazproxy2.dll
66 YAZPROXY_IMPLIB=$(LIBDIR)\yazproxy2.lib
67
68 YAZPROXY=$(BINDIR)\yazproxy.exe
69
70 # shortcut names defined here
71 dll: $(YAZPROXY_DLL)
72 proxy: $(YAZPROXY)
73
74 !if $(DEBUG)
75 YAZD=yaz3d
76 YAZPPD=yazpp3d
77 !else
78 YAZD=yaz3
79 YAZPPD=yazpp3
80 !endif
81
82 # YAZ includes & libs
83 YAZ_LIB="$(YAZ_DIR)\lib\$(YAZD).lib"
84 YAZ_DEF=/DYAZ_HAVE_XML2=1 /DYAZ_USE_NEW_LOG=1 /I"$(YAZ_DIR)\include"
85
86 # Copy yaz.dll to our bin
87 yaz: $(BINDIR)\$(YAZD).dll
88 $(BINDIR)\$(YAZD).dll: "$(YAZ_DIR)\bin\$(YAZD).dll"
89   copy "$(YAZ_DIR)\bin\$(YAZD).dll" $(BINDIR)
90
91 # YAZ++ includes & libs
92 YAZPP_LIB="$(YAZPP_DIR)\lib\$(YAZPPD).lib"
93 YAZPP_DEF=/I"$(YAZPP_DIR)\include"
94
95 # Copy yazpp.dll to our bin
96 yazpp: $(BINDIR)\$(YAZPPD).dll
97 $(BINDIR)\$(YAZPPD).dll: "$(YAZPP_DIR)\bin\$(YAZPPD).dll"
98   copy "$(YAZPP_DIR)\bin\$(YAZPPD).dll" $(BINDIR)
99
100 !if $(HAVE_ICONV)
101 ICONV_DEF= \
102   /D HAVE_ICONV_H=1 \
103   /I"$(ICONV_DIR)\include"
104 ICONV_LIB= \
105   "$(ICONV_DIR)\lib\iconv.lib"
106 iconv: $(BINDIR)\iconv.dll
107
108 $(BINDIR)\iconv.dll:
109   copy "$(ICONV_DIR)\bin\iconv.dll" $(BINDIR)
110 !else
111 ICONV_DEF= \
112   /D HAVE_ICONV_H=0
113 ICONV_LIB=
114 iconv:
115
116 !endif
117
118 !if $(HAVE_LIBXML2)
119 LIBXML2_LIB="$(LIBXML2_DIR)\lib\libxml2.lib"
120 LIBXML2_DEF=/D HAVE_XML2=1 /I"$(LIBXML2_DIR)\include"
121 libxml2: $(BINDIR)\libxml2.dll $(BINDIR)\zlib1.dll
122
123 $(BINDIR)\libxml2.dll:
124   copy "$(LIBXML2_DIR)\bin\libxml2.dll" $(BINDIR)
125
126 $(BINDIR)\zlib1.dll:
127   copy "$(ZLIB_DIR)\bin\zlib1.dll" $(BINDIR)
128
129 !else
130 LIBXML2_LIB=
131 LIBXML2_DEF=/D HAVE_XML2=0
132 libxml2: 
133
134 !endif
135
136 !if $(HAVE_LIBXSLT)
137 LIBXSLT_LIB="$(LIBXSLT_DIR)\lib\libxslt.lib"
138 LIBXSLT_DEF=/D YAZ_HAVE_XSLT=1 /I"$(LIBXSLT_DIR)\include"
139 libxslt: $(BINDIR)\libxslt.dll $(BINDIR)\zlib1.dll
140
141 $(BINDIR)\libxslt.dll:
142   copy "$(LIBXSLT_DIR)\bin\libxslt.dll" $(BINDIR)
143
144 !else
145 LIBXSLT_LIB=
146 LIBXSLT_DEF=/D YAZ_HAVE_XSLT=0
147 libxslt: 
148
149 !endif
150
151
152 ### C and CPP compiler  (the same thing)
153 # Note: $(CPP) has already been defined in the environment
154 # (if you set things up right!)
155
156 COMMON_C_OPTIONS=          \
157   /nologo /W3 /EHsc /FD /c \
158   /D "_CRT_SECURE_NO_DEPRECATE" \
159   $(ICONV_DEF)             \
160   $(YAZ_DEF)               \
161   $(YAZPP_DEF)             \
162   $(LIBXML2_DEF)           \
163   $(LIBXSLT_DEF)           \
164   /D "_WINDOWS"            \
165   /D "WIN32"               \
166   /D "HAVE_WCHAR_H=1"      \
167   /FR"$(OBJDIR)\\"         \
168   /Fo"$(OBJDIR)\\"         \
169   /Fd"$(OBJDIR)\\" 
170
171 COMMON_C_INCLUDES= \
172   /I"$(ROOTDIR)\include"
173
174 DEBUG_C_OPTIONS=  \
175   /D "_DEBUG"      \
176   /MDd  /Od /Zi /Gm
177
178 RELEASE_C_OPTIONS=  \
179   /D "NDEBUG"        \
180   /MD /O2
181
182 # /W3  = warning level
183 # /EHsc= Enable exception handling
184 # /FD  = Generate file dependencies (what ever they are)
185 # /c   = compile without linking
186 # /FR  = Generate browse info (.sbr file that gets combined into .bsc)
187 # /Fo  = object file name (or at least path)
188 # /Fd  = debug database name (or path)
189 # /MD  = Runtime library: Multithread DLL
190 # /MDd = Runtime library: Multithread DLL (debug)
191 # /Od  = Disable optimising (debug)
192 # /O2  = Optimize for speed
193 # /Gm  = Minimal rebuild (some cpp class stuff)
194 # /Zi  = Program database for debuggers
195 # /ZI  = Pgm database with special "edit&continue" stuff - not available in C5
196
197
198 ### Linker options
199 LINK=link.exe
200
201 LINK_LIBS=kernel32.lib advapi32.lib ws2_32.lib \
202            $(YAZ_LIB) $(YAZPP_LIB) $(ICONV_LIB) $(LIBXML2_LIB) $(LIBXSLT_LIB)
203
204 COMMON_LNK_OPTIONS=\
205                 /nologo \
206                 /subsystem:windows \
207                 /machine:i386 \
208                 /incremental:no
209
210 DEBUG_LNK_OPTIONS= /debug 
211
212 RELEASE_LNK_OPTIONS=
213
214 DLL_LINK_OPTIONS= /dll  
215 CLIENT_LINK_OPTIONS = /subsystem:console  
216
217 # Final opt variables
218 !if $(DEBUG)
219 COPT=   $(COMMON_C_OPTIONS)   $(DEBUG_C_OPTIONS)     $(COMMON_C_INCLUDES)
220 MTLOPT= $(COMMON_MTL_OPTIONS) $(DEBUG_MTL_OPTIONS)
221 RCOPT=  $(COMMON_RC_OPTIONS)  $(DEBUG_RC_OPTIONS)
222 LNKOPT= $(COMMON_LNK_OPTIONS) $(DEBUG_LNK_OPTIONS)   $(LNK_LIBS)
223 TCLOPT= $(COMMON_TCL_OPTIONS)
224
225 !else
226 COPT=   $(COMMON_C_OPTIONS)   $(RELEASE_C_OPTIONS)   $(COMMON_C_INCLUDES) 
227 MTLOPT= $(COMMON_MTL_OPTIONS) $(RELEASE_MTL_OPTIONS)
228 RCOPT=  $(COMMON_RC_OPTIONS)  $(RELEASE_RC_OPTIONS)
229 LNKOPT= $(COMMON_LNK_OPTIONS) $(RELEASE_LNK_OPTIONS) $(LNK_LIBS)
230 TCLOPT= $(COMMON_TCL_OPTIONS)
231 !endif
232
233 # Source and object modules
234
235 YAZPROXY_OBJS= \
236    "$(OBJDIR)\yaz-proxy-main.obj"
237
238 YAZPROXY_DLL_OBJS = \
239    "$(OBJDIR)\yaz-proxy.obj" \
240    "$(OBJDIR)\yaz-proxy-config.obj" \
241    "$(OBJDIR)\yaz-usemarcon.obj" \
242    "$(OBJDIR)\msg-thread.obj" \
243    "$(OBJDIR)\charset-converter.obj" \
244    "$(OBJDIR)\limit-connect.obj" \
245    "$(OBJDIR)\modules.obj" \
246    "$(OBJDIR)\yaz-bw.obj"
247
248 ###########################################################
249 ############### Compiling 
250 ###########################################################
251
252 # Note: This defines where to look for the necessary
253 # source files. Funny way of doing it, but it works.
254
255 {$(SRCDIR)}.cpp{$(OBJDIR)}.obj:
256         $(CPP) $(COPT) $< 
257
258 ###########################################################
259 ############### Resources
260 ###########################################################
261
262 ### The RC compiler (resource files)
263 RSC=rc.exe
264 COMMON_RC_OPTIONS= /l 0x406 /i"$(ROOTDIR)" 
265 DEBUG_RC_OPTIONS=/d "_DEBUG"
266 RELEASE_RC_OPTIONS=/d "NDEBUG"
267
268 !if $(DEBUG)
269 RSOPT=/d_DEBUG
270 !else
271 RSOPT=/d_NDEBUG
272 !endif
273
274 ###########################################################
275 ############### Linking
276 ###########################################################
277
278 $(YAZPROXY_DLL) $(YAZPROXY_IMPLIB): "$(BINDIR)" $(YAZPROXY_DLL_OBJS)
279         $(LINK) \
280                 $(LNKOPT)  \
281                 $(LINK_LIBS)  \
282                 $(DLL_LINK_OPTIONS) \
283                 $(YAZPP_IMPLIB) \
284                 $(YAZPROXY_DLL_OBJS) \
285                 /out:$(YAZPROXY_DLL)  \
286                 /implib:"$(YAZPROXY_IMPLIB)" \
287
288 $(YAZPROXY) : "$(BINDIR)" $(YAZPROXY_OBJS) $(YAZPROXY_IMPLIB)
289         $(LINK) \
290                 $(LNKOPT)  \
291                 $(CLIENT_LINK_OPTIONS) \
292                 $(LINK_LIBS)  \
293                 $(YAZPP_IMPLIB) \
294                 $(YAZPROXY_IMPLIB) \
295                 $(YAZPROXY_OBJS) \
296                 /out:$(YAZPROXY)
297
298 clean:
299         -del $(BINDIR)\*.exe
300         -del $(BINDIR)\*.dll
301         -del $(TMPDIR)\*.
302         -del $(LIBDIR)\*.LIB
303         -del $(OBJDIR)\*.OBJ
304
305 realclean: clean
306
307 ########### check directories and create if needed
308 dirs: $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR)
309
310 $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR):
311         if not exist "$@/$(NUL)" mkdir "$@"
312