1 ########################################################################
3 # Copyright (c) 2009, 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)\..\..\..
59 ! error Cant determine source directory
62 ! if "$(CPU)"=="i386" || "$(CPU)"=="x86"
64 ! elseif "$(CPU)"=="AMD64"
70 !include "NTMakefile.config"
72 #----------------------------------------------------------------
75 DESTDIR=$(SRC)\out\dest_$(OUTDIR)
76 OBJDIR =$(SRC)\out\obj_$(OUTDIR)
78 INCDIR =$(DESTDIR)\inc
79 LIBDIR =$(DESTDIR)\lib
80 BINDIR =$(DESTDIR)\bin
85 SDKINCDIR=$(SRC)\out\inc
86 SDKLIBDIR=$(SRC)\out\lib\$(CPU)
87 SDKSRCDIR=$(SRC)\out\src
90 SRCDIR =$(SRC)\$(RELDIR)
91 OBJ =$(OBJDIR)\$(RELDIR)
97 PATH=$(PATH);$(BINDIR)
99 #----------------------------------------------------------------
102 RMAKE=nmake /nologo /f NTMakefile RECURSE=1
117 SIGNTOOL=signtool.exe
120 # Only used for tests
124 #----------------------------------------------------------------
125 # External dependencies
127 # For pthread support to be enabled, both PTHREAD_INC and PTHREAD_LIB
128 # should be defined. PTHREAD_INC should be the include directory
129 # where pthread.h is to be found (i.e. $(PTHREAD_INC)\pthread.h should
130 # exist), and PTHREAD_LIB is the full path to the pthread import
133 # Note that both paths should not contain any whitespace.
136 pthreadinc= -I$(PTHREAD_INC)
139 #----------------------------------------------------------------
142 cincdirs=$(cincdirs) -I$(INCDIR) -I$(INCDIR)\krb5 $(pthreadinc)
143 cdefines=$(cdefines) -DHAVE_CONFIG_H
145 # ---------------------------------------------------------------
149 cdefines=$(cdefines) -D_USE_32BIT_TIME_T
154 # C4996: 'function' was declared deprecated
155 # C4127: Conditional expression is constant
156 # C4244: Conversion from 'type1' to 'type2', possible loss of data
157 # C4100: 'identifier': unreferenced formal parameter
158 # C4706: Assignment within conditional expression
159 # C4214: Nonstandard extension used
160 # C4267: '': Conversion from 'type1' to 'type2', possible loss of data
161 # C4018: '': Signed/unsigned mismatch
162 # C4204: Nonstandard extension used: non-constant aggregate initializer
163 # C4221: Nonstandard extension used: 'v1': cannot be initialized using address of automatic variable 'v2'
164 # C4295: '': Array is too small to include a terminating null character
166 cwarn=$(cwarn) -D_CRT_SECURE_NO_WARNINGS -wd4996 -wd4127 -wd4244 -wd4100 -wd4706
167 cwarn=$(cwarn) -wd4214 -wd4267 -wd4018 -wd4389 -wd4204 -wd4221 -wd4295
171 !elseif "$(CPU)"=="AMD64"
174 ! error Unknown CPU value
177 !ifndef STATICRUNTIME
179 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsdll) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
180 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsdll) $(libmach)
181 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsdll) $(libmach)
182 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsdll) $(libmach)
183 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsdll) $(libmach)
185 !else # STATICRUNTIME
187 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsmt) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
188 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsmt) $(libmach)
189 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsmt) $(libmach)
190 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsmt) $(libmach)
191 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsmt) $(libmach)
195 LIBGUI_C = $(LM) /nologo $(libmach) /SUBSYSTEM:WINDOWS
196 LIBCON_C = $(LM) /nologo $(libmach) /SUBSYSTEM:CONSOLE
198 C2OBJ = $(C2OBJ_C) -Fo$@ -Fd$(@D)\ $**
199 C2OBJ_NP = $(C2OBJ_C) -MP $<
200 C2OBJ_P = $(C2OBJ_NP) -Fo$(OBJ)\ -Fd$(OBJ)\ #
201 EXECONLINK = $(EXECONLINK_C) -OUT:$@ $**
202 EXEGUILINK = $(EXEGUILINK_C) -OUT:$@ $**
203 DLLCONLINK = $(DLLCONLINK_C) -OUT:$@ $**
204 DLLGUILINK = $(DLLGUILINK_C) -OUT:$@ $**
205 LIBGUI = $(LIBGUI_C) /OUT:$@ $**
206 LIBCON = $(LIBCON_C) /OUT:$@ $**
208 # Preprocess files to stdout using config.h
209 CPREPROCESSOUT = $(CC) /EP /FI$(INCDIR)\config.h /TC /DCPP_ONLY=1
213 RC2RES_C = $(RC) $(cincdirs) $(AUXRCFLAGS)
214 RC2RES = $(RC2RES_C) -fo $@ $**
216 #----------------------------------------------------------------------
217 # If this is the initial invocation, we check if all the build
218 # utilities are there. Also show the commands macros.
223 @for %%g in ( "$(AWK)" "$(YACC)" "$(LEX)" "$(PYTHON)" "$(PERL)" "$(CMP)" "$(SED)" "$(SIGNTOOL)" "$(MAKECAT)" ) do @( \
224 for /f %%f in ( "%%g" ) do @( \
227 ) else if "%%~$$PATH:f"=="" @( \
228 echo Could not find %%f in PATH && \
231 echo Found %%~$$PATH:f \
235 @for %%g in ( "$(SH)" ) do @( \
236 for /f %%f in ( "%%g" ) do @( \
239 ) else if "%%~$$PATH:f"=="" @( \
240 echo Could not find %%f in PATH && \
241 echo Test targets may fail. \
243 echo Found %%~$$PATH:f \
252 @$(ECHO) C2OBJ=$(C2OBJ_C:\=\\)
254 @$(ECHO) EXECONLINK=$(EXECONLINK_C)
256 @$(ECHO) EXEGUILINK=$(EXEGUILINK_C)
258 @$(ECHO) DLLCONLINK=$(DLLCONLINK_C)
260 @$(ECHO) DLLGUILINK=$(DLLGUILINK_C)
262 @$(ECHO) LIBGUI=$(LIBGUI_C)
264 @$(ECHO) LIBCON=$(LIBCON_C)
271 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ /MP @<<
275 {$(OBJ)}.c{$(OBJ)}.obj::
276 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ /MP @<<
281 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ /MP @<<
285 {$(OBJ)}.cpp{$(OBJ)}.obj::
286 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ /MP @<<
296 {}.h{$(INCDIR)\krb5}.h:
299 {$(OBJ)}.h{$(INCDIR)}.h:
302 {$(OBJ)}.x{$(OBJ)}.c:
305 {$(OBJ)}.hx{$(INCDIR)}.h:
308 {$(OBJ)}.hx{$(OBJ)}.h:
314 #----------------------------------------------------------------------
315 # Announce the build directory
320 all-tools:: announce-tools
328 @echo --------- Entering $(RELDIR:\= ):
332 @echo --------- Entering $(RELDIR:\= ) tools:
335 #----------------------------------------------------------------------
336 # Create any required directories if they don't already exist
344 ! if !exist($(DESTDIR))
347 ! if !exist($(LIBDIR))
350 ! if !exist($(BINDIR))
353 ! if !exist($(INCDIR))
356 ! if !exist($(INCDIR)\gssapi)
357 $(MKDIR) $(INCDIR)\gssapi
359 ! if !exist($(INCDIR)\hcrypto)
360 $(MKDIR) $(INCDIR)\hcrypto
362 ! if !exist($(INCDIR)\kadm5)
363 $(MKDIR) $(INCDIR)\kadm5
365 ! if !exist($(INCDIR)\krb5)
366 $(MKDIR) $(INCDIR)\krb5
369 #----------------------------------------------------------------------
370 # If SUBDIRS is defined, we should recurse into the subdirectories
374 @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) && popd) || exit /b 1
377 @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) clean && popd) || exit /b 1
380 @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) test && popd) || exit /b 1
384 clean:: clean-subdirs
390 #----------------------------------------------------------------------
402 .SUFFIXES: .c .cpp .hin .h .x .hx
404 #----------------------------------------------------------------------
407 # Starting with Visual Studio 8, the C compiler and the linker
408 # generate manifests so that the applications will link with the
409 # correct side-by-side DLLs at run-time. These are required for
410 # correct operation under Windows XP and later. We also have custom
411 # manifests which need to be merged with the manifests that VS
414 # The syntax for invoking the _VC_MANIFEST_EMBED_FOO macro is:
415 # $(_VC_MANIFEST_EMBED_???) <additional manifests>
420 _VC_MANIFEST_EMBED_EXE= \
421 ( if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest )
423 _VC_MANIFEST_EMBED_DLL= \
424 ( if exist $@.manifest $(MT) -outputresource:$@;2 -manifest $@.manifest )
426 # Note that if you are merging manifests, then the VS generated
427 # manifest should be cleaned up after calling _VC_MANIFEST_EMBED_???.
428 # This ensures that even if the DLL or EXE is executed in-place, the
429 # embedded manifest will be used. Otherwise the $@.manifest file will
432 _VC_MANIFEST_CLEAN= \
433 ( if exist $@.manifest $(RM) $@.manifest )
435 # End of manifest handling
437 #----------------------------------------------------------------------
438 # Code and assembly signing
440 # SIGNTOOL_C is any set of options required for certificate/private
441 # key selection for code signging.
443 # SIGNTOOL_O is any set of additional options to signtool.exe
445 # SIGNTOOL_T is the timestamp option
448 _CODESIGN=( $(CODESIGN) $@ )
454 SIGNTOOL_T=/t http://timestamp.verisign.com/scripts/timstamp.dll
457 _CODESIGN=( $(SIGNTOOL) sign $(SIGNTOOL_O) $(SIGNTOOL_T) $(SIGNTOOL_C) /v $@ )
459 _CODESIGN=( echo Skipping code sign )
464 #----------------------------------------------------------------------
465 # Convenience macros for preparing EXEs and DLLs. These are multiline
466 # macros that deal with manifests and code signing. Unless we need to
467 # include custom manifests, these are what we should be using to
471 ( $(_VC_MANIFEST_EMBED_EXE) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || $(RM) $@
474 ( $(_VC_MANIFEST_EMBED_EXE) && $(_VC_MANIFEST_CLEAN) ) || $(RM) $@
477 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || $(RM) $@
480 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) ) || $(RM) $@
482 #----------------------------------------------------------------------
483 # Convenience macros for import libraries and assemblies
486 LIBASN1 =$(LIBDIR)\libasn1.lib
487 LIBCOMERR =$(LIBDIR)\libcom_err.lib
488 LIBEDITLINE =$(LIBDIR)\libeditline.lib
489 LIBGSSAPI =$(LIBDIR)\libgssapi.lib
490 LIBHCRYPTO =$(LIBDIR)\libhcrypto.lib
491 LIBHDB =$(LIBDIR)\libhdb.lib
492 LIBHEIMDAL =$(LIBDIR)\heimdal.lib
493 LIBHEIMIPCC =$(LIBDIR)\libheim-ipcc.lib
494 LIBHEIMIPCS =$(LIBDIR)\libheim-ipcs.lib
495 LIBHEIMNTLM =$(LIBDIR)\libheimntlm.lib
496 LIBHX509 =$(LIBDIR)\libhx509.lib
497 LIBKADM5CLNT=$(LIBDIR)\libkadm5clnt.lib
498 LIBKADM5SRV =$(LIBDIR)\libkadm5srv.lib
499 LIBKDC =$(LIBDIR)\libkdc.lib
500 LIBLTM =$(LIBDIR)\libltm.lib
501 LIBKRB5 =$(LIBDIR)\libkrb5.lib
502 LIBROKEN =$(LIBDIR)\libroken.lib
503 LIBSL =$(LIBDIR)\libsl.lib
504 LIBSQLITE =$(LIBDIR)\libsqlite.lib
505 LIBVERS =$(LIBDIR)\libvers.lib
506 LIBWIND =$(LIBDIR)\libwind.lib
508 ASMKRBNAME =Heimdal.Kerberos
509 ASMGSSNAME =Heimdal.GSSAPI
510 APPMANIFEST =$(INCDIR)\Heimdal.Application.$(MCPU).manifest