More quoting for spacse in fnames
[yazpp-moved-to-github.git] / win / makefile
1 # Copyright (C) 1999-2006, Index Data ApS
2 # All rights reserved.
3 # $Id: makefile,v 1.18 2007-01-11 12:18:55 adam Exp $
4
5 # Parameters 
6
7 DEBUG=0   # 0 for release, 1 for debug
8
9 # YAZ
10 YAZ_DIR=..\..\yaz
11
12 default: all
13
14 all: dirs generated dll myclient zclient yaz
15
16 NSIS="c:\program files\nsis\makensis-bz2.exe"
17
18 nsis: all
19         $(NSIS) yazpp.nsi
20
21 nsishelp:
22         $(NSIS)
23
24 # Directories
25 # The current directory is supposed to be something like
26 # ..../yaz/win, everything is relative to that
27 ROOTDIR=..   # The home of yazpp
28
29 INCLDIR=$(ROOTDIR)\include  # our includes
30 LIBDIR=$(ROOTDIR)\lib       # We produce .lib, .exp etc there
31 BINDIR=$(ROOTDIR)\bin       # We produce exes and dlls there
32 WINDIR=$(ROOTDIR)\win       # all these Win make things
33 SRCDIR=$(ROOTDIR)\src       # for the case we move them under src
34 ZOOMDIR=$(ROOTDIR)\zoom
35
36 !if $(DEBUG)
37 OBJDIR=$(WINDIR)\dobj       # where we store intermediate files
38 !else
39 OBJDIR=$(WINDIR)\obj        # where we store intermediate files
40 !endif
41
42 TMPDIR=$(ROOTDIR)\win\tmp
43 TMP=$(TMPDIR)
44
45 # Targets - what to make
46
47 !if $(DEBUG)
48 YAZPP_DLL=$(BINDIR)\yazpp_1_d.dll
49 YAZPP_IMPLIB=$(LIBDIR)\yazpp_1_d.lib
50 YAZD=yazd
51 !else
52 YAZPP_DLL=$(BINDIR)\yazpp_1.dll
53 YAZPP_IMPLIB=$(LIBDIR)\yazpp_1.lib
54 YAZD=yaz
55 !endif
56
57 ZCLIENT=$(BINDIR)\zclient.exe
58 MY_CLIENT=$(BINDIR)\yaz-my-client.exe
59
60 # shortcut names defined here
61 dll: $(YAZPP_DLL)
62 zclient: $(ZCLIENT)
63 myclient: $(MY_CLIENT)
64
65 # Compiler and linker options 
66
67 # YAZ includes & libs
68 YAZ_LIB="$(YAZ_DIR)\lib\$(YAZD).lib"
69 YAZ_DEF=/I"$(YAZ_DIR)\include"
70 yaz: $(BINDIR)\$(YAZD).dll 
71
72 $(BINDIR)\$(YAZD).dll: "$(YAZ_DIR)\bin\$(YAZD).dll"
73   copy "$(YAZ_DIR)\bin\$(YAZD).dll" $(BINDIR)
74
75 COMMON_C_OPTIONS=          \
76   /nologo /W3 /EHsc /FD /c \
77   /D "_CRT_SECURE_NO_DEPRECATE" \
78   $(YAZ_DEF)               \
79   /D "_WINDOWS"            \
80   /D "WIN32"               \
81   /D "HAVE_WCHAR_H=1"      \
82   /FR"$(OBJDIR)\\"         \
83   /Fo"$(OBJDIR)\\"         \
84   /Fd"$(OBJDIR)\\" 
85
86 COMMON_C_INCLUDES= \
87   /I"$(ROOTDIR)\include"
88
89 DEBUG_C_OPTIONS=  \
90   /D "_DEBUG"      \
91   /MDd  /Od /Zi /Gm
92
93 RELEASE_C_OPTIONS=  \
94   /D "NDEBUG"        \
95   /MD /O2
96
97 # /W3  = warning level
98 # /GX  = Enable exception handling
99 # /FD  = Generate file dependencies (what ever they are)
100 # /c   = compile without linking
101 # /FR  = Generate browse info (.sbr file that gets combined into .bsc)
102 # /Fo  = object file name (or at least path)
103 # /Fd  = debug database name (or path)
104 # /MD  = Runtime library: Multithread DLL
105 # /MDd = Runtime library: Multithread DLL (debug)
106 # /Od  = Disable optimising (debug)
107 # /O2  = Optimize for speed
108 # /Gm  = Minimal rebuild (some cpp class stuff)
109 # /Zi  = Program database for debuggers
110 # /ZI  = Pgm database with special "edit&continue" stuff - not available in C5
111
112
113 ### Linker options
114 LINK=link.exe
115
116 LINK_LIBS= kernel32.lib user32.lib gdi32.lib advapi32.lib uuid.lib \
117            wsock32.lib  advapi32.lib \
118            $(YAZ_LIB)
119
120 COMMON_LNK_OPTIONS= /nologo /subsystem:windows /machine:i386 /incremental:no
121
122 DEBUG_LNK_OPTIONS= /debug 
123
124 RELEASE_LNK_OPTIONS=
125
126 DLL_LINK_OPTIONS= /dll  
127 CLIENT_LINK_OPTIONS = /subsystem:console  
128
129 # Final opt variables
130 !if $(DEBUG)
131 COPT=   $(COMMON_C_OPTIONS)   $(DEBUG_C_OPTIONS)     $(COMMON_C_INCLUDES)
132 RCOPT=  $(COMMON_RC_OPTIONS)  $(DEBUG_RC_OPTIONS)
133 LNKOPT= $(COMMON_LNK_OPTIONS) $(DEBUG_LNK_OPTIONS)   $(LNK_LIBS)
134
135 !else
136 COPT=   $(COMMON_C_OPTIONS)   $(RELEASE_C_OPTIONS)   $(COMMON_C_INCLUDES) 
137 RCOPT=  $(COMMON_RC_OPTIONS)  $(RELEASE_RC_OPTIONS)
138 LNKOPT= $(COMMON_LNK_OPTIONS) $(RELEASE_LNK_OPTIONS) $(LNK_LIBS)
139 !endif
140
141 # Source and object modules
142
143 YAZPP_DLL_OBJS = \
144    "$(OBJDIR)\gdu.obj" \
145    "$(OBJDIR)\gduqueue.obj" \
146    "$(OBJDIR)\pdu-observer.obj" \
147    "$(OBJDIR)\query.obj" \
148    "$(OBJDIR)\socket-observer.obj" \
149    "$(OBJDIR)\z-server.obj" \
150    "$(OBJDIR)\yaz-socket-manager.obj" \
151    "$(OBJDIR)\yaz-pdu-assoc.obj" \
152    "$(OBJDIR)\yaz-z-assoc.obj" \
153    "$(OBJDIR)\yaz-z-query.obj" \
154    "$(OBJDIR)\yaz-ir-assoc.obj" \
155    "$(OBJDIR)\yaz-z-server.obj" \
156    "$(OBJDIR)\yaz-pdu-assoc-thread.obj" \
157    "$(OBJDIR)\yaz-z-server-sr.obj" \
158    "$(OBJDIR)\yaz-z-server-ill.obj" \
159    "$(OBJDIR)\yaz-z-server-update.obj" \
160    "$(OBJDIR)\yaz-z-databases.obj" \
161    "$(OBJDIR)\yaz-z-cache.obj" \
162    "$(OBJDIR)\yaz-cql2rpn.obj" \
163    "$(OBJDIR)\zexcept.obj" \
164    "$(OBJDIR)\zconn.obj" \
165    "$(OBJDIR)\zquery.obj" \
166    "$(OBJDIR)\zrs.obj" \
167    "$(OBJDIR)\zrec.obj"
168
169 MY_CLIENT_OBJS = \
170    "$(OBJDIR)\yaz-my-client.obj"
171
172 ZCLIENT_OBJS = \
173    "$(OBJDIR)\zclient.obj"
174
175 # Note: This defines where to look for the necessary
176 # source files. Funny way of doing it, but it works.
177
178 {$(SRCDIR)}.cpp{$(OBJDIR)}.obj:
179         $(CPP) $(COPT) $< 
180
181 {$(ZOOMDIR)}.cpp{$(OBJDIR)}.obj:
182         $(CPP) $(COPT) $< 
183
184 ### The RC compiler (resource files)
185 RSC=rc.exe
186 COMMON_RC_OPTIONS= /l 0x406 /i"$(ROOTDIR)" 
187 DEBUG_RC_OPTIONS=/d "_DEBUG"
188 RELEASE_RC_OPTIONS=/d "NDEBUG"
189
190 !if $(DEBUG)
191 RSOPT=/d_DEBUG
192 !else
193 RSOPT=/d_NDEBUG
194 !endif
195
196 $(YAZPP_DLL) $(YAZPP_IMPLIB): "$(BINDIR)" $(YAZPP_DLL_OBJS)
197         $(LINK) \
198                 $(LNKOPT) \
199                 $(LINK_LIBS) \
200                 $(DLL_LINK_OPTIONS) \
201                 $(YAZPP_DLL_OBJS) \
202                 /out:"$(YAZPP_DLL)" \
203                 /implib:"$(YAZPP_IMPLIB)" 
204
205 $(MY_CLIENT) : "$(BINDIR)" $(MY_CLIENT_OBJS) $(YAZPP_IMPLIB)
206         $(LINK) \
207                 $(LNKOPT) \
208                 $(CLIENT_LINK_OPTIONS) \
209                 $(LINK_LIBS)  \
210                 $(YAZPP_IMPLIB) \
211                 $(MY_CLIENT_OBJS) \
212                 /out:$(MY_CLIENT)
213
214 $(ZCLIENT) : "$(BINDIR)" $(ZCLIENT_OBJS) $(YAZPP_IMPLIB)
215         $(LINK) \
216                 $(LNKOPT) \
217                 $(CLIENT_LINK_OPTIONS) \
218                 $(LINK_LIBS) \
219                 $(YAZPP_IMPLIB) \
220                 $(ZCLIENT_OBJS) \
221                 /out:$(ZCLIENT)
222
223 generated: $(ZOOMDIR)\zoom.h
224
225 "$(ZOOMDIR)\zoom.h": "$(ZOOMDIR)\master-header"
226         sed "s/^*       /       /; s/^*/ /" "$(ZOOMDIR)\master-header" >"$(ZOOMDIR)\zoom.h"
227
228 clean:
229         -del $(BINDIR)\*.exe
230         -del $(BINDIR)\*.dll
231         -del $(TMPDIR)\*.
232         -del $(LIBDIR)\*.LIB
233         -del $(OBJDIR)\*.OBJ
234
235 realclean: clean
236         -del $(ZOOMDIR)\zoom.h
237
238 dirs: $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR)
239
240 $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR):
241         if not exist "$@/$(NUL)" mkdir "$@"
242