add glue for krb5_einval
[heimdal.git] / windows / NTMakefile.w32
blob8079c7886bb51173c39d5470a608be2fc7049ede
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 !elseif exist($(MAKEDIR)\..\..\..\..\windows\NTMakefile.w32)
59 SRC=$(MAKEDIR)\..\..\..\..
60 !else
61 !  error Cant determine source directory
62 !endif
64 !  if "$(CPU)"=="i386" || "$(CPU)"=="x86"
65 MCPU=x86
66 !  elseif "$(CPU)"=="AMD64"
67 MCPU=amd64
68 !  else
69 !    error Unknown CPU
70 !  endif
72 !include "NTMakefile.config"
74 #----------------------------------------------------------------
75 # Directory macros
77 DESTDIR         =$(SRC)\out\dest_$(CPU)
78 OBJDIR          =$(SRC)\out\obj_$(CPU)
80 INCDIR          =$(DESTDIR)\inc
81 LIBDIR          =$(DESTDIR)\lib
82 BINDIR          =$(DESTDIR)\bin
83 PLUGINDIR       =$(BINDIR)\plugin\krb5
84 DOCDIR          =$(DESTDIR)\doc
85 SBINDIR         =$(BINDIR)
86 LIBEXECDIR      =$(BINDIR)
87 ASMDIR          =$(BINDIR)
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)
95 !ifdef RELDIR
96 SRCDIR =$(SRC)\$(RELDIR)
97 OBJ    =$(OBJDIR)\$(RELDIR)
98 !else
99 OBJ    =$(OBJDIR)
100 !endif
102 # For tests:
103 PATH=$(PATH);$(BINDIR)
105 #----------------------------------------------------------------
106 # Command macros
108 RMAKE=nmake /nologo /f NTMakefile RECURSE=1
109 MKDIR=md
110 CP=copy /Y
111 LINK=link
112 LM=lib
113 RM=del /q
114 ECHO=echo
115 RC=rc
117 #----------------------------------------------------------------
118 # Program macros
120 AWK_CMD=gawk.exe
121 YACC_CMD=bison.exe
122 LEX_CMD=flex.exe
123 PYTHON=python.exe
124 PERL=perl.exe
125 CMP=cmp.exe
126 SIGNTOOL=signtool.exe
127 MAKECAT=makecat.exe
128 HHC=hhc.exe
129 MAKEINFO=makeinfo.exe
130 SED=sed.exe
132 CANDLE_CMD=candle.exe
133 LIGHT_CMD=light.exe
135 # Only used for tests
136 SH=sh.exe
138 # Commands
139 AWK=$(AWK_CMD)
140 YACC=$(YACC_CMD) -y
141 LEX=$(LEX_CMD)
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
152 # library.
154 # Note that both paths should not contain any whitespace.
156 !ifdef PTHREAD_INC
157 pthreadinc= -I$(PTHREAD_INC)
158 !endif
160 #----------------------------------------------------------------
161 # Build options
163 cincdirs=$(cincdirs) -I$(INCDIR) -I$(INCDIR)\krb5 $(pthreadinc)
164 cdefines=$(cdefines) -DHAVE_CONFIG_H
165 cdebug=$(cdebug) /Zi
166 ldebug=$(ldebug) /DEBUG
168 # ---------------------------------------------------------------
169 # time_t issues
171 !if "$(MCPU)"=="x86"
172 cdefines=$(cdefines) -D_USE_32BIT_TIME_T
173 !endif
175 # Disable warnings:
177 # C4996: 'function' was declared deprecated
178 # C4127: Conditional expression is constant
179 # C4244: Conversion from 'type1' to 'type2', possible loss of data
180 # C4100: 'identifier': unreferenced formal parameter
181 # C4706: Assignment within conditional expression
182 # C4214: Nonstandard extension used
183 # C4267: '': Conversion from 'type1' to 'type2', possible loss of data
184 # C4018: '': Signed/unsigned mismatch
185 # C4204: Nonstandard extension used: non-constant aggregate initializer
186 # C4221: Nonstandard extension used: 'v1': cannot be initialized using address of automatic variable 'v2'
187 # C4295: '': Array is too small to include a terminating null character
188 # C4146: Unary minus operator applied to unsigned type, result still unsigned.
190 cwarn=$(cwarn) -D_CRT_SECURE_NO_WARNINGS -wd4996 -wd4127 -wd4244 -wd4100 -wd4706
191 cwarn=$(cwarn) -wd4214 -wd4267 -wd4018 -wd4389 -wd4204 -wd4221 -wd4295 -wd4146
193 !if "$(CPU)"=="i386"
194 libmach=/machine:X86
195 !elseif "$(CPU)"=="AMD64"
196 libmach=/machine:X64
197 !else
198 !  error Unknown CPU value
199 !endif
201 !ifdef NO_MP
202 MPOPT=
203 !else
204 MPOPT=/MP
205 !endif
207 !ifndef STATICRUNTIME
209 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsdll) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
210 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsdll) $(libmach)
211 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsdll) $(libmach)
212 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsdll) $(libmach)
213 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsdll) $(libmach)
215 !else # STATICRUNTIME
217 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsmt) $(AUXCFLAGS) $(intcflags) $(cdefines) $(cincdirs) $(cwarn)
218 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsmt) $(libmach)
219 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsmt) $(libmach)
220 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsmt) $(libmach)
221 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsmt) $(libmach)
223 !endif
225 LIBGUI_C = $(LM) /nologo $(libmach) /SUBSYSTEM:WINDOWS
226 LIBCON_C = $(LM) /nologo $(libmach) /SUBSYSTEM:CONSOLE
228 C2OBJ = $(C2OBJ_C) -Fo$@ -Fd$(@D)\ $**
229 C2OBJ_NP = $(C2OBJ_C) $(MPOPT) $<
230 C2OBJ_P = $(C2OBJ_NP) -Fo$(OBJ)\ -Fd$(OBJ)\ #
231 EXECONLINK = $(EXECONLINK_C) -OUT:$@ $**
232 EXEGUILINK = $(EXEGUILINK_C) -OUT:$@ $**
233 DLLCONLINK = $(DLLCONLINK_C) -OUT:$@ $**
234 DLLGUILINK = $(DLLGUILINK_C) -OUT:$@ $**
235 LIBGUI = $(LIBGUI_C) /OUT:$@ $**
236 LIBCON = $(LIBCON_C) /OUT:$@ $**
238 # Preprocess files to stdout using config.h
239 CPREPROCESSOUT = $(CC) /EP /FI$(INCDIR)\config.h /TC /DCPP_ONLY=1
241 # Resources
243 RC2RES_C = $(RC) $(cincdirs) $(AUXRCFLAGS)
244 RC2RES = $(RC2RES_C) -fo $@ $**
246 #----------------------------------------------------------------------
247 # If this is the initial invocation, we check if all the build
248 # utilities are there.  Also show the commands macros.
250 !ifndef RECURSE
252 REQUIRED_TOOLS= \
253         "$(AWK_CMD)" "$(YACC_CMD)" "$(LEX_CMD)" "$(PYTHON)" "$(PERL)" \
254         "$(CMP)" "$(SED)" "$(SIGNTOOL)" "$(MAKECAT)" "$(MAKEINFO)" "$(HHC)"
256 !ifdef BUILD_INSTALLERS
257 REQUIRED_TOOLS=$(REQUIRED_TOOLS) "$(CANDLE_CMD)" "$(LIGHT_CMD)"
258 !endif
260 OPTIONAL_TOOLS="$(SH)" 
262 check-utils:
263         @for %%g in ( $(REQUIRED_TOOLS) ) do @( \
264         for /f %%f in ( "%%g" ) do @( \
265                 if exist %%f @( \
266                         echo Found %%f \
267                 ) else if "%%~$$PATH:f"=="" @( \
268                         echo Could not find %%f in PATH && \
269                         exit /b 1 \
270                 ) else @( \
271                         echo Found %%~$$PATH:f \
272                 ) \
273         ) \
274         )
275         @for %%g in ( $(OPTIONAL_TOOLS) ) do @( \
276         for /f %%f in ( "%%g" ) do @( \
277                 if exist %%f @( \
278                         echo Found %%f \
279                 ) else if "%%~$$PATH:f"=="" @( \
280                         echo Could not find %%f in PATH && \
281                         echo Optional targets may fail. \
282                 ) else @( \
283                         echo Found %%~$$PATH:f \
284                 ) \
285         ) \
286         )
289 prep:: check-utils
291 show-cmds:
292         @$(ECHO) C2OBJ=$(C2OBJ_C:\=\\)
293         @$(ECHO).
294         @$(ECHO) EXECONLINK=$(EXECONLINK_C)
295         @$(ECHO).
296         @$(ECHO) EXEGUILINK=$(EXEGUILINK_C)
297         @$(ECHO).
298         @$(ECHO) DLLCONLINK=$(DLLCONLINK_C)
299         @$(ECHO).
300         @$(ECHO) DLLGUILINK=$(DLLGUILINK_C)
301         @$(ECHO).
302         @$(ECHO) LIBGUI=$(LIBGUI_C)
303         @$(ECHO).
304         @$(ECHO) LIBCON=$(LIBCON_C)
306 prep:: show-cmds
308 !endif                          # RECURSE
310 {}.c{$(OBJ)}.obj::
311         $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(localcflags) $(MPOPT) @<<
315 {$(OBJ)}.c{$(OBJ)}.obj::
316         $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(extcflags) $(MPOPT) @<<
320 {}.cpp{$(OBJ)}.obj::
321         $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(localcflags) $(MPOPT) @<<
325 {$(OBJ)}.cpp{$(OBJ)}.obj::
326         $(C2OBJ_C) /Fd$(OBJ)\ /Fo$(OBJ)\ $(extcflags) $(MPOPT) @<<
330 {}.hin{$(INCDIR)}.h:
331         $(CP) $< $@
333 {}.h{$(INCDIR)}.h:
334         $(CP) $< $@
336 {}.h{$(INCDIR)\krb5}.h:
337         $(CP) $< $@
339 {$(OBJ)}.h{$(INCDIR)}.h:
340         $(CP) $< $@
342 {$(OBJ)}.x{$(OBJ)}.c:
343         $(CP) $< $@
345 {$(OBJ)}.hx{$(INCDIR)}.h:
346         $(CP) $< $@
348 {$(OBJ)}.hx{$(OBJ)}.h:
349         $(CP) $< $@
351 {}.rc{$(OBJ)}.res:
352         $(RC2RES)
354 #----------------------------------------------------------------------
355 # Announce the build directory
357 !ifdef RELDIR
358 all:: announce
360 all-tools:: announce-tools
362 test:: announce
364 clean:: announce
366 announce:
367         @echo.
368         @echo --------- Entering $(RELDIR:\= ):
370 announce-tools:
371         @echo.
372         @echo --------- Entering $(RELDIR:\= ) tools:
373 !endif
375 #----------------------------------------------------------------------
376 # Create any required directories if they don't already exist
378 prep:: mkdirs
380 mkdirs:
381 !  if !exist($(OBJ))
382         $(MKDIR) $(OBJ)
383 !  endif
384 !  if !exist($(DESTDIR))
385         $(MKDIR) $(DESTDIR)
386 !  endif
387 !  if !exist($(LIBDIR))
388         $(MKDIR) $(LIBDIR)
389 !  endif
390 !  if !exist($(BINDIR))
391         $(MKDIR) $(BINDIR)
392 !  endif
393 !  if !exist($(PLUGINDIR))
394         $(MKDIR) $(PLUGINDIR)
395 !  endif
396 !  if !exist($(INCDIR))
397         $(MKDIR) $(INCDIR)
398 !  endif
399 !  if !exist($(DOCDIR))
400         $(MKDIR) $(DOCDIR)
401 !  endif
402 !  if !exist($(INCDIR)\gssapi)
403         $(MKDIR) $(INCDIR)\gssapi
404 !  endif
405 !  if !exist($(INCDIR)\hcrypto)
406         $(MKDIR) $(INCDIR)\hcrypto
407 !  endif
408 !  if !exist($(INCDIR)\kadm5)
409         $(MKDIR) $(INCDIR)\kadm5
410 !  endif
411 !  if !exist($(INCDIR)\krb5)
412         $(MKDIR) $(INCDIR)\krb5
413 !  endif
415 #----------------------------------------------------------------------
416 # If SUBDIRS is defined, we should recurse into the subdirectories
418 !ifdef SUBDIRS
419 subdirs:
420         @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) && popd) || exit /b 1
422 clean-subdirs:
423         @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) clean && popd) || exit /b 1
425 test-subdirs:
426         @for %%f in ( $(SUBDIRS) ) do @ (pushd %%f && $(RMAKE) test && popd) || exit /b 1
428 all:: subdirs
430 clean:: clean-subdirs
432 test:: test-subdirs
434 !endif
436 #----------------------------------------------------------------------
437 # Clean targets
439 !ifdef CLEANFILES
440 clean::
441         -$(RM) $(CLEANFILES)
442 !endif
443 !ifdef RELDIR
444 clean::
445         -$(RM) $(OBJ)\*.*
446 !endif
448 .SUFFIXES: .c .cpp .hin .h .x .hx
450 #----------------------------------------------------------------------
451 # Manifest handling
453 # Starting with Visual Studio 8, the C compiler and the linker
454 # generate manifests so that the applications will link with the
455 # correct side-by-side DLLs at run-time.  These are required for
456 # correct operation under Windows XP and later.  We also have custom
457 # manifests which need to be merged with the manifests that VS
458 # creates.
460 # The syntax for invoking the _VC_MANIFEST_EMBED_FOO macro is:
461 # $(_VC_MANIFEST_EMBED_???) <additional manifests>
464 MT=mt.exe -nologo
466 _VC_MANIFEST_EMBED_EXE= \
467 ( if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest $(APPMANIFEST) )
469 _VC_MANIFEST_EMBED_EXE_NOHEIM= \
470 ( if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest )
472 _VC_MANIFEST_EMBED_DLL= \
473 ( if exist $@.manifest $(MT) -outputresource:$@;2 -manifest $@.manifest )
475 _MERGE_MANIFEST_DLL= \
476 ( $(MT) -inputresource:$@;2 -manifest $(APPMANIFEST) -outputresource:$@;2 )
478 _INSERT_APPMANIFEST_DLL= \
479 ( $(MT) -manifest $(APPMANIFEST) -outputresource:$@;2 )
481 # Note that if you are merging manifests, then the VS generated
482 # manifest should be cleaned up after calling _VC_MANIFEST_EMBED_???.
483 # This ensures that even if the DLL or EXE is executed in-place, the
484 # embedded manifest will be used.  Otherwise the $@.manifest file will
485 # be used.
487 _VC_MANIFEST_CLEAN= \
488 ( if exist $@.manifest $(RM) $@.manifest )
490 # End of manifest handling
492 #----------------------------------------------------------------------
493 # Code and assembly signing
495 # SIGNTOOL_C is any set of options required for certificate/private
496 # key selection for code signging.
498 # SIGNTOOL_O is any set of additional options to signtool.exe
500 # SIGNTOOL_T is the timestamp option
502 !ifdef CODESIGN
503 _CODESIGN=( $(CODESIGN) $@ )
504 !else
506 !ifdef SIGNTOOL_C
508 !ifndef SIGNTOOL_T
509 SIGNTOOL_T=/t http://timestamp.verisign.com/scripts/timstamp.dll
510 !endif
512 _CODESIGN=( $(SIGNTOOL) sign $(SIGNTOOL_O) $(SIGNTOOL_T) $(SIGNTOOL_C) /v $@ )
513 !else
514 _CODESIGN=( echo Skipping code sign )
515 !endif
517 !endif
519 #----------------------------------------------------------------------
520 # Convenience macros for preparing EXEs and DLLs.  These are multiline
521 # macros that deal with manifests and code signing.  Unless we need to
522 # include custom manifests, these are what we should be using to
523 # prepare binaries.
525 EXEPREP=\
526 ( $(_VC_MANIFEST_EMBED_EXE) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
528 EXEPREP_NOHEIM=\
529 ( $(_VC_MANIFEST_EMBED_EXE_NOHEIM) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
531 EXEPREP_NODIST=\
532 ( $(_VC_MANIFEST_EMBED_EXE_NOHEIM) && $(_VC_MANIFEST_CLEAN) ) || ( $(RM) $@ && exit /b 1 )
534 DLLPREP=\
535 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
537 DLLPREP_NODIST=\
538 ( $(_VC_MANIFEST_EMBED_DLL) && $(_VC_MANIFEST_CLEAN) ) || ( $(RM) $@ && exit /b 1 )
540 DLLPREP_MERGE=\
541 ( ( $(_MERGE_MANIFEST_DLL) || $(_INSERT_APPMANIFEST_DLL) ) && $(_CODESIGN) ) || ( $(RM) $@ && exit /b 1 )
543 #----------------------------------------------------------------------
544 # Convenience macros for import libraries and assemblies
547 LIBASN1     =$(LIBDIR)\libasn1.lib
548 LIBCOMERR   =$(LIBDIR)\libcom_err.lib
549 LIBEDITLINE =$(LIBDIR)\libeditline.lib
550 LIBGSSAPI   =$(LIBDIR)\libgssapi.lib
551 LIBHCRYPTO  =$(LIBDIR)\libhcrypto.lib
552 LIBHDB      =$(LIBDIR)\libhdb.lib
553 LIBHEIMBASE =$(LIBDIR)\libheimbase.lib
554 LIBHEIMDAL  =$(LIBDIR)\heimdal.lib
555 LIBHEIMIPCC =$(LIBDIR)\libheim-ipcc.lib
556 LIBHEIMIPCS =$(LIBDIR)\libheim-ipcs.lib
557 LIBHEIMNTLM =$(LIBDIR)\libheimntlm.lib
558 LIBHX509    =$(LIBDIR)\libhx509.lib
559 LIBKADM5CLNT=$(LIBDIR)\libkadm5clnt.lib
560 LIBKADM5SRV =$(LIBDIR)\libkadm5srv.lib
561 LIBKDC      =$(LIBDIR)\libkdc.lib
562 LIBLTM      =$(LIBDIR)\libltm.lib
563 LIBKRB5     =$(LIBDIR)\libkrb5.lib
564 LIBRFC3961  =$(LIBDIR)\librfc3961.lib
565 LIBROKEN    =$(LIBDIR)\libroken.lib
566 LIBSL       =$(LIBDIR)\libsl.lib
567 LIBSQLITE   =$(LIBDIR)\libsqlite.lib
568 LIBVERS     =$(LIBDIR)\libvers.lib
569 LIBWIND     =$(LIBDIR)\libwind.lib
571 ASMKRBNAME  =Heimdal.Kerberos
572 ASMGSSNAME  =Heimdal.GSSAPI
573 APPMANIFEST =$(INCDIR)\Heimdal.Application.$(MCPU).manifest