Remove commented code
[heimdal.git] / windows / NTMakefile.w32
blobbde9aa20083581c7d95eb888765db7f09487d0b1
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 !include "NTMakefile.config"
64 #----------------------------------------------------------------
65 # Directory macros
67 DESTDIR=$(SRC)\out\dest_$(OUTDIR)
68 OBJDIR =$(SRC)\out\obj_$(OUTDIR)
70 INCDIR =$(DESTDIR)\inc
71 LIBDIR =$(DESTDIR)\lib
72 BINDIR =$(DESTDIR)\bin
73 SBINDIR=$(BINDIR)
74 LIBEXECDIR=$(BINDIR)
76 !ifdef RELDIR
77 SRCDIR =$(SRC)\$(RELDIR)
78 OBJ    =$(OBJDIR)\$(RELDIR)
79 !else
80 OBJ    =$(OBJDIR)
81 !endif
83 # For tests:
84 PATH=$(PATH);$(BINDIR)
86 #----------------------------------------------------------------
87 # Command macros
89 RMAKE=nmake /nologo /f NTMakefile RECURSE=1
90 MKDIR=md
91 CP=copy /Y
92 LINK=link
93 LM=lib
94 RM=del /q
95 ECHO=echo
96 RC=rc
98 !ifndef AWK
99 AWK=gawk.exe
100 !endif
102 !ifndef YACC
103 YACC=bison.exe -y
104 !endif
106 !ifndef LEX
107 LEX=flex.exe
108 !endif
110 !ifndef PYTHON
111 PYTHON=python.exe
112 !endif
114 !ifndef PERL
115 PERL=perl.exe
116 !endif
118 !ifndef CMP
119 CMP=cmp.exe
120 !endif
122 # Only used for tests
123 !ifndef SH
124 SH=sh.exe
125 !endif
127 !ifndef SED
128 SED=sed.exe
129 !endif
131 #----------------------------------------------------------------
132 # External dependencies
134 # For pthread support to be enabled, both PTHREAD_INC and PTHREAD_LIB
135 # should be defined.  PTHREAD_INC should be the include directory
136 # where pthread.h is to be found (i.e. $(PTHREAD_INC)\pthread.h should
137 # exist), and PTHREAD_LIB is the full path to the pthread import
138 # library.
140 # Note that both paths should not contain any whitespace.
142 !ifdef PTHREAD_INC
143 pthreadinc= -I$(PTHREAD_INC)
144 !endif
146 #----------------------------------------------------------------
147 # Build options
149 cincdirs=$(cincdirs) -I$(INCDIR) -I$(INCDIR)\krb5 $(pthreadinc)
150 cdefines=$(cdefines) -DHAVE_CONFIG_H
151 cwarn=$(cwarn) -D_CRT_SECURE_NO_WARNINGS -wd4996 -wd4127 -wd4244 -wd4100
153 !if "$(CPU)"=="i386"
154 libmach=/machine:X86
155 !elseif "$(CPU)"=="AMD64"
156 libmach=/machine:X64
157 !else
158 !  error Unknown CPU value
159 !endif
161 !ifndef STATICRUNTIME
163 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsdll) $(AUXCFLAGS) $(cdefines) $(cincdirs) $(cwarn)
164 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsdll)
165 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsdll)
166 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsdll)
167 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsdll)
169 !else # STATICRUNTIME
171 C2OBJ_C = $(CC) $(cdebug) $(cflags) $(cvarsmt) $(AUXCFLAGS) $(cdefines) $(cincdirs) $(cwarn)
172 EXECONLINK_C = $(LINK) $(ldebug) $(conlflags) $(conlibsmt)
173 EXEGUILINK_C = $(LINK) $(ldebug) $(guilflags) $(guilibsmt)
174 DLLCONLINK_C = $(LINK) $(ldebug) $(dlllflags) $(conlibsmt)
175 DLLGUILINK_C = $(LINK) $(ldebug) $(dlllflags) $(guilibsmt)
177 !endif
179 LIBGUI_C = $(LM) /nologo $(libmach) /SUBSYSTEM:WINDOWS
180 LIBCON_C = $(LM) /nologo $(libmach) /SUBSYSTEM:CONSOLE
182 C2OBJ = $(C2OBJ_C) -Fo$@ -Fd$(@D)\ $**
183 EXECONLINK = $(EXECONLINK_C) -OUT:$@ $**
184 EXEGUILINK = $(EXEGUILINK_C) -OUT:$@ $**
185 DLLCONLINK = $(DLLCONLINK_C) -OUT:$@ $**
186 DLLGUILINK = $(DLLGUILINK_C) -OUT:$@ $**
187 LIBGUI = $(LIBGUI_C) /OUT:$@ $**
188 LIBCON = $(LIBCON_C) /OUT:$@ $**
190 # Preprocess files to stdout using config.h
191 CPREPROCESSOUT = $(CC) /EP /FI$(INCDIR)\config.h /TC /DCPP_ONLY=1
193 # Resources
195 RC2RES_C = $(RC) $(cincdirs) $(AUXRCFLAGS)
196 RC2RES = $(RC2RES_C) -fo $@ $**
198 #----------------------------------------------------------------------
199 # If this is the initial invocation, we check if all the build
200 # utilities are there.  Also show the commands macros.
202 !ifndef RECURSE
204 check-utils:
205         @for %%g in ( "$(AWK)" "$(YACC)" "$(LEX)" "$(PYTHON)" "$(PERL)" "$(CMP)" ) do @( \
206         for /f %%f in ( "%%g" ) do @( \
207                 if exist %%f @( \
208                         echo Found %%f \
209                 ) else if "%%~$$PATH:f"=="" @( \
210                         echo Could not find %%f in PATH && \
211                         exit /b 1 \
212                 ) else @( \
213                         echo Found %%~$$PATH:f \
214                 ) \
215         ) \
216         )
217         @for %%g in ( "$(SH)" "$(SED)" ) do @( \
218         for /f %%f in ( "%%g" ) do @( \
219                 if exist %%f @( \
220                         echo Found %%f \
221                 ) else if "%%~$$PATH:f"=="" @( \
222                         echo Could not find %%f in PATH && \
223                         echo Test targets may fail. \
224                 ) else @( \
225                         echo Found %%~$$PATH:f \
226                 ) \
227         ) \
228         )
231 prep:: check-utils
233 show-cmds:
234         @$(ECHO) C2OBJ=$(C2OBJ_C:\=\\)
235         @$(ECHO).
236         @$(ECHO) EXECONLINK=$(EXECONLINK_C)
237         @$(ECHO).
238         @$(ECHO) EXEGUILINK=$(EXEGUILINK_C)
239         @$(ECHO).
240         @$(ECHO) DLLCONLINK=$(DLLCONLINK_C)
241         @$(ECHO).
242         @$(ECHO) DLLGUILINK=$(DLLGUILINK_C)
243         @$(ECHO).
244         @$(ECHO) LIBGUI=$(LIBGUI_C)
245         @$(ECHO).
246         @$(ECHO) LIBCON=$(LIBCON_C)
248 prep:: show-cmds
250 !endif
252 {}.c{$(OBJ)}.obj:
253         $(C2OBJ)
255 {$(OBJ)}.c{$(OBJ)}.obj:
256         $(C2OBJ)
258 {}.cpp{$(OBJ)}.obj:
259         $(C2OBJ)
261 {$(OBJ)}.cpp{$(OBJ)}.obj:
262         $(C2OBJ)
264 {}.hin{$(INCDIR)}.h:
265         $(CP) $< $@
267 {}.h{$(INCDIR)}.h:
268         $(CP) $< $@
270 {}.h{$(INCDIR)\krb5}.h:
271         $(CP) $< $@
273 {$(OBJ)}.h{$(INCDIR)}.h:
274         $(CP) $< $@
276 {$(OBJ)}.x{$(OBJ)}.c:
277         $(CP) $< $@
279 {$(OBJ)}.hx{$(INCDIR)}.h:
280         $(CP) $< $@
282 {$(OBJ)}.hx{$(OBJ)}.h:
283         $(CP) $< $@
285 {}.rc{$(OBJ)}.res:
286         $(RC2RES)
288 #----------------------------------------------------------------------
289 # Announce the build directory
291 !ifdef RELDIR
292 all:: announce
294 test:: announce
296 clean:: announce
298 announce:
299         @echo.
300         @echo --------- Entering $(RELDIR:\= ):
301 !endif
303 #----------------------------------------------------------------------
304 # Create any required directories if they don't already exist
306 prep:: mkdirs
308 mkdirs:
309 !  if !exist($(OBJ))
310         $(MKDIR) $(OBJ)
311 !  endif
312 !  if !exist($(DESTDIR))
313         $(MKDIR) $(DESTDIR)
314 !  endif
315 !  if !exist($(LIBDIR))
316         $(MKDIR) $(LIBDIR)
317 !  endif
318 !  if !exist($(BINDIR))
319         $(MKDIR) $(BINDIR)
320 !  endif
321 !  if !exist($(INCDIR))
322         $(MKDIR) $(INCDIR)
323 !  endif
324 !  if !exist($(INCDIR)\gssapi)
325         $(MKDIR) $(INCDIR)\gssapi
326 !  endif
327 !  if !exist($(INCDIR)\hcrypto)
328         $(MKDIR) $(INCDIR)\hcrypto
329 !  endif
330 !  if !exist($(INCDIR)\kadm5)
331         $(MKDIR) $(INCDIR)\kadm5
332 !  endif
333 !  if !exist($(INCDIR)\krb5)
334         $(MKDIR) $(INCDIR)\krb5
335 !  endif
337 #----------------------------------------------------------------------
338 # If SUBDIRS is defined, we should recurse into the subdirectories
340 !ifdef SUBDIRS
341 subdirs:
342         @for %%f in ( $(SUBDIRS) ) do @ (cd %%f && $(RMAKE) && cd ..) || exit /b 1
344 clean-subdirs:
345         @for %%f in ( $(SUBDIRS) ) do @ (cd %%f && $(RMAKE) clean && cd ..) || exit /b 1
347 test-subdirs:
348         @for %%f in ( $(SUBDIRS) ) do @ (cd %%f && $(RMAKE) test && cd ..) || exit /b 1
350 all:: subdirs
352 clean:: clean-subdirs
354 test:: test-subdirs
356 !endif
358 #----------------------------------------------------------------------
359 # Clean targets
361 !ifdef CLEANFILES
362 clean::
363         -$(RM) $(CLEANFILES)
364 !endif
365 !ifdef RELDIR
366 clean::
367         -$(RM) $(OBJ)\*.*
368 !endif
370 .SUFFIXES: .c .cpp .hin .h .x .hx
372 #----------------------------------------------------------------------
373 # Manifest handling
375 # Starting with Visual Studio 8, the C compiler and the linker
376 # generate manifests so that the applications will link with the
377 # correct side-by-side DLLs at run-time.  These are required for
378 # correct operation under Windows XP and later.  We also have custom
379 # manifests which need to be merged with the manifests that VS
380 # creates.
382 # The syntax for invoking the _VC_MANIFEST_EMBED_FOO macro is:
383 # $(_VC_MANIFEST_EMBED_???) <additional manifests>
386 MT=mt.exe -nologo
388 _VC_MANIFEST_EMBED_EXE= \
389 if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest
391 _VC_MANIFEST_EMBED_DLL= \
392 if exist $@.manifest $(MT) -outputresource:$@;2 -manifest $@.manifest
394 # Note that if you are merging manifests, then the VS generated
395 # manifest should be cleaned up after calling _VC_MANIFEST_EMBED_???.
396 # This ensures that even if the DLL or EXE is executed in-place, the
397 # embedded manifest will be used.  Otherwise the $@.manifest file will
398 # be used.
400 _VC_MANIFEST_CLEAN= \
401 if exist $@.manifest $(RM) $@.manifest
403 # End of manifest handling
405 # Code signing
406 !ifdef CODESIGN
407 _CODESIGN=$(CODESIGN) $@
408 !else
409 _CODESIGN=
410 !endif
412 #----------------------------------------------------------------------
413 # Convenience macros for preparing EXEs and DLLs.  These are multiline
414 # macros that deal with manifests and code signing.  Unless we need to
415 # include custom manifests, these are what we should be using to
416 # prepare binaries.
418 EXEPREP=\
419 $(_VC_MANIFEST_EMBED_EXE)^
420 $(_VC_MANIFEST_CLEAN)^
421 $(_CODESIGN)
423 EXEPREP_NODIST=\
424 $(_VC_MANIFEST_EMBED_EXE)^
425 $(_VC_MANIFEST_CLEAN)
427 DLLPREP=\
428 $(_VC_MANIFEST_EMBED_DLL)^
429 $(_VC_MANIFEST_CLEAN)^
430 $(_CODESIGN)
432 DLLPREP_NODIST=\
433 $(_VC_MANIFEST_EMBED_DLL)^
434 $(_VC_MANIFEST_CLEAN)
436 #----------------------------------------------------------------------
437 # Convenience macros for import libraries
440 LIBROKEN    =$(LIBDIR)\libroken.lib
441 LIBVERS     =$(LIBDIR)\libvers.lib
442 LIBEDITLINE =$(LIBDIR)\libeditline.lib
443 LIBCOMERR   =$(LIBDIR)\libcom_err.lib
444 LIBSL       =$(LIBDIR)\libsl.lib
445 LIBWIND     =$(LIBDIR)\libwind.lib
446 LIBASN1     =$(LIBDIR)\libasn1.lib
447 LIBSQLITE   =$(LIBDIR)\libsqlite.lib
448 LIBHCRYPTO  =$(LIBDIR)\libhcrypto.lib
449 LIBHX509    =$(LIBDIR)\libhx509.lib
450 LIBKRB5     =$(LIBDIR)\libkrb5.lib
451 LIBHEIMNTLM =$(LIBDIR)\libheimntlm.lib
452 LIBHEIMIPCC =$(LIBDIR)\libheim-ipcc.lib
453 LIBHEIMIPCS =$(LIBDIR)\libheim-ipcs.lib
454 LIBGSSAPI   =$(LIBDIR)\libgssapi.lib
455 LIBHDB      =$(LIBDIR)\libhdb.lib
456 LIBKADM5SRV =$(LIBDIR)\libkadm5srv.lib
457 LIBKADM5CLNT=$(LIBDIR)\libkadm5clnt.lib
458 LIBKDC      =$(LIBDIR)\libkdc.lib
459 LIBLTM      =$(LIBDIR)\libltm.lib