Fix slashes while expanding path tokens
[heimdal.git] / windows / NTMakefile.w32
blob3da293f7fdf36cf81d2e2f4c1987ec76da608deb
1 ########################################################################
3 # Copyright (c) 2009, Secure Endpoints Inc.
4 # All rights reserved.
5
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9
10 # - Redistributions of source code must retain the above copyright
11 #   notice, this list of conditions and the following disclaimer.
12
13 # - Redistributions in binary form must reproduce the above copyright
14 #   notice, this list of conditions and the following disclaimer in
15 #   the documentation and/or other materials provided with the
16 #   distribution.
17
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
30
32 all::
34 clean::
36 test::
38 prep::
40 all:: prep
42 !include <Win32.Mak>
44 !ifdef NODEBUG
45 BUILD=rel
46 !else
47 BUILD=dbg
48 !endif
50 !if exist($(MAKEDIR)\windows\NTMakefile.w32)
51 SRC=$(MAKEDIR)
52 !elseif exist($(MAKEDIR)\..\windows\NTMakefile.w32)
53 SRC=$(MAKEDIR)\..
54 !elseif exist($(MAKEDIR)\..\..\windows\NTMakefile.w32)
55 SRC=$(MAKEDIR)\..\..
56 !else
57 !  error Cant determine source directory
58 !endif
60 !include "NTMakefile.config"
62 #----------------------------------------------------------------
63 # Directory macros
65 DESTDIR=$(SRC)\out32\dest_$(OUTDIR)
66 OBJDIR =$(SRC)\out32\obj_$(OUTDIR)
68 INCDIR =$(DESTDIR)\inc
69 LIBDIR =$(DESTDIR)\lib
70 BINDIR =$(DESTDIR)\bin
71 SBINDIR=$(BINDIR)
72 LIBEXECDIR=$(BINDIR)
74 !ifdef RELDIR
75 SRCDIR =$(SRC)\$(RELDIR)
76 OBJ    =$(OBJDIR)\$(RELDIR)
77 !else
78 OBJ    =$(OBJDIR)
79 !endif
81 # For tests:
82 PATH=$(PATH);$(BINDIR)
84 #----------------------------------------------------------------
85 # Command macros
87 RMAKE=nmake /nologo /f NTMakefile RECURSE=1
88 MKDIR=md
89 CP=copy /Y
90 LINK=link
91 LM=lib
92 RM=del /q
93 ECHO=echo
94 RC=rc
96 !ifndef AWK
97 AWK=gawk.exe
98 !endif
100 !ifndef YACC
101 YACC=bison.exe -y
102 !endif
104 !ifndef LEX
105 LEX=flex.exe
106 !endif
108 !ifndef PYTHON
109 PYTHON=python.exe
110 !endif
112 !ifndef PERL
113 PERL=perl.exe
114 !endif
116 !ifndef CMP
117 CMP=cmp.exe
118 !endif
120 # Only used for tests
121 !ifndef SH
122 SH=sh.exe
123 !endif
125 !ifndef SED
126 SED=sed.exe
127 !endif
129 #----------------------------------------------------------------
130 # External dependencies
132 # For pthread support to be enabled, both PTHREAD_INC and PTHREAD_LIB
133 # should be defined.  PTHREAD_INC should be the include directory
134 # where pthread.h is to be found (i.e. $(PTHREAD_INC)\pthread.h should
135 # exist), and PTHREAD_LIB is the full path to the pthread import
136 # library.
138 # Note that both paths should not contain any whitespace.
140 !ifdef PTHREAD_INC
141 pthreadinc= -I$(PTHREAD_INC)
142 !endif
144 #----------------------------------------------------------------
145 # Build options
147 cincdirs=$(cincdirs) -I$(INCDIR) -I$(INCDIR)\krb5 $(pthreadinc)
148 cdefines=$(cdefines) -DHAVE_CONFIG_H
149 cwarn=$(cwarn) -D_CRT_SECURE_NO_WARNINGS -wd4996
151 !if "$(CPU)"=="i386"
152 libmach=/machine:X86
153 !elseif "$(CPU)"=="AMD64"
154 libmach=/machine:X64
155 !else
156 !  error Unknown CPU value
157 !endif
159 !ifndef STATICRUNTIME
161 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsdll) $(AUXCFLAGS) $(cdefines) $(cincdirs) $(cwarn)
162 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsdll)
163 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsdll)
164 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsdll)
165 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsdll)
167 !else # STATICRUNTIME
169 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsmt) $(AUXCFLAGS) $(cdefines) $(cincdirs) $(cwarn)
170 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsmt)
171 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsmt)
172 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsmt)
173 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsmt)
175 !endif
177 LIBGUI_C = $(LM) /nologo $(libmach) /SUBSYSTEM:WINDOWS
178 LIBCON_C = $(LM) /nologo $(libmach) /SUBSYSTEM:CONSOLE
180 C2OBJ = $(C2OBJ_C) -Fo$@ -Fd$(@D)\ $**
181 EXECONLINK = $(EXECONLINK_C) -OUT:$@ $**
182 EXEGUILINK = $(EXEGUILINK_C) -OUT:$@ $**
183 DLLCONLINK = $(DLLCONLINK_C) -OUT:$@ $**
184 DLLGUILINK = $(DLLGUILINK_C) -OUT:$@ $**
185 LIBGUI = $(LIBGUI_C) /OUT:$@ $**
186 LIBCON = $(LIBCON_C) /OUT:$@ $**
188 # Preprocess files to stdout using config.h
189 CPREPROCESSOUT = $(CC) /EP /FI$(INCDIR)\config.h /TC /DCPP_ONLY=1
191 # Resources
193 RC2RES_C = $(RC) $(cincdirs) $(AUXRCFLAGS)
194 RC2RES = $(RC2RES_C) -fo $@ $**
196 #----------------------------------------------------------------------
197 # If this is the initial invocation, we check if all the build
198 # utilities are there.  Also show the commands macros.
200 !ifndef RECURSE
202 check-utils:
203         @for %%g in ( "$(AWK)" "$(YACC)" "$(LEX)" "$(PYTHON)" "$(PERL)" "$(CMP)" ) do @( \
204         for /f %%f in ( "%%g" ) do @( \
205                 if exist %%f @( \
206                         echo Found %%f \
207                 ) else if "%%~$$PATH:f"=="" @( \
208                         echo Could not find %%f in PATH && \
209                         exit /b 1 \
210                 ) else @( \
211                         echo Found %%~$$PATH:f \
212                 ) \
213         ) \
214         )
215         @for %%g in ( "$(SH)" "$(SED)" ) do @( \
216         for /f %%f in ( "%%g" ) do @( \
217                 if exist %%f @( \
218                         echo Found %%f \
219                 ) else if "%%~$$PATH:f"=="" @( \
220                         echo Could not find %%f in PATH && \
221                         echo Test targets may fail. \
222                 ) else @( \
223                         echo Found %%~$$PATH:f \
224                 ) \
225         ) \
226         )
229 prep:: check-utils
231 show-cmds:
232         @$(ECHO) C2OBJ=$(C2OBJ_C:\=\\)
233         @$(ECHO).
234         @$(ECHO) EXECONLINK=$(EXECONLINK_C)
235         @$(ECHO).
236         @$(ECHO) EXEGUILINK=$(EXEGUILINK_C)
237         @$(ECHO).
238         @$(ECHO) DLLCONLINK=$(DLLCONLINK_C)
239         @$(ECHO).
240         @$(ECHO) DLLGUILINK=$(DLLGUILINK_C)
241         @$(ECHO).
242         @$(ECHO) LIBGUI=$(LIBGUI_C)
243         @$(ECHO).
244         @$(ECHO) LIBCON=$(LIBCON_C)
246 prep:: show-cmds
248 !endif
250 {}.c{$(OBJ)}.obj:
251         $(C2OBJ)
253 {$(OBJ)}.c{$(OBJ)}.obj:
254         $(C2OBJ)
256 {}.cpp{$(OBJ)}.obj:
257         $(C2OBJ)
259 {$(OBJ)}.cpp{$(OBJ)}.obj:
260         $(C2OBJ)
262 {}.hin{$(INCDIR)}.h:
263         $(CP) $< $@
265 {}.h{$(INCDIR)}.h:
266         $(CP) $< $@
268 {}.h{$(INCDIR)\krb5}.h:
269         $(CP) $< $@
271 {$(OBJ)}.h{$(INCDIR)}.h:
272         $(CP) $< $@
274 {$(OBJ)}.x{$(OBJ)}.c:
275         $(CP) $< $@
277 {$(OBJ)}.hx{$(INCDIR)}.h:
278         $(CP) $< $@
280 {$(OBJ)}.hx{$(OBJ)}.h:
281         $(CP) $< $@
283 {}.rc{$(OBJ)}.res:
284         $(RC2RES)
286 #----------------------------------------------------------------------
287 # Announce the build directory
289 !ifdef RELDIR
290 all:: announce
292 test:: announce
294 clean:: announce
296 announce:
297         @echo.
298         @echo --------- Entering $(RELDIR:\= ):
299 !endif
301 #----------------------------------------------------------------------
302 # Create any required directories if they don't already exist
304 prep:: mkdirs
306 mkdirs:
307 !  if !exist($(OBJ))
308         $(MKDIR) $(OBJ)
309 !  endif
310 !  if !exist($(DESTDIR))
311         $(MKDIR) $(DESTDIR)
312 !  endif
313 !  if !exist($(LIBDIR))
314         $(MKDIR) $(LIBDIR)
315 !  endif
316 !  if !exist($(BINDIR))
317         $(MKDIR) $(BINDIR)
318 !  endif
319 !  if !exist($(INCDIR))
320         $(MKDIR) $(INCDIR)
321 !  endif
322 !  if !exist($(INCDIR)\gssapi)
323         $(MKDIR) $(INCDIR)\gssapi
324 !  endif
325 !  if !exist($(INCDIR)\hcrypto)
326         $(MKDIR) $(INCDIR)\hcrypto
327 !  endif
328 !  if !exist($(INCDIR)\kadm5)
329         $(MKDIR) $(INCDIR)\kadm5
330 !  endif
331 !  if !exist($(INCDIR)\krb5)
332         $(MKDIR) $(INCDIR)\krb5
333 !  endif
335 #----------------------------------------------------------------------
336 # If SUBDIRS is defined, we should recurse into the subdirectories
338 !ifdef SUBDIRS
339 subdirs:
340         @for %%f in ( $(SUBDIRS) ) do @ (cd %%f && $(RMAKE) && cd ..) || exit /b 1
342 clean-subdirs:
343         @for %%f in ( $(SUBDIRS) ) do @ (cd %%f && $(RMAKE) clean && cd ..) || exit /b 1
345 test-subdirs:
346         @for %%f in ( $(SUBDIRS) ) do @ (cd %%f && $(RMAKE) test && cd ..) || exit /b 1
348 all:: subdirs
350 clean:: clean-subdirs
352 test:: test-subdirs
354 !endif
356 #----------------------------------------------------------------------
357 # Clean targets
359 !ifdef CLEANFILES
360 clean::
361         -$(RM) $(CLEANFILES)
362 !endif
363 !ifdef RELDIR
364 clean::
365         -$(RM) $(OBJ)\*.*
366 !endif
368 .SUFFIXES: .c .cpp .hin .h .x .hx
370 #----------------------------------------------------------------------
371 # Manifest handling
373 # Starting with Visual Studio 8, the C compiler and the linker
374 # generate manifests so that the applications will link with the
375 # correct side-by-side DLLs at run-time.  These are required for
376 # correct operation under Windows XP and later.  We also have custom
377 # manifests which need to be merged with the manifests that VS
378 # creates.
380 # The syntax for invoking the _VC_MANIFEST_EMBED_FOO macro is:
381 # $(_VC_MANIFEST_EMBED_???) <additional manifests>
384 MT=mt.exe -nologo
386 _VC_MANIFEST_EMBED_EXE= \
387 if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest
389 _VC_MANIFEST_EMBED_DLL= \
390 if exist $@.manifest $(MT) -outputresource:$@;2 -manifest $@.manifest
392 # Note that if you are merging manifests, then the VS generated
393 # manifest should be cleaned up after calling _VC_MANIFEST_EMBED_???.
394 # This ensures that even if the DLL or EXE is executed in-place, the
395 # embedded manifest will be used.  Otherwise the $@.manifest file will
396 # be used.
398 _VC_MANIFEST_CLEAN= \
399 if exist $@.manifest $(RM) $@.manifest
401 # End of manifest handling
403 # Code signing
404 !ifdef CODESIGN
405 _CODESIGN=$(CODESIGN) $@
406 !else
407 _CODESIGN=
408 !endif
410 #----------------------------------------------------------------------
411 # Convenience macros for preparing EXEs and DLLs.  These are multiline
412 # macros that deal with manifests and code signing.  Unless we need to
413 # include custom manifests, these are what we should be using to
414 # prepare binaries.
416 EXEPREP=\
417 $(_VC_MANIFEST_EMBED_EXE)^
418 $(_VC_MANIFEST_CLEAN)^
419 $(_CODESIGN)
421 EXEPREP_NODIST=\
422 $(_VC_MANIFEST_EMBED_EXE)^
423 $(_VC_MANIFEST_CLEAN)
425 DLLPREP=\
426 $(_VC_MANIFEST_EMBED_DLL)^
427 $(_VC_MANIFEST_CLEAN)^
428 $(_CODESIGN)
430 DLLPREP_NODIST=\
431 $(_VC_MANIFEST_EMBED_DLL)^
432 $(_VC_MANIFEST_CLEAN)
434 #----------------------------------------------------------------------
435 # Convenience macros for import libraries
438 LIBROKEN    =$(LIBDIR)\libroken.lib
439 LIBVERS     =$(LIBDIR)\libvers.lib
440 LIBEDITLINE =$(LIBDIR)\libeditline.lib
441 LIBCOMERR   =$(LIBDIR)\libcom_err.lib
442 LIBSL       =$(LIBDIR)\libsl.lib
443 LIBWIND     =$(LIBDIR)\libwind.lib
444 LIBASN1     =$(LIBDIR)\libasn1.lib
445 LIBSQLITE   =$(LIBDIR)\libsqlite.lib
446 LIBHCRYPTO  =$(LIBDIR)\libhcrypto.lib
447 LIBHX509    =$(LIBDIR)\libhx509.lib
448 LIBKRB5     =$(LIBDIR)\libkrb5.lib
449 LIBHEIMNTLM =$(LIBDIR)\libheimntlm.lib
450 LIBHEIMIPCC =$(LIBDIR)\libheim-ipcc.lib
451 LIBHEIMIPCS =$(LIBDIR)\libheim-ipcs.lib
452 LIBGSSAPI   =$(LIBDIR)\libgssapi.lib
453 LIBHDB      =$(LIBDIR)\libhdb.lib
454 LIBKADM5SRV =$(LIBDIR)\libkadm5srv.lib
455 LIBKADM5CLNT=$(LIBDIR)\libkadm5clnt.lib
456 LIBKDC      =$(LIBDIR)\libkdc.lib