Mention 1.6.22 as release where ranking stuff was changed.
[pazpar2-moved-to-github.git] / win / makefile
1 # This file is part of Pazpar2.
2 # Copyright (C) 2006-2012 Index Data
3
4 DEBUG=0   # 0 for release, 1 for debug
5 USE_MANIFEST = 1 # Can be enabled Visual Studio 2005/2008
6 PACKAGE_NAME=pazpar2
7 PACKAGE_VERSION=1.6.21
8
9 # YAZ
10 YAZ_DIR=..\..\yaz
11
12 # Libxml2 + libxslt + associates
13 ZLIB_DIR=\zlib-1.2.3.win32
14 ICONV_DIR=\iconv-1.9.2.win32
15 LIBXML2_DIR=\libxml2-2.7.6.win32
16 LIBXSLT_DIR=\libxslt-1.1.26.win32
17
18 # ICU
19 HAVE_ICU=1
20 ICU_DIR=c:\icu
21
22 default: all
23
24 all: dirs yaz libxslt pazpar2
25
26 NSIS="c:\program files\nsis\makensis.exe"
27
28 dist: pazpar2.nsi
29         nmake DEBUG=1 clean
30         nmake DEBUG=0 clean
31         nmake DEBUG=0
32         $(NSIS) pazpar2.nsi
33
34 nsis: all
35         $(NSIS) pazpar2.nsi
36
37 nsishelp:
38         $(NSIS)
39
40 # Directories
41 ROOTDIR=..
42
43 BINDIR=$(ROOTDIR)\bin       # We produce exes and dlls there
44 WINDIR=$(ROOTDIR)\win       # all these Win make things
45 SRCDIR=$(ROOTDIR)\src       # for the case we move them under src
46
47 !if $(DEBUG)
48 OBJDIR=$(WINDIR)\dobj
49 !else
50 OBJDIR=$(WINDIR)\obj
51 !endif
52
53 TMPDIR=$(ROOTDIR)\win\tmp
54 TMP=$(TMPDIR)
55
56 PAZPAR2_EXE=$(BINDIR)\pazpar2.exe
57
58 pazpar2: $(PAZPAR2_EXE)
59
60 YAZBINDIR=$(YAZ_DIR)\bin
61 !if $(DEBUG)
62 YAZ_LIB="$(YAZ_DIR)\lib\yaz4d.lib" "$(YAZ_DIR)\lib\yaz_cond4d.lib" 
63 !if $(HAVE_ICU)
64 YAZ_LIB=$(YAZ_LIB) "$(YAZ_DIR)\lib\yaz_icu4d.lib"
65 !endif
66 YAZ_DLL_SOURCE="$(YAZBINDIR)\yaz4d.dll"
67 YAZ_DLL_TARGET="$(BINDIR)\yaz4d.dll"
68 !else
69 YAZ_LIB="$(YAZ_DIR)\lib\yaz4.lib" "$(YAZ_DIR)\lib\yaz_cond4.lib"
70 !if $(HAVE_ICU)
71 YAZ_LIB=$(YAZ_LIB) "$(YAZ_DIR)\lib\yaz_icu4.lib"
72 !endif
73 YAZ_DLL_SOURCE="$(YAZBINDIR)\yaz4.dll"
74 YAZ_DLL_TARGET="$(BINDIR)\yaz4.dll"
75 !endif
76
77 YAZ_DEF=/DYAZ_HAVE_XML2=2 /DYAZ_HAVE_XSLT=1 /I"$(YAZ_DIR)\include"
78
79 # Copy libxslt and associates to our bin directory
80 libxslt: $(BINDIR)\libxslt.dll
81
82 $(BINDIR)\libxslt.dll: "$(LIBXSLT_DIR)\bin\libxslt.dll"
83         copy "$(ICONV_DIR)\bin\iconv.dll" $(BINDIR)
84         copy "$(ZLIB_DIR)\bin\zlib1.dll" $(BINDIR)
85         copy "$(LIBXML2_DIR)\bin\libxml2.dll" $(BINDIR)
86         copy "$(LIBXSLT_DIR)\bin\libxslt.dll" $(BINDIR)
87
88
89 LIBXSLT_DEF= \
90             /I"$(ICONV_DIR)\include" \
91             /I"$(LIBXML2_DIR)\include" \
92             /I"$(LIBXSLT_DIR)\include"
93
94 LIBXSLT_LIB = \
95            "$(ICONV_DIR)\lib\iconv.lib" \
96            "$(LIBXML2_DIR)\lib\libxml2.lib" \
97            "$(LIBXSLT_DIR)\lib\libxslt.lib"
98
99 !if $(HAVE_ICU)
100 ICU_DEF=/DYAZ_HAVE_ICU=1 /I"$(ICU_DIR)\include"
101 ICU_LIB= $(ICU_DIR)\lib\icudt.lib \
102          $(ICU_DIR)\lib\icuin.lib \
103          $(ICU_DIR)\lib\icuuc.lib
104 !else
105 ICU_DEF=/DYAZ_HAVE_ICU=0
106 ICU_LIB=
107 !endif
108
109 COMMON_C_OPTIONS=          \
110   /nologo /W3 /EHsc /FD /c \
111   /D "_CRT_SECURE_NO_DEPRECATE" \
112   /D "PACKAGE_VERSION=\"$(PACKAGE_VERSION)\"" \
113   /D "PACKAGE_NAME=\"$(PACKAGE_NAME)\"" \
114   /D "VERSION=\"$(PACKAGE_VERSION)\"" \
115   $(YAZ_DEF)               \
116   $(ICU_DEF)               \
117   $(LIBXSLT_DEF)           \
118   /D "_WINDOWS"            \
119   /D "WIN32"               \
120   /D "HAVE_WCHAR_H=1"      \
121   /FR"$(OBJDIR)\\"         \
122   /Fo"$(OBJDIR)\\"         \
123   /Fd"$(OBJDIR)\\" 
124
125 COMMON_C_INCLUDES= \
126   /I"$(ROOTDIR)\include"
127
128 DEBUG_C_OPTIONS=  \
129   /D "_DEBUG"      \
130   /MDd  /Od /Zi /Gm
131
132 RELEASE_C_OPTIONS=  \
133   /D "NDEBUG"        \
134   /MD /O2
135
136 # /W3  = warning level
137 # /GX  = Enable exception handling
138 # /FD  = Generate file dependencies (what ever they are)
139 # /c   = compile without linking
140 # /FR  = Generate browse info (.sbr file that gets combined into .bsc)
141 # /Fo  = object file name (or at least path)
142 # /Fd  = debug database name (or path)
143 # /MD  = Runtime library: Multithread DLL
144 # /MDd = Runtime library: Multithread DLL (debug)
145 # /Od  = Disable optimising (debug)
146 # /O2  = Optimize for speed
147 # /Gm  = Minimal rebuild (some cpp class stuff)
148 # /Zi  = Program database for debuggers
149 # /ZI  = Pgm database with special "edit&continue" stuff - not available in C5
150
151
152 ### Linker options
153 LINK=link.exe
154
155 LINK_LIBS= kernel32.lib ws2_32.lib advapi32.lib \
156            $(YAZ_LIB) $(ICU_LIB) $(LIBXSLT_LIB)
157
158 COMMON_LNK_OPTIONS= /nologo /subsystem:windows /machine:i386 /incremental:no
159
160 DEBUG_LNK_OPTIONS= /debug 
161
162 RELEASE_LNK_OPTIONS=
163
164 CLIENT_LINK_OPTIONS = /subsystem:console  
165
166 # Final opt variables
167 !if $(DEBUG)
168 COPT=   $(COMMON_C_OPTIONS)   $(DEBUG_C_OPTIONS)     $(COMMON_C_INCLUDES)
169 RCOPT=  $(COMMON_RC_OPTIONS)  $(DEBUG_RC_OPTIONS)
170 LNKOPT= $(COMMON_LNK_OPTIONS) $(DEBUG_LNK_OPTIONS)   $(LNK_LIBS)
171
172 !else
173 COPT=   $(COMMON_C_OPTIONS)   $(RELEASE_C_OPTIONS)   $(COMMON_C_INCLUDES) 
174 RCOPT=  $(COMMON_RC_OPTIONS)  $(RELEASE_RC_OPTIONS)
175 LNKOPT= $(COMMON_LNK_OPTIONS) $(RELEASE_LNK_OPTIONS) $(LNK_LIBS)
176 !endif
177
178 # Source and object modules
179
180 PAZPAR2_OBJS = \
181    "$(OBJDIR)\getaddrinfo.obj" \
182    "$(OBJDIR)\host.obj" \
183    "$(OBJDIR)\pazpar2.obj" \
184    "$(OBJDIR)\pazpar2_config.obj" \
185    "$(OBJDIR)\http.obj" \
186    "$(OBJDIR)\eventl.obj" \
187    "$(OBJDIR)\http_command.obj" \
188    "$(OBJDIR)\session.obj" \
189    "$(OBJDIR)\record.obj" \
190    "$(OBJDIR)\reclists.obj" \
191    "$(OBJDIR)\relevance.obj" \
192    "$(OBJDIR)\termlists.obj" \
193    "$(OBJDIR)\normalize7bit.obj" \
194    "$(OBJDIR)\database.obj" \
195    "$(OBJDIR)\settings.obj" \
196    "$(OBJDIR)\charsets.obj" \
197    "$(OBJDIR)\client.obj" \
198    "$(OBJDIR)\jenkins_hash.obj" \
199    "$(OBJDIR)\marcmap.obj" \
200    "$(OBJDIR)\marchash.obj" \
201    "$(OBJDIR)\normalize_record.obj" \
202    "$(OBJDIR)\normalize_cache.obj" \
203    "$(OBJDIR)\ppmutex.obj" \
204    "$(OBJDIR)\incref.obj" \
205    "$(OBJDIR)\sel_thread.obj" \
206    "$(OBJDIR)\service_xslt.obj" \
207    "$(OBJDIR)\connection.obj"  \
208    "$(OBJDIR)\facet_limit.obj" 
209
210
211 {$(SRCDIR)}.c{$(OBJDIR)}.obj:
212         $(CPP) $(COPT) $< 
213
214
215 !if $(USE_MANIFEST)
216 MT=mt.exe /nologo
217 !else
218 MT=echo
219 !endif
220
221
222 LINK_PROGRAM = $(LINK) $(LNKOPT) $(CLIENT_LINK_OPTIONS) $(LINK_LIBS)
223
224
225 $(PAZPAR2_EXE) : "$(BINDIR)" $(PAZPAR2_OBJS) $(YAZ_LIB)
226         $(LINK_PROGRAM) $(PAZPAR2_OBJS) /out:$@
227         $(MT) -manifest $@.manifest -outputresource:$@;1
228
229 clean:
230         -del $(BINDIR)\*.exe
231         -del $(TMPDIR)\*.
232         -del $(OBJDIR)\*.OBJ
233
234 dirs: $(OBJDIR) $(WINDIR) $(BINDIR) $(TMPDIR)
235
236 $(OBJDIR) $(WINDIR) $(BINDIR) $(TMPDIR):
237         if not exist "$@/$(NUL)" mkdir "$@"
238
239 yaz: $(YAZ_DLL_TARGET)
240
241 $(YAZ_DLL_TARGET) : $(YAZ_DLL_SOURCE)
242 #       copy "$(YAZBINDIR)\*.dll.manifest" $(BINDIR)
243         copy "$(YAZBINDIR)\*.dll" $(BINDIR)
244