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
86 SRCDIR =$(SRC)\$(RELDIR)
87 OBJ =$(OBJDIR)\$(RELDIR)
93 PATH=$(PATH);$(BINDIR)
95 #----------------------------------------------------------------
98 RMAKE=nmake /nologo /f NTMakefile RECURSE=1
113 SIGNTOOL=signtool.exe
116 # Only used for tests
120 #----------------------------------------------------------------
121 # External dependencies
123 # For pthread support to be enabled, both PTHREAD_INC and PTHREAD_LIB
124 # should be defined. PTHREAD_INC should be the include directory
125 # where pthread.h is to be found (i.e. $(PTHREAD_INC)\pthread.h should
126 # exist), and PTHREAD_LIB is the full path to the pthread import
129 # Note that both paths should not contain any whitespace.
132 pthreadinc= -I$(PTHREAD_INC)
135 #----------------------------------------------------------------
138 cincdirs=$(cincdirs) -I$(INCDIR) -I$(INCDIR)\krb5 $(pthreadinc)
139 cdefines=$(cdefines) -DHAVE_CONFIG_H
141 # ---------------------------------------------------------------
145 cdefines=$(cdefines) -D_USE_32BIT_TIME_T
150 # C4996: 'function' was declared deprecated
151 # C4127: Conditional expression is constant
152 # C4244: Conversion from 'type1' to 'type2', possible loss of data
153 # C4100: 'identifier': unreferenced formal parameter
154 # C4706: Assignment within conditional expression
155 # C4214: Nonstandard extension used
156 # C4267: '': Conversion from 'type1' to 'type2', possible loss of data
157 # C4018: '': Signed/unsigned mismatch
158 # C4204: Nonstandard extension used: non-constant aggregate initializer
159 # C4221: Nonstandard extension used: 'v1': cannot be initialized using address of automatic variable 'v2'
160 # C4295: '': Array is too small to include a terminating null character
162 cwarn=$(cwarn) -D_CRT_SECURE_NO_WARNINGS -wd4996 -wd4127 -wd4244 -wd4100 -wd4706
163 cwarn=$(cwarn) -wd4214 -wd4267 -wd4018 -wd4389 -wd4204 -wd4221 -wd4295
167 !elseif "$(CPU)"=="AMD64"
170 ! error Unknown CPU value
173 !ifndef STATICRUNTIME
175 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsdll) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
176 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsdll) $(libmach)
177 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsdll) $(libmach)
178 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsdll) $(libmach)
179 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsdll) $(libmach)
181 !else # STATICRUNTIME
183 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsmt) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
184 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsmt) $(libmach)
185 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsmt) $(libmach)
186 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsmt) $(libmach)
187 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsmt) $(libmach)
191 LIBGUI_C = $(LM) /nologo $(libmach) /SUBSYSTEM:WINDOWS
192 LIBCON_C = $(LM) /nologo $(libmach) /SUBSYSTEM:CONSOLE
194 C2OBJ = $(C2OBJ_C) -Fo$@ -Fd$(@D)\ $**
195 C2OBJ_NP = $(C2OBJ_C) -MP $<
196 C2OBJ_P = $(C2OBJ_NP) -Fo$(OBJ)\ -Fd$(OBJ)\ #
197 EXECONLINK = $(EXECONLINK_C) -OUT:$@ $**
198 EXEGUILINK = $(EXEGUILINK_C) -OUT:$@ $**
199 DLLCONLINK = $(DLLCONLINK_C) -OUT:$@ $**
200 DLLGUILINK = $(DLLGUILINK_C) -OUT:$@ $**
201 LIBGUI = $(LIBGUI_C) /OUT:$@ $**
202 LIBCON = $(LIBCON_C) /OUT:$@ $**
204 # Preprocess files to stdout using config.h
205 CPREPROCESSOUT = $(CC) /EP /FI$(INCDIR)\config.h /TC /DCPP_ONLY=1
209 RC2RES_C = $(RC) $(cincdirs) $(AUXRCFLAGS)
210 RC2RES = $(RC2RES_C) -fo $@ $**
212 #----------------------------------------------------------------------
213 # If this is the initial invocation, we check if all the build
214 # utilities are there. Also show the commands macros.
219 @for %%g in ( "$(AWK)" "$(YACC)" "$(LEX)" "$(PYTHON)" "$(PERL)" "$(CMP)" "$(SED)" "$(SIGNTOOL)" "$(MAKECAT)" ) do @( \
220 for /f %%f in ( "%%g" ) do @( \
223 ) else if "%%~$$PATH:f"=="" @( \
224 echo Could not find %%f in PATH && \
227 echo Found %%~$$PATH:f \
231 @for %%g in ( "$(SH)" ) do @( \
232 for /f %%f in ( "%%g" ) do @( \
235 ) else if "%%~$$PATH:f"=="" @( \
236 echo Could not find %%f in PATH && \
237 echo Test targets may fail. \
239 echo Found %%~$$PATH:f \
248 @$(ECHO) C2OBJ=$(C2OBJ_C:\=\\)
250 @$(ECHO) EXECONLINK=$(EXECONLINK_C)
252 @$(ECHO) EXEGUILINK=$(EXEGUILINK_C)
254 @$(ECHO) DLLCONLINK=$(DLLCONLINK_C)
256 @$(ECHO) DLLGUILINK=$(DLLGUILINK_C)
258 @$(ECHO) LIBGUI=$(LIBGUI_C)
260 @$(ECHO) LIBCON=$(LIBCON_C)
267 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ /MP @<<
271 {$(OBJ)}.c{$(OBJ)}.obj::
272 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ /MP @<<
277 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ /MP @<<
281 {$(OBJ)}.cpp{$(OBJ)}.obj::
282 $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ /MP @<<
292 {}.h{$(INCDIR)\krb5}.h:
295 {$(OBJ)}.h{$(INCDIR)}.h:
298 {$(OBJ)}.x{$(OBJ)}.c:
301 {$(OBJ)}.hx{$(INCDIR)}.h:
304 {$(OBJ)}.hx{$(OBJ)}.h:
310 #----------------------------------------------------------------------
311 # Announce the build directory
316 all-tools:: announce-tools
324 @echo --------- Entering $(RELDIR:\= ):
328 @echo --------- Entering $(RELDIR:\= ) tools:
331 #----------------------------------------------------------------------
332 # Create any required directories if they don't already exist
340 ! if !exist($(DESTDIR))
343 ! if !exist($(LIBDIR))
346 ! if !exist($(BINDIR))
349 ! if !exist($(INCDIR))
352 ! if !exist($(INCDIR)\gssapi)
353 $(MKDIR) $(INCDIR)\gssapi
355 ! if !exist($(INCDIR)\hcrypto)
356 $(MKDIR) $(INCDIR)\hcrypto
358 ! if !exist($(INCDIR)\kadm5)
359 $(MKDIR) $(INCDIR)\kadm5
361 ! if !exist($(INCDIR)\krb5)
362 $(MKDIR) $(INCDIR)\krb5
365 #----------------------------------------------------------------------
366 # If SUBDIRS is defined, we should recurse into the subdirectories
370 @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) && popd) || exit /b 1
373 @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) clean && popd) || exit /b 1
376 @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) test && popd) || exit /b 1
380 clean:: clean-subdirs
386 #----------------------------------------------------------------------
398 .SUFFIXES: .c .cpp .hin .h .x .hx
400 #----------------------------------------------------------------------
403 # Starting with Visual Studio 8, the C compiler and the linker
404 # generate manifests so that the applications will link with the
405 # correct side-by-side DLLs at run-time. These are required for
406 # correct operation under Windows XP and later. We also have custom
407 # manifests which need to be merged with the manifests that VS
410 # The syntax for invoking the _VC_MANIFEST_EMBED_FOO macro is:
411 # $(_VC_MANIFEST_EMBED_???) <additional manifests>
416 _VC_MANIFEST_EMBED_EXE= \
417 ( if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest )
419 _VC_MANIFEST_EMBED_DLL= \
420 ( if exist $@.manifest $(MT) -outputresource:$@;2 -manifest $@.manifest )
422 # Note that if you are merging manifests, then the VS generated
423 # manifest should be cleaned up after calling _VC_MANIFEST_EMBED_???.
424 # This ensures that even if the DLL or EXE is executed in-place, the
425 # embedded manifest will be used. Otherwise the $@.manifest file will
428 _VC_MANIFEST_CLEAN= \
429 ( if exist $@.manifest $(RM) $@.manifest )
431 # End of manifest handling
433 #----------------------------------------------------------------------
434 # Code and assembly signing
436 # SIGNTOOL_C is any set of options required for certificate/private
437 # key selection for code signging.
439 # SIGNTOOL_O is any set of additional options to signtool.exe
441 # SIGNTOOL_T is the timestamp option
444 _CODESIGN=( $(CODESIGN) $@ )
450 SIGNTOOL_T=/t http://timestamp.verisign.com/scripts/timstamp.dll
453 _CODESIGN=( $(SIGNTOOL) sign $(SIGNTOOL_O) $(SIGNTOOL_T) $(SIGNTOOL_C) /v $@ )
455 _CODESIGN=( echo Skipping code sign )
460 #----------------------------------------------------------------------
461 # Convenience macros for preparing EXEs and DLLs. These are multiline
462 # macros that deal with manifests and code signing. Unless we need to
463 # include custom manifests, these are what we should be using to
467 ( $(_VC_MANIFEST_EMBED_EXE) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || $(RM) $@
470 ( $(_VC_MANIFEST_EMBED_EXE) && $(_VC_MANIFEST_CLEAN) ) || $(RM) $@
473 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || $(RM) $@
476 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) ) || $(RM) $@
478 #----------------------------------------------------------------------
479 # Convenience macros for import libraries and assemblies
482 LIBASN1 =$(LIBDIR)\libasn1.lib
483 LIBCOMERR =$(LIBDIR)\libcom_err.lib
484 LIBEDITLINE =$(LIBDIR)\libeditline.lib
485 LIBGSSAPI =$(LIBDIR)\libgssapi.lib
486 LIBHCRYPTO =$(LIBDIR)\libhcrypto.lib
487 LIBHDB =$(LIBDIR)\libhdb.lib
488 LIBHEIMDAL =$(LIBDIR)\heimdal.lib
489 LIBHEIMIPCC =$(LIBDIR)\libheim-ipcc.lib
490 LIBHEIMIPCS =$(LIBDIR)\libheim-ipcs.lib
491 LIBHEIMNTLM =$(LIBDIR)\libheimntlm.lib
492 LIBHX509 =$(LIBDIR)\libhx509.lib
493 LIBKADM5CLNT=$(LIBDIR)\libkadm5clnt.lib
494 LIBKADM5SRV =$(LIBDIR)\libkadm5srv.lib
495 LIBKDC =$(LIBDIR)\libkdc.lib
496 LIBLTM =$(LIBDIR)\libltm.lib
497 LIBKRB5 =$(LIBDIR)\libkrb5.lib
498 LIBROKEN =$(LIBDIR)\libroken.lib
499 LIBSL =$(LIBDIR)\libsl.lib
500 LIBSQLITE =$(LIBDIR)\libsqlite.lib
501 LIBVERS =$(LIBDIR)\libvers.lib
502 LIBWIND =$(LIBDIR)\libwind.lib
504 ASMKRBNAME =Heimdal.Kerberos
505 ASMGSSNAME =Heimdal.GSSAPI
506 APPMANIFEST =$(INCDIR)\Heimdal.Application.$(MCPU).manifest