1 ########################################################################
3 # Copyright (c) 2009-2011, Secure Endpoints Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # - Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
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
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.
50 !if exist($(MAKEDIR)\windows\NTMakefile.w32)
52 !elseif exist($(MAKEDIR)\..\windows\NTMakefile.w32)
54 !elseif exist($(MAKEDIR)\..\..\windows\NTMakefile.w32)
56 !elseif exist($(MAKEDIR)\..\..\..\windows\NTMakefile.w32)
57 SRC=$(MAKEDIR)\..\..\..
58 !elseif exist($(MAKEDIR)\..\..\..\..\windows\NTMakefile.w32)
59 SRC=$(MAKEDIR)\..\..\..\..
61 ! error Cant determine source directory
64 ! if "$(CPU)"=="i386" || "$(CPU)"=="x86"
66 ! elseif "$(CPU)"=="AMD64"
72 !include "NTMakefile.config"
74 #----------------------------------------------------------------
77 DESTDIR =$(SRC)\out\dest_$(CPU)
78 OBJDIR =$(SRC)\out\obj_$(CPU)
80 INCDIR =$(DESTDIR)\inc
81 LIBDIR =$(DESTDIR)\lib
82 BINDIR =$(DESTDIR)\bin
84 DOCDIR =$(DESTDIR)\doc
88 INSTDIR =$(DESTDIR)\install
89 SDKDIR =$(SRC)\out\sdk
90 SDKINCDIR =$(SDKDIR)\inc
91 SDKLIBDIR =$(SDKDIR)\lib\$(CPU)
92 SDKSRCDIR =$(SDKDIR)\src
93 SDKREDISTDIR =$(SDKDIR)\redist\$(CPU)
96 SRCDIR =$(SRC)\$(RELDIR)
97 OBJ =$(OBJDIR)\$(RELDIR)
103 PATH=$(PATH);$(BINDIR)
105 #----------------------------------------------------------------
108 RMAKE=nmake /nologo /f NTMakefile RECURSE=1
117 #----------------------------------------------------------------
126 SIGNTOOL=signtool.exe
129 MAKEINFO=makeinfo.exe
132 CANDLE_CMD=candle.exe
135 # Only used for tests
142 CANDLE=$(CANDLE_CMD) -nologo
143 LIGHT=$(LIGHT_CMD) -nologo
145 #----------------------------------------------------------------
146 # External dependencies
148 # For pthread support to be enabled, both PTHREAD_INC and PTHREAD_LIB
149 # should be defined. PTHREAD_INC should be the include directory
150 # where pthread.h is to be found (i.e. $(PTHREAD_INC)\pthread.h should
151 # exist), and PTHREAD_LIB is the full path to the pthread import
154 # Note that both paths should not contain any whitespace.
157 pthreadinc= -I$(PTHREAD_INC)
160 #----------------------------------------------------------------
163 cincdirs=$(cincdirs) -I$(INCDIR) -I$(INCDIR)\krb5 $(pthreadinc)
164 cdefines=$(cdefines) -DHAVE_CONFIG_H
166 ldebug=$(ldebug) /DEBUG
167 localcflags=$(localcflags) /Oy-
171 # C4996: 'function' was declared deprecated
172 # C4127: Conditional expression is constant
173 # C4244: Conversion from 'type1' to 'type2', possible loss of data
174 # C4100: 'identifier': unreferenced formal parameter
175 # C4706: Assignment within conditional expression
176 # C4214: Nonstandard extension used
177 # C4267: '': Conversion from 'type1' to 'type2', possible loss of data
178 # C4018: '': Signed/unsigned mismatch
179 # C4204: Nonstandard extension used: non-constant aggregate initializer
180 # C4221: Nonstandard extension used: 'v1': cannot be initialized using address of automatic variable 'v2'
181 # C4295: '': Array is too small to include a terminating null character
182 # C4146: Unary minus operator applied to unsigned type, result still unsigned.
184 cwarn=$(cwarn) -D_CRT_SECURE_NO_WARNINGS -wd4996 -wd4127 -wd4244 -wd4100 -wd4706
185 cwarn=$(cwarn) -wd4214 -wd4267 -wd4018 -wd4389 -wd4204 -wd4221 -wd4295 -wd4146
189 !elseif "$(CPU)"=="AMD64"
192 ! error Unknown CPU value
201 !ifndef STATICRUNTIME
203 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsdll) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
204 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsdll) $(libmach)
205 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsdll) $(libmach)
206 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsdll) $(libmach)
207 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsdll) $(libmach)
209 !else # STATICRUNTIME
211 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsmt) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
212 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsmt) $(libmach)
213 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsmt) $(libmach)
214 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsmt) $(libmach)
215 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsmt) $(libmach)
219 LIBGUI_C = $(LM) /nologo $(libmach) /SUBSYSTEM:WINDOWS
220 LIBCON_C = $(LM) /nologo $(libmach) /SUBSYSTEM:CONSOLE
222 C2OBJ = $(C2OBJ_C) -Fo$@ -Fd$(@D)\ $**
223 C2OBJ_NP = $(C2OBJ_C) $(MPOPT) $<
224 C2OBJ_P = $(C2OBJ_NP) -Fo$(OBJ)\ -Fd$(OBJ)\ #
225 EXECONLINK = $(EXECONLINK_C) -OUT:$@ $**
226 EXEGUILINK = $(EXEGUILINK_C) -OUT:$@ $**
227 DLLCONLINK = $(DLLCONLINK_C) -OUT:$@ $**
228 DLLGUILINK = $(DLLGUILINK_C) -OUT:$@ $**
229 LIBGUI = $(LIBGUI_C) /OUT:$@ $**
230 LIBCON = $(LIBCON_C) /OUT:$@ $**
232 # Preprocess files to stdout using config.h
233 CPREPROCESSOUT = $(CC) /EP /FI$(INCDIR)\config.h /TC /DCPP_ONLY=1
237 RC2RES_C = $(RC) $(cincdirs) $(AUXRCFLAGS)
238 RC2RES = $(RC2RES_C) -fo $@ $**
240 #----------------------------------------------------------------------
241 # If this is the initial invocation, we check if all the build
242 # utilities are there. Also show the commands macros.
247 "$(AWK_CMD)" "$(YACC_CMD)" "$(LEX_CMD)" "$(PYTHON)" "$(PERL)" \
248 "$(CMP)" "$(SED)" "$(SIGNTOOL)" "$(MAKECAT)" "$(MAKEINFO)" "$(HHC)"
250 !ifdef BUILD_INSTALLERS
251 REQUIRED_TOOLS=$(REQUIRED_TOOLS) "$(CANDLE_CMD)" "$(LIGHT_CMD)"
254 OPTIONAL_TOOLS="$(SH)"
257 @for %%g in ( $(REQUIRED_TOOLS) ) do @( \
258 for /f %%f in ( "%%g" ) do @( \
261 ) else if "%%~$$PATH:f"=="" @( \
262 echo Could not find %%f in PATH && \
265 echo Found %%~$$PATH:f \
269 @for %%g in ( $(OPTIONAL_TOOLS) ) do @( \
270 for /f %%f in ( "%%g" ) do @( \
273 ) else if "%%~$$PATH:f"=="" @( \
274 echo Could not find %%f in PATH && \
275 echo Optional targets may fail. \
277 echo Found %%~$$PATH:f \
286 @$(ECHO) C2OBJ=$(C2OBJ_C:\=\\)
288 @$(ECHO) EXECONLINK=$(EXECONLINK_C)
290 @$(ECHO) EXEGUILINK=$(EXEGUILINK_C)
292 @$(ECHO) DLLCONLINK=$(DLLCONLINK_C)
294 @$(ECHO) DLLGUILINK=$(DLLGUILINK_C)
296 @$(ECHO) LIBGUI=$(LIBGUI_C)
298 @$(ECHO) LIBCON=$(LIBCON_C)
305 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(localcflags) $(MPOPT) @<<
309 {$(OBJ)}.c{$(OBJ)}.obj::
310 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(extcflags) $(MPOPT) @<<
315 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(localcflags) $(MPOPT) @<<
319 {$(OBJ)}.cpp{$(OBJ)}.obj::
320 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(extcflags) $(MPOPT) @<<
330 {}.h{$(INCDIR)\krb5}.h:
333 {$(OBJ)}.h{$(INCDIR)}.h:
336 {$(OBJ)}.x{$(OBJ)}.c:
339 {$(OBJ)}.hx{$(INCDIR)}.h:
342 {$(OBJ)}.hx{$(OBJ)}.h:
348 #----------------------------------------------------------------------
349 # Announce the build directory
354 all-tools:: announce-tools
362 @echo --------- Entering $(RELDIR:\= ):
366 @echo --------- Entering $(RELDIR:\= ) tools:
369 #----------------------------------------------------------------------
370 # Create any required directories if they don't already exist
375 ! if !exist("$(OBJ)")
378 ! if !exist("$(DESTDIR)")
379 -$(MKDIR) "$(DESTDIR)"
381 ! if !exist("$(LIBDIR)")
382 -$(MKDIR) "$(LIBDIR)"
384 ! if !exist("$(BINDIR)")
385 -$(MKDIR) "$(BINDIR)"
387 ! if !exist("$(PLUGINDIR)")
388 -$(MKDIR) "$(PLUGINDIR)"
390 ! if !exist("$(INCDIR)")
391 -$(MKDIR) "$(INCDIR)"
393 ! if !exist("$(DOCDIR)")
394 -$(MKDIR) "$(DOCDIR)"
396 ! if !exist("$(INCDIR)\gssapi")
397 -$(MKDIR) "$(INCDIR)\gssapi"
399 ! if !exist("$(INCDIR)\hcrypto")
400 -$(MKDIR) "$(INCDIR)\hcrypto"
402 ! if !exist("$(INCDIR)\kadm5")
403 -$(MKDIR) "$(INCDIR)\kadm5"
405 ! if !exist("$(INCDIR)\krb5")
406 -$(MKDIR) "$(INCDIR)\krb5"
409 #----------------------------------------------------------------------
410 # If SUBDIRS is defined, we should recurse into the subdirectories
414 @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) && popd) || exit /b 1
417 @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) clean && popd) || exit /b 1
420 @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) test && popd) || exit /b 1
424 clean:: clean-subdirs
430 #----------------------------------------------------------------------
442 .SUFFIXES: .c .cpp .hin .h .x .hx
444 #----------------------------------------------------------------------
447 # Starting with Visual Studio 8, the C compiler and the linker
448 # generate manifests so that the applications will link with the
449 # correct side-by-side DLLs at run-time. These are required for
450 # correct operation under Windows XP and later. We also have custom
451 # manifests which need to be merged with the manifests that VS
454 # The syntax for invoking the _VC_MANIFEST_EMBED_FOO macro is:
455 # $(_VC_MANIFEST_EMBED_???) <additional manifests>
460 _VC_MANIFEST_EMBED_EXE= \
461 ( if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest $(APPMANIFEST) )
463 _VC_MANIFEST_EMBED_EXE_NOHEIM= \
464 ( if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest )
466 _VC_MANIFEST_EMBED_DLL= \
467 ( if exist $@.manifest $(MT) -outputresource:$@;2 -manifest $@.manifest )
469 _MERGE_MANIFEST_DLL= \
470 ( $(MT) -inputresource:$@;2 -manifest $(APPMANIFEST) -outputresource:$@;2 )
472 _INSERT_APPMANIFEST_DLL= \
473 ( $(MT) -manifest $(APPMANIFEST) -outputresource:$@;2 )
475 # Note that if you are merging manifests, then the VS generated
476 # manifest should be cleaned up after calling _VC_MANIFEST_EMBED_???.
477 # This ensures that even if the DLL or EXE is executed in-place, the
478 # embedded manifest will be used. Otherwise the $@.manifest file will
481 _VC_MANIFEST_CLEAN= \
482 ( if exist $@.manifest $(RM) $@.manifest )
484 # End of manifest handling
486 #----------------------------------------------------------------------
487 # Code and assembly signing
489 # SIGNTOOL_C is any set of options required for certificate/private
490 # key selection for code signging.
492 # SIGNTOOL_O is any set of additional options to signtool.exe
494 # SIGNTOOL_T is the timestamp option
497 _CODESIGN=( $(CODESIGN) $@ )
503 SIGNTOOL_T=/t http://timestamp.verisign.com/scripts/timstamp.dll
506 _CODESIGN=( $(SIGNTOOL) sign $(SIGNTOOL_O) $(SIGNTOOL_T) $(SIGNTOOL_C) /v $@ )
508 _CODESIGN=( echo Skipping code sign )
513 #----------------------------------------------------------------------
514 # Symbol Store Support
516 # SYMSTORE_EXE is full path to symstore.exe
518 # SYMSTORE_ROOT is full path to root directory of symbol store
520 # SYMSTORE_COMMENT is optional comment to include in symbol store catalog entry
523 !IF DEFINED(SYMSTORE_EXE) && DEFINED(SYMSTORE_ROOT)
524 !IF "$(SYMSTORE_COMMENT)" != ""
525 SYMSTORE_COMMENT = |$(SYMSTORE_COMMENT)
528 $(SYMSTORE_EXE) add /s $(SYMSTORE_ROOT) /t "Heimdal" /v "$(BUILD)-$(CPU)-$(VER_PACKAGE_VERSION)" /c "$(@F)$(SYMSTORE_COMMENT)" /f $*.*
530 SYMSTORE_IMPORT=@echo No symbol store
533 #----------------------------------------------------------------------
534 # Convenience macros for preparing EXEs and DLLs. These are multiline
535 # macros that deal with manifests and code signing. Unless we need to
536 # include custom manifests, these are what we should be using to
540 ( $(_VC_MANIFEST_EMBED_EXE) && $(_VC_MANIFEST_CLEAN) && $(SYMSTORE_IMPORT) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
543 ( $(_VC_MANIFEST_EMBED_EXE_NOHEIM) && $(_VC_MANIFEST_CLEAN) && $(SYMSTORE_IMPORT) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
546 ( $(_VC_MANIFEST_EMBED_EXE_NOHEIM) && $(_VC_MANIFEST_CLEAN) && $(SYMSTORE_IMPORT) ) || ( $(RM) $@ && exit /b 1 )
549 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) && $(SYMSTORE_IMPORT) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
552 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) && $(SYMSTORE_IMPORT) ) || ( $(RM) $@ && exit /b 1 )
555 ( ( $(_MERGE_MANIFEST_DLL) || $(_INSERT_APPMANIFEST_DLL) && $(SYMSTORE_IMPORT) ) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
557 #----------------------------------------------------------------------
558 # Convenience macros for import libraries and assemblies
561 LIBASN1 =$(LIBDIR)\libasn1.lib
562 LIBCOMERR =$(LIBDIR)\libcom_err.lib
563 LIBEDITLINE =$(LIBDIR)\libeditline.lib
564 LIBGSSAPI =$(LIBDIR)\libgssapi.lib
565 LIBHCRYPTO =$(LIBDIR)\libhcrypto.lib
566 LIBHDB =$(LIBDIR)\libhdb.lib
567 LIBHEIMBASE =$(LIBDIR)\libheimbase.lib
568 LIBHEIMDAL =$(LIBDIR)\heimdal.lib
569 LIBHEIMIPCC =$(LIBDIR)\libheim-ipcc.lib
570 LIBHEIMIPCS =$(LIBDIR)\libheim-ipcs.lib
571 LIBHEIMNTLM =$(LIBDIR)\libheimntlm.lib
572 LIBHX509 =$(LIBDIR)\libhx509.lib
573 LIBKADM5CLNT=$(LIBDIR)\libkadm5clnt.lib
574 LIBKADM5SRV =$(LIBDIR)\libkadm5srv.lib
575 LIBKDC =$(LIBDIR)\libkdc.lib
576 LIBLTM =$(LIBDIR)\libltm.lib
577 LIBKRB5 =$(LIBDIR)\libkrb5.lib
578 LIBRFC3961 =$(LIBDIR)\librfc3961.lib
579 LIBROKEN =$(LIBDIR)\libroken.lib
580 LIBSL =$(LIBDIR)\libsl.lib
581 LIBSQLITE =$(LIBDIR)\libsqlite.lib
582 LIBVERS =$(LIBDIR)\libvers.lib
583 LIBWIND =$(LIBDIR)\libwind.lib
588 !ifdef VER_PRERELEASE
598 ASMKRBNAME =Heimdal.Kerberos$(ASM_SPC)$(ASM_PVT)$(ASM_PRE)$(ASM_DBG)
599 APPMANIFEST =$(INCDIR)\Heimdal.Application.$(MCPU).manifest