remove trailing whitespace
[heimdal.git] / windows / NTMakefile.w32
blobb5cff7f6c3c0b3fc1114931ab916020f2207626e
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 !elseif exist($(MAKEDIR)\..\..\..\windows\NTMakefile.w32)
57 SRC=$(MAKEDIR)\..\..\..
58 !else
59 !  error Cant determine source directory
60 !endif
62 !  if "$(CPU)"=="i386" || "$(CPU)"=="x86"
63 MCPU=x86
64 !  elseif "$(CPU)"=="AMD64"
65 MCPU=amd64
66 !  else
67 !    error Unknown CPU
68 !  endif
70 !include "NTMakefile.config"
72 #----------------------------------------------------------------
73 # Directory macros
75 DESTDIR         =$(SRC)\out\dest_$(CPU)
76 OBJDIR          =$(SRC)\out\obj_$(CPU)
78 INCDIR          =$(DESTDIR)\inc
79 LIBDIR          =$(DESTDIR)\lib
80 BINDIR          =$(DESTDIR)\bin
81 PLUGINDIR       =$(BINDIR)\plugin\krb5
82 DOCDIR          =$(DESTDIR)\doc
83 SBINDIR         =$(BINDIR)
84 LIBEXECDIR      =$(BINDIR)
85 ASMDIR          =$(BINDIR)
86 INSTDIR         =$(DESTDIR)\install
87 SDKDIR          =$(SRC)\out\sdk
88 SDKINCDIR       =$(SDKDIR)\inc
89 SDKLIBDIR       =$(SDKDIR)\lib\$(CPU)
90 SDKSRCDIR       =$(SDKDIR)\src
91 SDKREDISTDIR    =$(SDKDIR)\redist\$(CPU)
93 !ifdef RELDIR
94 SRCDIR =$(SRC)\$(RELDIR)
95 OBJ    =$(OBJDIR)\$(RELDIR)
96 !else
97 OBJ    =$(OBJDIR)
98 !endif
100 # For tests:
101 PATH=$(PATH);$(BINDIR)
103 #----------------------------------------------------------------
104 # Command macros
106 RMAKE=nmake /nologo /f NTMakefile RECURSE=1
107 MKDIR=md
108 CP=copy /Y
109 LINK=link
110 LM=lib
111 RM=del /q
112 ECHO=echo
113 RC=rc
115 #----------------------------------------------------------------
116 # Program macros
118 AWK_CMD=gawk.exe
119 YACC_CMD=bison.exe
120 LEX_CMD=flex.exe
121 PYTHON=python.exe
122 PERL=perl.exe
123 CMP=cmp.exe
124 SIGNTOOL=signtool.exe
125 MAKECAT=makecat.exe
126 HHC=hhc.exe
127 MAKEINFO=makeinfo.exe
128 SED=sed.exe
130 CANDLE_CMD=candle.exe
131 LIGHT_CMD=light.exe
133 # Only used for tests
134 SH=sh.exe
136 # Commands
137 AWK=$(AWK_CMD)
138 YACC=$(YACC_CMD) -y
139 LEX=$(LEX_CMD)
140 CANDLE=$(CANDLE_CMD) -nologo
141 LIGHT=$(LIGHT_CMD) -nologo
143 #----------------------------------------------------------------
144 # External dependencies
146 # For pthread support to be enabled, both PTHREAD_INC and PTHREAD_LIB
147 # should be defined.  PTHREAD_INC should be the include directory
148 # where pthread.h is to be found (i.e. $(PTHREAD_INC)\pthread.h should
149 # exist), and PTHREAD_LIB is the full path to the pthread import
150 # library.
152 # Note that both paths should not contain any whitespace.
154 !ifdef PTHREAD_INC
155 pthreadinc= -I$(PTHREAD_INC)
156 !endif
158 #----------------------------------------------------------------
159 # Build options
161 cincdirs=$(cincdirs) -I$(INCDIR) -I$(INCDIR)\krb5 $(pthreadinc)
162 cdefines=$(cdefines) -DHAVE_CONFIG_H
163 cdebug=$(cdebug) /Zi
164 ldebug=$(ldebug) /DEBUG
166 # ---------------------------------------------------------------
167 # time_t issues
169 !if "$(MCPU)"=="x86"
170 cdefines=$(cdefines) -D_USE_32BIT_TIME_T
171 !endif
173 # Disable warnings:
175 # C4996: 'function' was declared deprecated
176 # C4127: Conditional expression is constant
177 # C4244: Conversion from 'type1' to 'type2', possible loss of data
178 # C4100: 'identifier': unreferenced formal parameter
179 # C4706: Assignment within conditional expression
180 # C4214: Nonstandard extension used
181 # C4267: '': Conversion from 'type1' to 'type2', possible loss of data
182 # C4018: '': Signed/unsigned mismatch
183 # C4204: Nonstandard extension used: non-constant aggregate initializer
184 # C4221: Nonstandard extension used: 'v1': cannot be initialized using address of automatic variable 'v2'
185 # C4295: '': Array is too small to include a terminating null character
186 # C4146: Unary minus operator applied to unsigned type, result still unsigned.
188 cwarn=$(cwarn) -D_CRT_SECURE_NO_WARNINGS -wd4996 -wd4127 -wd4244 -wd4100 -wd4706
189 cwarn=$(cwarn) -wd4214 -wd4267 -wd4018 -wd4389 -wd4204 -wd4221 -wd4295 -wd4146
191 !if "$(CPU)"=="i386"
192 libmach=/machine:X86
193 !elseif "$(CPU)"=="AMD64"
194 libmach=/machine:X64
195 !else
196 !  error Unknown CPU value
197 !endif
199 !ifdef NO_MP
200 MPOPT=
201 !else
202 MPOPT=/MP
203 !endif
205 !ifndef STATICRUNTIME
207 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsdll) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
208 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsdll) $(libmach)
209 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsdll) $(libmach)
210 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsdll) $(libmach)
211 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsdll) $(libmach)
213 !else # STATICRUNTIME
215 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsmt) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
216 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsmt) $(libmach)
217 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsmt) $(libmach)
218 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsmt) $(libmach)
219 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsmt) $(libmach)
221 !endif
223 LIBGUI_C = $(LM) /nologo $(libmach) /SUBSYSTEM:WINDOWS
224 LIBCON_C = $(LM) /nologo $(libmach) /SUBSYSTEM:CONSOLE
226 C2OBJ = $(C2OBJ_C) -Fo$@ -Fd$(@D)\ $**
227 C2OBJ_NP = $(C2OBJ_C) $(MPOPT) $<
228 C2OBJ_P = $(C2OBJ_NP) -Fo$(OBJ)\ -Fd$(OBJ)\ #
229 EXECONLINK = $(EXECONLINK_C) -OUT:$@ $**
230 EXEGUILINK = $(EXEGUILINK_C) -OUT:$@ $**
231 DLLCONLINK = $(DLLCONLINK_C) -OUT:$@ $**
232 DLLGUILINK = $(DLLGUILINK_C) -OUT:$@ $**
233 LIBGUI = $(LIBGUI_C) /OUT:$@ $**
234 LIBCON = $(LIBCON_C) /OUT:$@ $**
236 # Preprocess files to stdout using config.h
237 CPREPROCESSOUT = $(CC) /EP /FI$(INCDIR)\config.h /TC /DCPP_ONLY=1
239 # Resources
241 RC2RES_C = $(RC) $(cincdirs) $(AUXRCFLAGS)
242 RC2RES = $(RC2RES_C) -fo $@ $**
244 #----------------------------------------------------------------------
245 # If this is the initial invocation, we check if all the build
246 # utilities are there.  Also show the commands macros.
248 !ifndef RECURSE
250 REQUIRED_TOOLS= \
251         "$(AWK_CMD)" "$(YACC_CMD)" "$(LEX_CMD)" "$(PYTHON)" "$(PERL)" \
252         "$(CMP)" "$(SED)" "$(SIGNTOOL)" "$(MAKECAT)" "$(MAKEINFO)" "$(HHC)"
254 !ifdef BUILD_INSTALLERS
255 REQUIRED_TOOLS=$(REQUIRED_TOOLS) "$(CANDLE_CMD)" "$(LIGHT_CMD)"
256 !endif
258 OPTIONAL_TOOLS="$(SH)" 
260 check-utils:
261         @for %%g in ( $(REQUIRED_TOOLS) ) do @( \
262         for /f %%f in ( "%%g" ) do @( \
263                 if exist %%f @( \
264                         echo Found %%f \
265                 ) else if "%%~$$PATH:f"=="" @( \
266                         echo Could not find %%f in PATH && \
267                         exit /b 1 \
268                 ) else @( \
269                         echo Found %%~$$PATH:f \
270                 ) \
271         ) \
272         )
273         @for %%g in ( $(OPTIONAL_TOOLS) ) do @( \
274         for /f %%f in ( "%%g" ) do @( \
275                 if exist %%f @( \
276                         echo Found %%f \
277                 ) else if "%%~$$PATH:f"=="" @( \
278                         echo Could not find %%f in PATH && \
279                         echo Optional targets may fail. \
280                 ) else @( \
281                         echo Found %%~$$PATH:f \
282                 ) \
283         ) \
284         )
287 prep:: check-utils
289 show-cmds:
290         @$(ECHO) C2OBJ=$(C2OBJ_C:\=\\)
291         @$(ECHO).
292         @$(ECHO) EXECONLINK=$(EXECONLINK_C)
293         @$(ECHO).
294         @$(ECHO) EXEGUILINK=$(EXEGUILINK_C)
295         @$(ECHO).
296         @$(ECHO) DLLCONLINK=$(DLLCONLINK_C)
297         @$(ECHO).
298         @$(ECHO) DLLGUILINK=$(DLLGUILINK_C)
299         @$(ECHO).
300         @$(ECHO) LIBGUI=$(LIBGUI_C)
301         @$(ECHO).
302         @$(ECHO) LIBCON=$(LIBCON_C)
304 prep:: show-cmds
306 !endif                          # RECURSE
308 {}.c{$(OBJ)}.obj::
309         $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(localcflags) $(MPOPT) @<<
313 {$(OBJ)}.c{$(OBJ)}.obj::
314         $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(extcflags) $(MPOPT) @<<
318 {}.cpp{$(OBJ)}.obj::
319         $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(localcflags) $(MPOPT) @<<
323 {$(OBJ)}.cpp{$(OBJ)}.obj::
324         $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(extcflags) $(MPOPT) @<<
328 {}.hin{$(INCDIR)}.h:
329         $(CP) $< $@
331 {}.h{$(INCDIR)}.h:
332         $(CP) $< $@
334 {}.h{$(INCDIR)\krb5}.h:
335         $(CP) $< $@
337 {$(OBJ)}.h{$(INCDIR)}.h:
338         $(CP) $< $@
340 {$(OBJ)}.x{$(OBJ)}.c:
341         $(CP) $< $@
343 {$(OBJ)}.hx{$(INCDIR)}.h:
344         $(CP) $< $@
346 {$(OBJ)}.hx{$(OBJ)}.h:
347         $(CP) $< $@
349 {}.rc{$(OBJ)}.res:
350         $(RC2RES)
352 #----------------------------------------------------------------------
353 # Announce the build directory
355 !ifdef RELDIR
356 all:: announce
358 all-tools:: announce-tools
360 test:: announce
362 clean:: announce
364 announce:
365         @echo.
366         @echo --------- Entering $(RELDIR:\= ):
368 announce-tools:
369         @echo.
370         @echo --------- Entering $(RELDIR:\= ) tools:
371 !endif
373 #----------------------------------------------------------------------
374 # Create any required directories if they don't already exist
376 prep:: mkdirs
378 mkdirs:
379 !  if !exist($(OBJ))
380         $(MKDIR) $(OBJ)
381 !  endif
382 !  if !exist($(DESTDIR))
383         $(MKDIR) $(DESTDIR)
384 !  endif
385 !  if !exist($(LIBDIR))
386         $(MKDIR) $(LIBDIR)
387 !  endif
388 !  if !exist($(BINDIR))
389         $(MKDIR) $(BINDIR)
390 !  endif
391 !  if !exist($(PLUGINDIR))
392         $(MKDIR) $(PLUGINDIR)
393 !  endif
394 !  if !exist($(INCDIR))
395         $(MKDIR) $(INCDIR)
396 !  endif
397 !  if !exist($(DOCDIR))
398         $(MKDIR) $(DOCDIR)
399 !  endif
400 !  if !exist($(INCDIR)\gssapi)
401         $(MKDIR) $(INCDIR)\gssapi
402 !  endif
403 !  if !exist($(INCDIR)\hcrypto)
404         $(MKDIR) $(INCDIR)\hcrypto
405 !  endif
406 !  if !exist($(INCDIR)\kadm5)
407         $(MKDIR) $(INCDIR)\kadm5
408 !  endif
409 !  if !exist($(INCDIR)\krb5)
410         $(MKDIR) $(INCDIR)\krb5
411 !  endif
413 #----------------------------------------------------------------------
414 # If SUBDIRS is defined, we should recurse into the subdirectories
416 !ifdef SUBDIRS
417 subdirs:
418         @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) && popd) || exit /b 1
420 clean-subdirs:
421         @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) clean && popd) || exit /b 1
423 test-subdirs:
424         @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) test && popd) || exit /b 1
426 all:: subdirs
428 clean:: clean-subdirs
430 test:: test-subdirs
432 !endif
434 #----------------------------------------------------------------------
435 # Clean targets
437 !ifdef CLEANFILES
438 clean::
439         -$(RM) $(CLEANFILES)
440 !endif
441 !ifdef RELDIR
442 clean::
443         -$(RM) $(OBJ)\*.*
444 !endif
446 .SUFFIXES: .c .cpp .hin .h .x .hx
448 #----------------------------------------------------------------------
449 # Manifest handling
451 # Starting with Visual Studio 8, the C compiler and the linker
452 # generate manifests so that the applications will link with the
453 # correct side-by-side DLLs at run-time.  These are required for
454 # correct operation under Windows XP and later.  We also have custom
455 # manifests which need to be merged with the manifests that VS
456 # creates.
458 # The syntax for invoking the _VC_MANIFEST_EMBED_FOO macro is:
459 # $(_VC_MANIFEST_EMBED_???) <additional manifests>
462 MT=mt.exe -nologo
464 _VC_MANIFEST_EMBED_EXE= \
465 ( if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest $(APPMANIFEST) )
467 _VC_MANIFEST_EMBED_EXE_NOHEIM= \
468 ( if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest )
470 _VC_MANIFEST_EMBED_DLL= \
471 ( if exist $@.manifest $(MT) -outputresource:$@;2 -manifest $@.manifest )
473 _MERGE_MANIFEST_DLL= \
474 ( $(MT) -inputresource:$@;2 -manifest $(APPMANIFEST) -outputresource:$@;2 )
476 _INSERT_APPMANIFEST_DLL= \
477 ( $(MT) -manifest $(APPMANIFEST) -outputresource:$@;2 )
479 # Note that if you are merging manifests, then the VS generated
480 # manifest should be cleaned up after calling _VC_MANIFEST_EMBED_???.
481 # This ensures that even if the DLL or EXE is executed in-place, the
482 # embedded manifest will be used.  Otherwise the $@.manifest file will
483 # be used.
485 _VC_MANIFEST_CLEAN= \
486 ( if exist $@.manifest $(RM) $@.manifest )
488 # End of manifest handling
490 #----------------------------------------------------------------------
491 # Code and assembly signing
493 # SIGNTOOL_C is any set of options required for certificate/private
494 # key selection for code signging.
496 # SIGNTOOL_O is any set of additional options to signtool.exe
498 # SIGNTOOL_T is the timestamp option
500 !ifdef CODESIGN
501 _CODESIGN=( $(CODESIGN) $@ )
502 !else
504 !ifdef SIGNTOOL_C
506 !ifndef SIGNTOOL_T
507 SIGNTOOL_T=/t http://timestamp.verisign.com/scripts/timstamp.dll
508 !endif
510 _CODESIGN=( $(SIGNTOOL) sign $(SIGNTOOL_O) $(SIGNTOOL_T) $(SIGNTOOL_C) /v $@ )
511 !else
512 _CODESIGN=( echo Skipping code sign )
513 !endif
515 !endif
517 #----------------------------------------------------------------------
518 # Convenience macros for preparing EXEs and DLLs.  These are multiline
519 # macros that deal with manifests and code signing.  Unless we need to
520 # include custom manifests, these are what we should be using to
521 # prepare binaries.
523 EXEPREP=\
524 ( $(_VC_MANIFEST_EMBED_EXE) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
526 EXEPREP_NOHEIM=\
527 ( $(_VC_MANIFEST_EMBED_EXE_NOHEIM) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
529 EXEPREP_NODIST=\
530 ( $(_VC_MANIFEST_EMBED_EXE_NOHEIM) && $(_VC_MANIFEST_CLEAN) ) || ( $(RM) $@ && exit /b 1 )
532 DLLPREP=\
533 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
535 DLLPREP_NODIST=\
536 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) ) || ( $(RM) $@ && exit /b 1 )
538 DLLPREP_MERGE=\
539 ( ( $(_MERGE_MANIFEST_DLL) || $(_INSERT_APPMANIFEST_DLL) ) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
541 #----------------------------------------------------------------------
542 # Convenience macros for import libraries and assemblies
545 LIBASN1     =$(LIBDIR)\libasn1.lib
546 LIBCOMERR   =$(LIBDIR)\libcom_err.lib
547 LIBEDITLINE =$(LIBDIR)\libeditline.lib
548 LIBGSSAPI   =$(LIBDIR)\libgssapi.lib
549 LIBHCRYPTO  =$(LIBDIR)\libhcrypto.lib
550 LIBHDB      =$(LIBDIR)\libhdb.lib
551 LIBHEIMBASE =$(LIBDIR)\libheimbase.lib
552 LIBHEIMDAL  =$(LIBDIR)\heimdal.lib
553 LIBHEIMIPCC =$(LIBDIR)\libheim-ipcc.lib
554 LIBHEIMIPCS =$(LIBDIR)\libheim-ipcs.lib
555 LIBHEIMNTLM =$(LIBDIR)\libheimntlm.lib
556 LIBHX509    =$(LIBDIR)\libhx509.lib
557 LIBKADM5CLNT=$(LIBDIR)\libkadm5clnt.lib
558 LIBKADM5SRV =$(LIBDIR)\libkadm5srv.lib
559 LIBKDC      =$(LIBDIR)\libkdc.lib
560 LIBLTM      =$(LIBDIR)\libltm.lib
561 LIBKRB5     =$(LIBDIR)\libkrb5.lib
562 LIBRFC3961  =$(LIBDIR)\librfc3961.lib
563 LIBROKEN    =$(LIBDIR)\libroken.lib
564 LIBSL       =$(LIBDIR)\libsl.lib
565 LIBSQLITE   =$(LIBDIR)\libsqlite.lib
566 LIBVERS     =$(LIBDIR)\libvers.lib
567 LIBWIND     =$(LIBDIR)\libwind.lib
569 ASMKRBNAME  =Heimdal.Kerberos
570 ASMGSSNAME  =Heimdal.GSSAPI
571 APPMANIFEST =$(INCDIR)\Heimdal.Application.$(MCPU).manifest