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