merge the formfield patch from ooo-build
[ooovba.git] / tools / bootstrp / mkcreate.cxx
blob83a4427be12a18728c9075a1fc30667061fb70ba
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mkcreate.cxx,v $
11 * $Revision: 1.18 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_tools.hxx"
35 // global includes
36 #include <stdio.h>
38 // local includes
39 #include "bootstrp/mkcreate.hxx"
40 #include "bootstrp/inimgr.hxx"
41 #include "bootstrp/appdef.hxx"
42 #include <tools/geninfo.hxx>
43 #include <tools/iparser.hxx>
44 #include "bootstrp/prj.hxx"
46 char const *NoBuildProject[] = {
47 "solenv",
48 "EndOf_NoBuildProject"
51 char const *LimitedPath[] = {
52 "jurt\\com\\sun\\star",
53 "r_tools",
54 "ridljar",
55 "setup2",
56 "connectivity",
57 "EndOf_LimitedPath"
61 // class SourceDirectory
64 /*****************************************************************************/
65 SourceDirectory::SourceDirectory( const ByteString &rDirectoryName,
66 USHORT nOperatingSystem, SourceDirectory *pParentDirectory )
67 /*****************************************************************************/
68 : ByteString( rDirectoryName ),
69 pParent( pParentDirectory ),
70 pSubDirectories( NULL ),
71 nOSType( nOperatingSystem ),
72 nDepth( 0 ),
73 pDependencies( NULL ),
74 pCodedDependencies( NULL ),
75 pCodedIdentifier( NULL )
77 if ( pParent ) {
78 if ( !pParent->pSubDirectories )
79 pParent->pSubDirectories = new SourceDirectoryList();
80 pParent->pSubDirectories->InsertSorted( this );
81 nDepth = pParent->nDepth + 1;
85 /*****************************************************************************/
86 SourceDirectory::~SourceDirectory()
87 /*****************************************************************************/
89 delete pSubDirectories;
92 /*****************************************************************************/
93 CodedDependency *SourceDirectory::AddCodedDependency(
94 const ByteString &rCodedIdentifier, USHORT nOperatingSystems )
95 /*****************************************************************************/
97 CodedDependency *pReturn = NULL;
99 if ( !pCodedDependencies ) {
100 pCodedDependencies = new SByteStringList();
101 pReturn = new CodedDependency( rCodedIdentifier, nOperatingSystems );
102 pCodedDependencies->PutString(( ByteString * ) pReturn );
104 else {
105 ULONG nPos =
106 pCodedDependencies->IsString( (ByteString *) (& rCodedIdentifier) );
107 if ( nPos == NOT_THERE ) {
108 pReturn =
109 new CodedDependency( rCodedIdentifier, nOperatingSystems );
110 pCodedDependencies->PutString(( ByteString * ) pReturn );
112 else {
113 pReturn =
114 ( CodedDependency * ) pCodedDependencies->GetObject( nPos );
115 pReturn->TryToMerge( rCodedIdentifier, nOperatingSystems );
118 return pReturn;
121 /*****************************************************************************/
122 CodedDependency *SourceDirectory::AddCodedIdentifier(
123 const ByteString &rCodedIdentifier, USHORT nOperatingSystems )
124 /*****************************************************************************/
126 CodedDependency *pReturn = NULL;
128 if ( !pCodedIdentifier ) {
129 pCodedIdentifier = new SByteStringList();
130 pReturn = new CodedDependency( rCodedIdentifier, nOperatingSystems );
131 pCodedIdentifier->PutString(( ByteString * ) pReturn );
133 else {
134 ULONG nPos =
135 pCodedIdentifier->IsString( ( ByteString *) (& rCodedIdentifier) );
136 if ( nPos == NOT_THERE ) {
137 pReturn =
138 new CodedDependency( rCodedIdentifier, nOperatingSystems );
139 pCodedIdentifier->PutString(( ByteString * ) pReturn );
141 else {
142 pReturn =
143 ( CodedDependency * ) pCodedIdentifier->GetObject( nPos );
144 pReturn->TryToMerge( rCodedIdentifier, nOperatingSystems );
147 if ( pParent && pParent->nDepth > 1 )
148 pParent->AddCodedIdentifier( rCodedIdentifier, nOperatingSystems );
150 return pReturn;
153 /*****************************************************************************/
154 ByteString SourceDirectory::GetFullPath()
155 /*****************************************************************************/
157 ByteString sFullPath;
158 if ( pParent ) {
159 sFullPath = pParent->GetFullPath();
160 sFullPath += ByteString( PATH_SEPARATOR );
162 sFullPath += *this;
164 return sFullPath;
167 /*****************************************************************************/
168 SourceDirectory *SourceDirectory::GetRootDirectory()
169 /*****************************************************************************/
171 if ( !pParent )
172 return this;
174 return pParent->GetRootDirectory();
177 /*****************************************************************************/
178 SourceDirectory *SourceDirectory::GetSubDirectory(
179 const ByteString &rDirectoryPath, USHORT nOperatingSystem )
180 /*****************************************************************************/
182 ByteString sSearch;
184 BOOL bSubs = TRUE;
185 ULONG nIndex = 0;
187 while ( bSubs && ByteString( LimitedPath[ nIndex ]) != "EndOf_LimitedPath" ) {
188 SourceDirectory *pActDir = this;
189 ByteString sLimitation( LimitedPath[ nIndex ]);
191 BOOL bBreak = FALSE;
192 for ( ULONG i = sLimitation.GetTokenCount( '\\' ); i > 0 && !bBreak; i-- ) {
193 if (( !pActDir ) || ( *pActDir != sLimitation.GetToken(( USHORT )( i - 1 ), '\\' )))
194 bBreak = TRUE;
195 else
196 pActDir = pActDir->pParent;
198 bSubs = bBreak;
199 nIndex++;
202 if ( !bSubs )
204 sSearch = rDirectoryPath;
206 else
207 sSearch = rDirectoryPath.GetToken( 0, PATH_SEPARATOR );
209 SourceDirectory *pSubDirectory = NULL;
211 if ( pSubDirectories )
212 pSubDirectory = pSubDirectories->Search( sSearch );
214 if ( !pSubDirectory )
215 pSubDirectory = new SourceDirectory(
216 sSearch, nOperatingSystem, this );
218 pSubDirectory->nOSType |= nOperatingSystem;
220 if ( sSearch.Len() == rDirectoryPath.Len())
221 return pSubDirectory;
223 ByteString sPath = rDirectoryPath.Copy( sSearch.Len() + 1 );
225 return pSubDirectory->GetSubDirectory( sPath, nOperatingSystem );
228 /*****************************************************************************/
229 SourceDirectory *SourceDirectory::GetDirectory(
230 const ByteString &rDirectoryName, USHORT nOperatingSystem )
231 /*****************************************************************************/
233 ByteString sDirectoryName( rDirectoryName );
234 #ifdef UNX
235 sDirectoryName.SearchAndReplaceAll( "\\", "/" );
236 #endif
238 SourceDirectory *pRoot = GetRootDirectory();
240 if ( sDirectoryName.Search( *pRoot ) != 0 )
241 return NULL;
243 if ( sDirectoryName.Len() == pRoot->Len())
244 return pRoot;
246 if ( sDirectoryName.GetChar( pRoot->Len()) == PATH_SEPARATOR ) {
247 ByteString sSub = sDirectoryName.Copy( pRoot->Len() + 1 );
248 return pRoot->GetSubDirectory( sSub, nOperatingSystem );
251 return NULL;
254 /*****************************************************************************/
255 SourceDirectory *SourceDirectory::Insert( const ByteString &rDirectoryName,
256 USHORT nOperatingSystem )
257 /*****************************************************************************/
259 SourceDirectory *pSubDirectory = NULL;
260 if ( pSubDirectories )
261 pSubDirectory = pSubDirectories->Search( rDirectoryName );
263 if ( !pSubDirectory )
264 pSubDirectory = new SourceDirectory(
265 rDirectoryName, nOperatingSystem, this );
267 return pSubDirectory;
270 /*****************************************************************************/
271 Dependency *SourceDirectory::ResolvesDependency(
272 CodedDependency *pCodedDependency )
273 /*****************************************************************************/
275 if ( !pCodedIdentifier )
276 return NULL;
278 ULONG nPos = pCodedIdentifier->IsString( pCodedDependency );
279 if ( nPos != NOT_THERE ) {
280 CodedDependency *pIdentifier =
281 ( CodedDependency * ) pCodedIdentifier->GetObject( nPos );
282 USHORT nResult =
283 pIdentifier->GetOperatingSystem() &
284 pCodedDependency->GetOperatingSystem();
285 Dependency *pReturn = new Dependency( *this, nResult );
286 nResult ^= pCodedDependency->GetOperatingSystem();
287 pCodedDependency->SetOperatingSystem( nResult );
288 return pReturn;
290 return NULL;
294 /*****************************************************************************/
295 void SourceDirectory::ResolveDependencies()
296 /*****************************************************************************/
298 if ( !pSubDirectories )
299 return;
301 for ( ULONG i = 0; i < pSubDirectories->Count(); i++ ) {
302 SourceDirectory *pActDirectory =
303 ( SourceDirectory * ) pSubDirectories->GetObject( i );
304 if ( pActDirectory->pSubDirectories )
305 pActDirectory->ResolveDependencies();
307 if ( pActDirectory->pCodedDependencies ) {
308 while ( pActDirectory->pCodedDependencies->Count())
310 CodedDependency *pCodedDependency = ( CodedDependency * )
311 pActDirectory->pCodedDependencies->GetObject(( ULONG ) 0 );
313 for (
314 ULONG k = 0;
315 ( k < pSubDirectories->Count()) &&
316 ( pCodedDependency->GetOperatingSystem() != OS_NONE );
319 Dependency *pDependency =
320 ((SourceDirectory *) pSubDirectories->GetObject( k ))->
321 ResolvesDependency( pCodedDependency );
322 if ( pDependency )
324 if ( !pActDirectory->pDependencies )
325 pActDirectory->pDependencies = new SByteStringList();
326 pActDirectory->pDependencies->PutString( pDependency );
329 if ( pCodedDependency->GetOperatingSystem()) {
330 if ( !pCodedDependencies )
331 pCodedDependencies = new SByteStringList();
332 pCodedDependencies->PutString( pCodedDependency );
334 else
335 delete pCodedDependency;
336 pActDirectory->pCodedDependencies->Remove(( ULONG ) 0 );
342 /*****************************************************************************/
343 ByteString SourceDirectory::GetTarget()
344 /*****************************************************************************/
346 ByteString sReturn;
348 if ( !pDependencies )
349 return sReturn;
351 ULONG k = 0;
352 while ( k < pDependencies->Count()) {
353 if ( *this == *pDependencies->GetObject( k ))
354 delete pDependencies->Remove( k );
355 else
356 k++;
359 if ( !pDependencies->Count()) {
360 delete pDependencies;
361 pDependencies = NULL;
362 return sReturn;
365 BOOL bDependsOnPlatform = FALSE;
366 for ( ULONG i = 0; i < pDependencies->Count(); i++ )
367 if ((( Dependency * ) pDependencies->GetObject( i ))->
368 GetOperatingSystem() != OS_ALL )
369 bDependsOnPlatform = TRUE;
371 ByteString sTarget( *this );
372 sTarget.SearchAndReplaceAll( "\\", "$/" );
373 if ( !bDependsOnPlatform ) {
374 sReturn = sTarget;
375 sReturn += " :";
376 for ( ULONG i = 0; i < pDependencies->Count(); i++ ) {
377 ByteString sDependency( *pDependencies->GetObject( i ));
378 sDependency.SearchAndReplaceAll( "\\", "$/" );
379 sReturn += " ";
380 sReturn += sDependency;
383 else {
384 ByteString sUNX( ".IF \"$(GUI)\" == \"UNX\"\n" );
385 sUNX += sTarget;
386 sUNX += " :";
387 BOOL bUNX = FALSE;
389 ByteString sWNT( ".IF \"$(GUI)\" == \"WNT\"\n" );
390 sWNT += sTarget;
391 sWNT += " :";
392 BOOL bWNT = FALSE;
394 ByteString sOS2( ".IF \"$(GUI)\" == \"OS2\"\n" );
395 sOS2 += sTarget;
396 sOS2 += " :";
397 BOOL bOS2 = FALSE;
399 for ( ULONG i = 0; i < pDependencies->Count(); i++ ) {
400 Dependency *pDependency =
401 ( Dependency * ) pDependencies->GetObject( i );
402 ByteString sDependency( *pDependency );
403 sDependency.SearchAndReplaceAll( "\\", "$/" );
405 if ( pDependency->GetOperatingSystem() & OS_UNX ) {
406 sUNX += " ";
407 sUNX += sDependency;
408 bUNX = TRUE;
410 if ( pDependency->GetOperatingSystem() & OS_WIN32 ) {
411 sWNT += " ";
412 sWNT += sDependency;
413 bWNT = TRUE;
415 if ( pDependency->GetOperatingSystem() & OS_OS2 ) {
416 sOS2 += " ";
417 sOS2 += sDependency;
418 bOS2 = TRUE;
422 if ( bUNX ) {
423 sReturn += sUNX;
424 sReturn += "\n.ENDIF\n";
426 if ( bWNT ) {
427 sReturn += sWNT;
428 sReturn += "\n.ENDIF\n";
430 if ( bOS2 ) {
431 sReturn += sOS2;
432 sReturn += "\n.ENDIF\n";
435 sReturn.EraseTrailingChars( '\n' );
436 return sReturn;
439 /*****************************************************************************/
440 ByteString SourceDirectory::GetSubDirsTarget()
441 /*****************************************************************************/
443 ByteString sReturn;
445 if ( pSubDirectories ) {
446 BOOL bDependsOnPlatform = FALSE;
447 for ( ULONG i = 0; i < pSubDirectories->Count(); i++ )
448 if ((( SourceDirectory * ) pSubDirectories->GetObject( i ))->
449 GetOperatingSystems() != OS_ALL )
450 bDependsOnPlatform = TRUE;
452 if ( !bDependsOnPlatform ) {
453 sReturn = "RC_SUBDIRS = ";
455 for ( ULONG i = 0; i < pSubDirectories->Count(); i++ ) {
456 ByteString sSubDirectory( *pSubDirectories->GetObject( i ));
457 sSubDirectory.SearchAndReplaceAll( "\\", "$/" );
458 sReturn += " \\\n\t";
459 sReturn += sSubDirectory;
461 sReturn += "\n";
463 else {
464 ByteString sUNX( ".IF \"$(GUI)\" == \"UNX\"\n" );
465 sUNX += "RC_SUBDIRS = ";
466 BOOL bUNX = FALSE;
468 ByteString sWNT( ".IF \"$(GUI)\" == \"WNT\"\n" );
469 sWNT += "RC_SUBDIRS = ";
470 BOOL bWNT = FALSE;
472 ByteString sOS2( ".IF \"$(GUI)\" == \"OS2\"\n" );
473 sOS2 += "RC_SUBDIRS = ";
474 BOOL bOS2 = FALSE;
476 for ( ULONG i = 0; i < pSubDirectories->Count(); i++ ) {
477 SourceDirectory *pDirectory =
478 ( SourceDirectory * ) pSubDirectories->GetObject( i );
479 ByteString sDirectory( *pDirectory );
480 sDirectory.SearchAndReplaceAll( "\\", "$/" );
482 if ( pDirectory->GetOperatingSystems() & OS_UNX ) {
483 sUNX += " \\\n\t";
484 sUNX += sDirectory;
485 bUNX = TRUE;
487 if ( pDirectory->GetOperatingSystems() & OS_WIN32 ) {
488 sWNT += " \\\n\t";
489 sWNT += sDirectory;
490 bWNT = TRUE;
492 if ( pDirectory->GetOperatingSystems() & OS_OS2 ) {
493 sOS2 += " \\\n\t";
494 sOS2 += sDirectory;
495 bOS2 = TRUE;
498 if ( bUNX ) {
499 sReturn += sUNX;
500 sReturn += "\n.ENDIF\n";
502 if ( bWNT ) {
503 sReturn += sWNT;
504 sReturn += "\n.ENDIF\n";
506 if ( bOS2 ) {
507 sReturn += sOS2;
508 sReturn += "\n.ENDIF\n";
512 return sReturn;
515 /*****************************************************************************/
516 USHORT SourceDirectory::GetOSType( const ByteString &sDependExt )
517 /*****************************************************************************/
519 USHORT nOSType = 0;
520 if ( sDependExt == "" )
521 nOSType |= OS_ALL;
522 else if ( sDependExt == "N" || sDependExt == "W" )
523 nOSType |= OS_WIN32;
524 else if ( sDependExt == "U" )
525 nOSType |= OS_UNX;
526 else if ( sDependExt == "P" )
527 nOSType |= OS_OS2;
528 return nOSType;
531 /*****************************************************************************/
532 SourceDirectory *SourceDirectory::CreateRootDirectory(
533 const ByteString &rRoot, const ByteString &rVersion, BOOL bAll )
534 /*****************************************************************************/
536 IniManager aIniManager;
537 aIniManager.Update();
539 ByteString sDefLst( GetDefStandList());
540 ByteString sStandLst( aIniManager.ToLocal( sDefLst ));
541 String s = String( sStandLst, gsl_getSystemTextEncoding());
542 InformationParser aParser;
543 // fprintf( stderr,
544 // "Reading database %s ...\n", sStandLst.GetBuffer());
545 GenericInformationList *pVerList = aParser.Execute(
546 s );
549 ByteString sPath( rVersion );
550 #ifndef UNX
551 sPath += ByteString( "/settings/solarlist" );
552 #else
553 sPath += ByteString( "/settings/unxsolarlist" );
554 #endif
555 ByteString sSolarList( _SOLARLIST );
557 GenericInformation *pInfo = pVerList->GetInfo( sPath, TRUE );
558 if ( pInfo ) {
559 ByteString aIniRoot( GetIniRoot() );
560 DirEntry aIniEntry( String( aIniRoot, RTL_TEXTENCODING_ASCII_US ));
561 aIniEntry += DirEntry( String( pInfo->GetValue(), RTL_TEXTENCODING_ASCII_US )).GetBase( PATH_SEPARATOR );
562 sSolarList = ByteString( aIniEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
565 sSolarList = aIniManager.ToLocal( sSolarList );
566 fprintf( stderr,
567 "Reading directory information %s ...\n", sSolarList.GetBuffer());
570 ByteString sVersion( rVersion );
571 Star aStar( pVerList, sVersion, TRUE, rRoot.GetBuffer());
572 // fprintf( stderr,
573 // "Creating virtual directory tree ...\n" );
576 SourceDirectory *pSourceRoot = new SourceDirectory( rRoot, OS_ALL );
578 for ( ULONG i = 0; i < aStar.Count(); i++ ) {
579 Prj *pPrj = aStar.GetObject( i );
581 BOOL bBuildable = TRUE;
582 ULONG nIndex = 0;
584 while ( bBuildable && ByteString( NoBuildProject[ nIndex ]) != "EndOf_NoBuildProject" ) {
585 bBuildable = ( ByteString( NoBuildProject[ nIndex ]) != pPrj->GetProjectName());
586 nIndex ++;
589 if ( bBuildable ) {
590 SourceDirectory *pProject = pSourceRoot->Insert( pPrj->GetProjectName(), OS_ALL );
592 SByteStringList *pPrjDependencies = pPrj->GetDependencies( FALSE );
593 if ( pPrjDependencies )
594 for ( ULONG x = 0; x < pPrjDependencies->Count(); x++ )
595 pProject->AddCodedDependency( *pPrjDependencies->GetObject( x ), OS_ALL );
597 pProject->AddCodedIdentifier( pPrj->GetProjectName(), OS_ALL );
599 for ( ULONG j = 0; j < pPrj->Count(); j++ ) {
600 CommandData *pData = pPrj->GetObject( j );
601 if ( bAll || ( pData->GetCommandType() == COMMAND_NMAKE )) {
602 ByteString sDirPath( rRoot );
603 sDirPath += ByteString( PATH_SEPARATOR );
604 sDirPath += pData->GetPath();
605 SourceDirectory *pDirectory =
606 pSourceRoot->InsertFull( sDirPath, pData->GetOSType());
607 SByteStringList *pDependencies = pData->GetDependencies();
608 if ( pDependencies ) {
609 for ( ULONG k = 0; k < pDependencies->Count(); k++ ) {
610 ByteString sDependency(*pDependencies->GetObject( k ));
611 ByteString sDependExt(sDependency.GetToken( 1, '.' ));
612 sDependExt.ToUpperAscii();
613 pDirectory->AddCodedDependency(
614 sDependency.GetToken( 0, '.' ), GetOSType( sDependExt ));
617 ByteString sIdentifier = pData->GetLogFile();
618 ByteString sIdExt = sIdentifier.GetToken( 1, '.' );
619 sIdExt.ToUpperAscii();
620 pDirectory->AddCodedIdentifier( sIdentifier.GetToken( 0, '.' ), GetOSType( sIdExt ));
625 delete pVerList;
626 return pSourceRoot;
629 /*****************************************************************************/
630 BOOL SourceDirectory::RemoveDirectoryTreeAndAllDependencies()
631 /*****************************************************************************/
633 if ( !pParent )
634 return FALSE;
636 SourceDirectoryList *pParentContent = pParent->pSubDirectories;
637 ULONG i = 0;
638 while ( i < pParentContent->Count()) {
639 SourceDirectory *pCandidate =
640 ( SourceDirectory * )pParentContent->GetObject( i );
641 if ( pCandidate == this ) {
642 pParentContent->Remove( i );
644 else {
645 if ( pCandidate->pDependencies ) {
646 ULONG nPos = pCandidate->pDependencies->IsString( this );
647 if ( nPos != NOT_THERE )
648 delete pCandidate->pDependencies->Remove( nPos );
650 i++;
653 delete this;
654 return TRUE;
657 /*****************************************************************************/
658 BOOL SourceDirectory::CreateRecursiveMakefile( BOOL bAllChilds )
659 /*****************************************************************************/
661 if ( !pSubDirectories )
662 return TRUE;
664 fprintf( stdout, "%s", GetFullPath().GetBuffer());
666 String aTmpStr( GetFullPath(), gsl_getSystemTextEncoding());
667 DirEntry aEntry( aTmpStr );
668 if ( !aEntry.Exists()) {
669 fprintf( stdout, " ... no directory!n" );
670 return FALSE;
673 ULONG j = 0;
674 while( j < pSubDirectories->Count()) {
675 String sSubDirectory(
676 (( SourceDirectory * ) pSubDirectories->GetObject( j ))->
677 GetFullPath(),
678 gsl_getSystemTextEncoding()
680 DirEntry aSubDirectory( sSubDirectory );
681 if ( !aSubDirectory.Exists())
682 (( SourceDirectory * ) pSubDirectories->GetObject( j ))->
683 RemoveDirectoryTreeAndAllDependencies();
684 else
685 j++;
688 DirEntry aRCFile( String( "makefile.rc", gsl_getSystemTextEncoding()));
689 DirEntry aRCEntry( aEntry );
690 aRCEntry += aRCFile;
692 DirEntry aMKFile( String( "makefile.mk", gsl_getSystemTextEncoding()));
693 DirEntry aMKEntry( aEntry );
694 aMKEntry += aMKFile;
696 BOOL bMakefileMk = FALSE;
697 if ( aMKEntry.Exists()) {
698 if ( nDepth == 1 && *this == ByteString( "api" ))
699 fprintf( stdout, " ... makefile.mk exists, ignoring (hack: prj == api)!" );
700 else {
701 fprintf( stdout, " ... makefile.mk exists, including!" );
702 bMakefileMk = TRUE;
706 SvFileStream aMakefile( aRCEntry.GetFull(), STREAM_STD_WRITE | STREAM_TRUNC );
707 if ( !aMakefile.IsOpen()) {
708 fprintf( stdout, " ... failed!\n" );
709 return FALSE;
712 ByteString sHeader(
713 "#*************************************************************************\n"
714 "#\n"
715 "# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n"
716 "#\n"
717 "# Copyright 2008 by Sun Microsystems, Inc.\n"
718 "#\n"
719 "# OpenOffice.org - a multi-platform office productivity suite\n"
720 "#\n"
721 "# $RCSfile: mkcreate.cxx,v $\n"
722 "#\n"
723 "# $Revision: 1.18 $\n"
724 "#\n"
725 "# This file is part of OpenOffice.org.\n"
726 "#\n"
727 "# OpenOffice.org is free software: you can redistribute it and/or modify\n"
728 "# it under the terms of the GNU Lesser General Public License version 3\n"
729 "# only, as published by the Free Software Foundation.\n"
730 "#\n"
731 "# OpenOffice.org is distributed in the hope that it will be useful,\n"
732 "# but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
733 "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
734 "# GNU Lesser General Public License version 3 for more details\n"
735 "# (a copy is included in the LICENSE file that accompanied this code).\n"
736 "#\n"
737 "# You should have received a copy of the GNU Lesser General Public License\n"
738 "# version 3 along with OpenOffice.org. If not, see\n"
739 "# <http://www.openoffice.org/license.html>\n"
740 "# for a copy of the LGPLv3 License.\n"
741 "#\n"
742 "#*************************************************************************\n"
743 "\n"
745 if ( !bMakefileMk ) {
746 if ( nDepth == 0 ) {
747 sHeader += ByteString(
748 "\n"
749 "# \n"
750 "# mark this makefile as a recursive one\n"
751 "# \n"
752 "\n"
753 "MAKEFILERC=yes\n"
754 "\n"
755 "# \n"
756 "# implementation of cvs checkout\n"
757 "# \n"
758 "\n"
759 ".IF \"$(checkout)\"==\"\"\n"
760 "all_target: ALLTAR\n"
761 ".ELSE\t# \"$(checkout)\"==\"\"\n"
762 ".IF \"$(checkout)\"==\"true\"\n"
763 "% : $(NULL)\n"
764 "\t_cvs co $@\n"
765 ".ELSE\t# \"$(checkout)\"==\"true\"\n"
766 "% : $(NULL)\n"
767 "\t_cvs co -r$(checkout) $@\n"
768 ".ENDIF\t# \"$(checkout)\"==\"true\"\n"
769 "all_subdirs : $(RC_SUBDIRS)\n"
770 ".ENDIF\t# \"$(checkout)\"==\"\"\n"
773 else {
774 sHeader += ByteString(
775 "\n"
776 "# \n"
777 "# mark this makefile as a recursive one\n"
778 "# \n"
779 "\n"
780 "MAKEFILERC=yes\n"
782 if ( nDepth == 1 )
783 sHeader += ByteString(
784 ".IF \"$(build_deliver)\"==\"true\"\n"
785 "all_target:\t\t\\\n"
786 "\tTG_DELIVER\t\\\n"
787 "\tALLTAR\n"
788 ".ELSE # \"$(build_deliver)\"==\"true\"\n"
789 "all_target: ALLTAR\n"
790 ".ENDIF # \"$(build_deliver)\"==\"true\"\n"
792 else
793 sHeader += ByteString(
794 "all_target: ALLTAR\n"
798 else {
799 if ( nDepth == 1 )
800 sHeader += ByteString(
801 ".IF \"$(build_deliver)\"==\"true\"\n"
802 "all_target:\t\t\\\n"
803 "\tTG_DELIVER\t\\\n"
804 "\tALLTAR\n"
805 ".ELSE # \"$(build_deliver)\"==\"true\"\n"
806 "all_target: ALLTAR\n"
807 ".ENDIF # \"$(build_deliver)\"==\"true\"\n"
810 sHeader += ByteString(
811 "\n"
812 "# \n"
813 "# macro RC_SUBDIRS handles iteration over\n"
814 "# all mandatory sub directories\n"
815 "# \n"
818 aMakefile.WriteLine( sHeader );
819 aMakefile.WriteLine( GetSubDirsTarget());
821 if ( nDepth == 0 ) {
822 ByteString sBootstrapTarget(
823 "# \n"
824 "# bootstrap target\n"
825 "# \n\n"
826 "bootstrap .PHONY :\n"
827 "\t@config_office/bootstrap\n\n"
829 aMakefile.WriteLine( sBootstrapTarget );
830 ByteString sConfigureTarget(
831 "# \n"
832 "# configure target\n"
833 "# \n\n"
834 "configure .PHONY SETDIR=config_office :\n"
835 "\t@configure\n"
837 aMakefile.WriteLine( sConfigureTarget );
839 else if ( nDepth == 1 ) {
840 ByteString sDeliverTarget(
841 "# \n"
842 "# deliver target to handle\n"
843 "# project dependencies\n"
844 "# \n\n"
845 "TG_DELIVER : $(RC_SUBDIRS)\n"
846 "\t$(DELIVER)\n"
848 aMakefile.WriteLine( sDeliverTarget );
851 if ( bMakefileMk ) {
852 ByteString sInclude(
853 "# \n"
854 "# local makefile\n"
855 "# \n"
856 "\n"
857 ".INCLUDE : makefile.mk\n"
860 if ( nDepth != 1 )
861 sInclude += ByteString(
862 "\n"
863 "all_rc_target: ALLTAR\n"
866 aMakefile.WriteLine( sInclude );
869 ByteString sComment(
870 "# \n"
871 "# single directory targets for\n"
872 "# dependency handling between directories\n"
873 "# \n"
875 aMakefile.WriteLine( sComment );
877 for ( ULONG i = 0; i < pSubDirectories->Count(); i++ ) {
878 ByteString sTarget(
879 (( SourceDirectory * )pSubDirectories->GetObject( i ))->
880 GetTarget()
882 if ( sTarget.Len())
883 aMakefile.WriteLine( sTarget );
886 ByteString sFooter(
887 "\n"
889 if ( !bMakefileMk ) {
890 sFooter += ByteString(
891 "# \n"
892 "# central target makefile\n"
893 "# \n"
894 "\n"
896 if ( nDepth != 0 ) {
897 sFooter += ByteString(
898 ".INCLUDE : target.mk\n"
901 else {
902 sFooter += ByteString(
903 ".IF \"$(checkout)\"==\"\"\n"
904 ".INCLUDE : target.mk\n"
905 ".ENDIF\t#\"$(checkout)\"==\"\"\n"
909 sFooter += ByteString(
910 "\n"
911 "#*************************************************************************\n"
913 aMakefile.WriteLine( sFooter );
915 aMakefile.Close();
917 fprintf( stdout, "\n" );
919 BOOL bSuccess = TRUE;
920 if ( bAllChilds )
921 for ( ULONG k = 0; k < pSubDirectories->Count(); k++ )
922 if ( !(( SourceDirectory * ) pSubDirectories->GetObject( k ))->
923 CreateRecursiveMakefile( TRUE ))
924 bSuccess = FALSE;
926 return bSuccess;
930 // class SourceDirectoryList
933 /*****************************************************************************/
934 SourceDirectoryList::~SourceDirectoryList()
935 /*****************************************************************************/
937 for ( ULONG i = 0; i < Count(); i++ )
938 delete GetObject( i );
941 /*****************************************************************************/
942 SourceDirectory *SourceDirectoryList::Search(
943 const ByteString &rDirectoryName )
944 /*****************************************************************************/
946 ULONG nPos = IsString( ( ByteString * ) (&rDirectoryName) );
947 if ( nPos != LIST_ENTRY_NOTFOUND )
948 return ( SourceDirectory * ) GetObject( nPos );
950 return NULL;