per-module clean rules, make cabman more *nix/msys friendly

This fix made it so I was able to successfully build a 22.4MB ReactOS.iso from the xmlbuildsystem branch! ( now to test it... )

svn path=/branches/xmlbuildsystem/; revision=13823
This commit is contained in:
Royce Mitchell III 2005-03-05 05:13:38 +00:00
parent c4f496eb04
commit 83cac15e73
10 changed files with 98 additions and 71 deletions

View file

@ -71,5 +71,7 @@ include$(SEP)reactos$(SEP)bugcodes.h ntoskrnl$(SEP)bugcodes.rc: $(WMC_TARGET) nt
include$(SEP)reactos$(SEP)errcodes.h lib$(SEP)kernel32$(SEP)errcodes.rc: $(WMC_TARGET) lib$(SEP)kernel32$(SEP)kernel32.mc
$(WMC_TARGET) -H include$(SEP)reactos$(SEP)errcodes.h -o lib$(SEP)kernel32$(SEP)errcodes.rc lib$(SEP)kernel32$(SEP)kernel32.mc
clean::
.PHONY: makefile_auto_clean
makefile_auto_clean:
-@$(rm) Makefile.auto $(PREAUTO) 2>$(NUL)
clean: makefile_auto_clean

View file

@ -19,9 +19,10 @@ $(RMKDIR_TARGET): $(RMKDIR_OBJECTS)
$(RMKDIR_OBJECTS): %.o : %.c
${host_gcc} $(RMKDIR_HOST_CFLAGS) -c $< -o $@
clean::
.PHONY: rmkdir_clean
rmkdir_clean:
-@$(rm) $(RMKDIR_TARGET) $(RMKDIR_OBJECTS) 2>$(NUL)
clean: rmkdir_clean
BUILDNO_BASE = tools
@ -45,8 +46,10 @@ $(BUILDNO_TARGET): $(BUILDNO_OBJECTS)
$(BUILDNO_OBJECTS): %.o : %.c
${host_gcc} $(BUILDNO_HOST_CFLAGS) -c $< -o $@
clean::
.PHONY: buildno_clean
buildno_clean:
-@$(rm) $(BUILDNO_TARGET) $(BUILDNO_OBJECTS) 2>$(NUL)
clean: buildno_clean
include$(SEP)reactos$(SEP)buildno.h: $(BUILDNO_TARGET)
$(EXEPREFIX)$(BUILDNO_TARGET) include$(SEP)reactos$(SEP)buildno.h

View file

@ -34,7 +34,7 @@ static long _GetSizeOfFile(FILEHANDLE handle)
#define ReadFileData(handle, buffer, size, bytesread) _ReadFileData(handle, buffer, size, bytesread)
static bool _ReadFileData(FILEHANDLE handle, void* buffer, unsigned long size, unsigned long* bytesread)
{
return ReadFile(handle, buffer, size, bytesread, NULL);
return ReadFile(handle, buffer, size, bytesread, NULL) != 0;
}
#else
#define GetSizeOfFile(handle) _GetSizeOfFile(handle)
@ -70,7 +70,7 @@ void DumpBuffer(void* Buffer, unsigned long Size)
0, // No sharing
NULL, // No security
CREATE_ALWAYS, // Create or overwrite
FILE_ATTRIBUTE_NORMAL, // Normal file
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
if (FileHandle == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("ERROR OPENING '%d'.\n", (unsigned int)GetLastError()));
@ -143,7 +143,7 @@ unsigned long CCFDATAStorage::Create(char* FileName)
if ((FileHandle = tmpfile()) == NULL)
return CAB_STATUS_CANNOT_CREATE;
/*
FileHandle = fopen(FullName, "w+b");
FileHandle = fopen(FullName, "w+b");
if (FileHandle == NULL) {
DPRINT(MID_TRACE, ("ERROR '%d'.\n", (unsigned int)errno));
return CAB_STATUS_CANNOT_CREATE;
@ -297,9 +297,15 @@ CCabinet::CCabinet()
* FUNCTION: Default constructor
*/
{
*CabinetName = '\0';
*CabinetPrev = '\0';
*DiskPrev = '\0';
*CabinetNext = '\0';
*DiskNext = '\0';
*DestPath = '\0';
*CabinetReservedFile = '\0';
FileOpen = false;
strcpy(DestPath, "");
strcpy(CabinetReservedFile, "");
CabinetReservedFileBuffer = NULL;
CabinetReservedFileSize = 0;
@ -521,19 +527,19 @@ bool CCabinet::SetCabinetReservedFile(char* FileName)
#if defined(WIN32)
FileHandle = CreateFile(ConvertPath(FileName, true), // Open this file
GENERIC_READ, // Open for reading
FILE_SHARE_READ, // Share for reading
NULL, // No security
OPEN_EXISTING, // Existing file only
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
GENERIC_READ, // Open for reading
FILE_SHARE_READ, // Share for reading
NULL, // No security
OPEN_EXISTING, // Existing file only
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
if (FileHandle == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n"));
return false;
}
#else /* !WIN32 */
FileHandle = fopen(ConvertPath(FileName, true), "rb");
FileHandle = fopen(ConvertPath(FileName, true), "rb");
if (FileHandle == NULL) {
DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n"));
return false;
@ -614,19 +620,19 @@ unsigned long CCabinet::Open()
#if defined(WIN32)
FileHandle = CreateFile(CabinetName, // Open this file
GENERIC_READ, // Open for reading
FILE_SHARE_READ, // Share for reading
NULL, // No security
OPEN_EXISTING, // Existing file only
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
GENERIC_READ, // Open for reading
FILE_SHARE_READ, // Share for reading
NULL, // No security
OPEN_EXISTING, // Existing file only
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
if (FileHandle == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("Cannot open file.\n"));
return CAB_STATUS_CANNOT_OPEN;
}
#else /* !WIN32 */
FileHandle = fopen(CabinetName, "rb");
FileHandle = fopen(CabinetName, "rb");
if (FileHandle == NULL) {
DPRINT(MID_TRACE, ("Cannot open file.\n"));
return CAB_STATUS_CANNOT_OPEN;
@ -694,7 +700,7 @@ unsigned long CCabinet::Open()
strcpy(CabinetPrev, "");
strcpy(DiskPrev, "");
}
if ((CABHeader.Flags & CAB_FLAG_HASNEXT) > 0) {
/* Read name of next cabinet */
Status = ReadString(CabinetNext, 256);
@ -818,7 +824,7 @@ unsigned long CCabinet::FindNext(PCAB_SEARCH Search)
OnDiskChange(CabinetNext, DiskNext);
Status = Open();
if (Status != CAB_STATUS_SUCCESS)
if (Status != CAB_STATUS_SUCCESS)
return Status;
Search->Next = FileListHead;
@ -925,7 +931,7 @@ unsigned long CCabinet::ExtractFile(char* FileName)
}
}
#else /* !WIN32 */
DestFile = fopen(DestName, "rb");
DestFile = fopen(DestName, "rb");
if (DestFile != NULL) {
fclose(DestFile);
/* If file exists, ask to overwrite file */
@ -961,7 +967,7 @@ unsigned long CCabinet::ExtractFile(char* FileName)
if (!Buffer) {
CloseFile(DestFile);
DPRINT(MIN_TRACE, ("Insufficient memory.\n"));
return CAB_STATUS_NOMEMORY;
return CAB_STATUS_NOMEMORY;
}
/* Call OnExtract event handler */
@ -1007,7 +1013,7 @@ unsigned long CCabinet::ExtractFile(char* FileName)
do {
DPRINT(MAX_TRACE, ("Size (%lu bytes).\n", Size));
if (((Status = ReadBlock(&CFData, sizeof(CFDATA), &BytesRead)) !=
if (((Status = ReadBlock(&CFData, sizeof(CFDATA), &BytesRead)) !=
CAB_STATUS_SUCCESS) || (BytesRead != sizeof(CFDATA))) {
CloseFile(DestFile);
FreeMemory(Buffer);
@ -1027,7 +1033,7 @@ unsigned long CCabinet::ExtractFile(char* FileName)
DPRINT(MAX_TRACE, ("Read: (0x%lX,0x%lX).\n",
(long unsigned int)CurrentBuffer, (long unsigned int)Buffer));
if (((Status = ReadBlock(CurrentBuffer, BytesToRead, &BytesRead)) !=
if (((Status = ReadBlock(CurrentBuffer, BytesToRead, &BytesRead)) !=
CAB_STATUS_SUCCESS) || (BytesToRead != BytesRead)) {
CloseFile(DestFile);
FreeMemory(Buffer);
@ -1068,7 +1074,7 @@ unsigned long CCabinet::ExtractFile(char* FileName)
OnDiskChange(CabinetNext, DiskNext);
Status = Open();
if (Status != CAB_STATUS_SUCCESS)
if (Status != CAB_STATUS_SUCCESS)
return Status;
/* The first data block of the file will not be
@ -1140,7 +1146,7 @@ unsigned long CCabinet::ExtractFile(char* FileName)
CurrentDataNode->AbsoluteOffset + sizeof(CFDATA) +
CurrentDataNode->Data.CompSize));
if (((Status = ReadBlock(&CFData, sizeof(CFDATA), &BytesRead)) !=
if (((Status = ReadBlock(&CFData, sizeof(CFDATA), &BytesRead)) !=
CAB_STATUS_SUCCESS) || (BytesRead != sizeof(CFDATA))) {
CloseFile(DestFile);
FreeMemory(Buffer);
@ -1274,7 +1280,7 @@ unsigned long CCabinet::NewCabinet()
InputBuffer = AllocateMemory(CAB_BLOCKSIZE + 12); // This should be enough
if ((!OutputBuffer) || (!InputBuffer)) {
DPRINT(MIN_TRACE, ("Insufficient memory.\n"));
return CAB_STATUS_NOMEMORY;
return CAB_STATUS_NOMEMORY;
}
CurrentIBuffer = InputBuffer;
CurrentIBufferSize = 0;
@ -1417,14 +1423,14 @@ unsigned long CCabinet::WriteFileToScratchStorage(PCFFILE_NODE FileNode)
FILE_SHARE_READ, // Share for reading
NULL, // No security
OPEN_EXISTING, // File must exist
FILE_ATTRIBUTE_NORMAL, // Normal file
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
if (SourceFile == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("File not found (%s).\n", FileNode->FileName));
return CAB_STATUS_NOFILE;
}
#else /* !WIN32 */
SourceFile = fopen(FileNode->FileName, "rb");
SourceFile = fopen(FileNode->FileName, "rb");
if (SourceFile == NULL) {
DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n"));
return CAB_STATUS_NOFILE;
@ -1447,7 +1453,7 @@ unsigned long CCabinet::WriteFileToScratchStorage(PCFFILE_NODE FileNode)
FileNode->File.FileOffset = CurrentFolderNode->UncompOffset;
CurrentFolderNode->UncompOffset += TotalBytesLeft;
FileNode->File.FileControlID = NextFolderNumber - 1;
FileNode->File.FileControlID = (unsigned short)(NextFolderNumber - 1);
CurrentFolderNode->Commit = true;
PrevCabinetNumber = CurrentDiskNumber;
@ -1543,7 +1549,7 @@ unsigned long CCabinet::WriteDisk(unsigned long MoreDisks)
ContinueFile = true;
CreateNewDisk = false;
DPRINT(MAX_TRACE, ("First on new disk. CurrentIBufferSize (%lu) CurrentOBufferSize (%lu).\n",
DPRINT(MAX_TRACE, ("First on new disk. CurrentIBufferSize (%lu) CurrentOBufferSize (%lu).\n",
CurrentIBufferSize, CurrentOBufferSize));
if ((CurrentIBufferSize > 0) || (CurrentOBufferSize > 0)) {
@ -1635,7 +1641,7 @@ unsigned long CCabinet::CommitDisk(unsigned long MoreDisks)
}
}
#else /* !WIN32 */
FileHandle = fopen(CabinetName, "rb");
FileHandle = fopen(CabinetName, "rb");
if (FileHandle != NULL) {
fclose(FileHandle);
/* If file exists, ask to overwrite file */
@ -1655,7 +1661,7 @@ unsigned long CCabinet::CommitDisk(unsigned long MoreDisks)
}
#endif
WriteCabinetHeader(MoreDisks);
WriteCabinetHeader(MoreDisks != 0);
Status = WriteFolderEntries();
if (Status != CAB_STATUS_SUCCESS)
@ -1770,14 +1776,14 @@ unsigned long CCabinet::AddFile(char* FileName)
FILE_SHARE_READ, // Share for reading
NULL, // No security
OPEN_EXISTING, // File must exist
FILE_ATTRIBUTE_NORMAL, // Normal file
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
if (SrcFile == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("File not found (%s).\n", FileNode->FileName));
return CAB_STATUS_CANNOT_OPEN;
}
#else /* !WIN32 */
SrcFile = fopen(FileNode->FileName, "rb");
SrcFile = fopen(FileNode->FileName, "rb");
if (SrcFile == NULL) {
DPRINT(MID_TRACE, ("File not found (%s).\n", FileNode->FileName));
return CAB_STATUS_CANNOT_OPEN;
@ -2545,8 +2551,8 @@ unsigned long CCabinet::InitCabinetHeader()
CABHeader.FileCount = 0; // Not known yet
CABHeader.Flags = 0; // Not known yet
CABHeader.CabinetNumber = CurrentDiskNumber;
CABHeader.CabinetNumber = (unsigned short)CurrentDiskNumber;
if ((CurrentDiskNumber > 0) && (OnCabinetName(PrevCabinetNumber, CabinetPrev))) {
CABHeader.Flags |= CAB_FLAG_HASPREV;
if (!OnDiskLabel(PrevCabinetNumber, DiskPrev))
@ -2672,7 +2678,7 @@ unsigned long CCabinet::WriteCabinetHeader(bool MoreDisks)
/* Write per-cabinet reserved area if present */
if (CABHeader.Flags & CAB_FLAG_RESERVE) {
unsigned long ReservedSize;
ReservedSize = CabinetReservedFileSize & 0xffff;
ReservedSize |= (0 << 16); /* Folder reserved area size */
ReservedSize |= (0 << 24); /* Folder reserved area size */
@ -2846,7 +2852,7 @@ unsigned long CCabinet::WriteFileEntries()
/* The file could end in the last (split) block and should therefore
appear in the next disk too */
if ((File->File.FileOffset + File->File.FileSize >= LastBlockStart) &&
(File->File.FileControlID <= CAB_FILE_MAX_FOLDER) && (BlockIsSplit)) {
File->File.FileControlID = CAB_FILE_SPLIT;
@ -2914,7 +2920,7 @@ unsigned long CCabinet::CommitDataBlocks(PCFFOLDER_NODE FolderNode)
DataNode = FolderNode->DataListHead;
if (DataNode != NULL)
Status = ScratchFile->Seek(DataNode->ScratchFilePosition);
while (DataNode != NULL) {
DPRINT(MAX_TRACE, ("Reading block at (0x%lX) CompSize (%d) UncompSize (%d).\n",
DataNode->ScratchFilePosition,

View file

@ -58,6 +58,10 @@
extern unsigned long DebugTraceLevel;
#ifdef _MSC_VER
#define __FUNCTION__ ""
#endif//_MSC_VER
#define DPRINT(_t_, _x_) \
if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
((DebugTraceLevel & _t_) > NORMAL_MASK)) { \

View file

@ -189,9 +189,9 @@ void CCABManager::Usage()
*/
{
printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION);
printf("CABMAN [/D | /E] [/A] [/L dir] cabinet [filename ...]\n");
printf("CABMAN /C dirfile [/I] [/RC file]\n");
printf("CABMAN /S cabinet filename\n");
printf("CABMAN [-D | -E] [-A] [-L dir] cabinet [filename ...]\n");
printf("CABMAN -C dirfile [-I] [-RC file]\n");
printf("CABMAN -S cabinet filename\n");
printf(" cabinet Cabinet file.\n");
printf(" filename Name of the file to extract from the cabinet.\n");
printf(" Wild cards and multiple filenames\n");
@ -199,18 +199,18 @@ void CCABManager::Usage()
printf(" dirfile Name of the directive file to use.\n");
printf(" /A Process ALL cabinets. Follows cabinet chain\n");
printf(" -A Process ALL cabinets. Follows cabinet chain\n");
printf(" starting in first cabinet mentioned.\n");
printf(" /C Create cabinet.\n");
printf(" /D Display cabinet directory.\n");
printf(" /E Extract files from cabinet.\n");
printf(" /I Don't create the cabinet, only the .inf file.\n");
printf(" /L dir Location to place extracted or generated files\n");
printf(" -C Create cabinet.\n");
printf(" -D Display cabinet directory.\n");
printf(" -E Extract files from cabinet.\n");
printf(" -I Don't create the cabinet, only the .inf file.\n");
printf(" -L dir Location to place extracted or generated files\n");
printf(" (default is current directory).\n");
printf(" /N Don't create the .inf file, only the cabinet.\n");
printf(" /RC Specify file to put in cabinet reserved area\n");
printf(" -N Don't create the .inf file, only the cabinet.\n");
printf(" -RC Specify file to put in cabinet reserved area\n");
printf(" (size must be less than 64KB).\n");
printf(" /S Create simple cabinet.\n");
printf(" -S Create simple cabinet.\n");
}
bool CCABManager::ParseCmdline(int argc, char* argv[])
@ -230,7 +230,7 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
ShowUsage = (argc < 2);
for (i = 1; i < argc; i++) {
if (argv[i][0] == '/') {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'a':
case 'A': ProcessAll = true; break;
@ -404,7 +404,7 @@ bool CCABManager::DisplayCabinet()
}
return true;
} else
printf("Cannot not open file: %s\n", GetCabinetName());
printf("Cannot open file: %s\n", GetCabinetName());
return false;
}
@ -443,7 +443,7 @@ bool CCABManager::ExtractFromCabinet()
}
return true;
} else
printf("Cannot not open file: %s.\n", GetCabinetName());
printf("Cannot open file: %s.\n", GetCabinetName());
return false;
}

View file

@ -20,5 +20,7 @@ $(CDMAKE_TARGET): $(CDMAKE_OBJECTS)
$(CDMAKE_OBJECTS): %.o : %.c
${host_gcc} $(CDMAKE_CFLAGS) -c $< -o $@
clean::
.PHONY: cdmake_clean
cdmake_clean:
-@$(rm) $(CDMAKE_TARGET) $(CDMAKE_OBJECTS) 2>$(NUL)
clean: cdmake_clean

View file

@ -19,8 +19,10 @@ $(NCI_TARGET): $(NCI_OBJECTS)
$(NCI_OBJECTS): %.o : %.c
${host_gcc} $(NCI_HOST_CFLAGS) -c $< -o $@
clean::
.PHONY: nci_clean
nci_clean:
-@$(rm) $(NCI_TARGET) $(NCI_OBJECTS) 2>$(NUL)
clean: nci_clean
# WIN32K.SYS
WIN32K_SVC_DB = $(NCI_BASE)$(SEP)w32ksvc.db
@ -53,5 +55,7 @@ $(NCI_SERVICE_FILES): $(NCI_TARGET)
$(WIN32K_GDI_STUBS) \
$(WIN32K_USER_STUBS)
clean::
.PHONY: nci_service_files_clean
nci_service_files_clean:
-@$(rm) $(NCI_SERVICE_FILES) 2>$(NUL)
clean: nci_service_files_clean

View file

@ -1029,14 +1029,16 @@ MingwModuleHandler::GenerateMacrosAndTargets (
clean_files.push_back ( ar_target );
GetCleanTargets ( clean_files, module.files, module.ifs );
fprintf ( fMakefile, "clean::\n\t-@$(rm)" );
fprintf ( fMakefile, ".PHONY: %s_clean\n", module.name.c_str() );
fprintf ( fMakefile, "%s_clean:\n\t-@$(rm)", module.name.c_str() );
for ( size_t i = 0; i < clean_files.size(); i++ )
{
if ( 9==(i%10) )
fprintf ( fMakefile, " 2>$(NUL)\n\t-@$(rm)" );
fprintf ( fMakefile, " %s", clean_files[i].c_str() );
}
fprintf ( fMakefile, " 2>$(NUL)\n\n" );
fprintf ( fMakefile, " 2>$(NUL)\n" );
fprintf ( fMakefile, "clean: %s_clean\n\n", module.name.c_str() );
}
void
@ -2100,11 +2102,11 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ( const Module& module )
cdDirectories.c_str (),
cdFiles.c_str () );
fprintf ( fMakefile,
"\t${cabman} /C %s /L %s /I\n",
"\t${cabman} -C %s -L %s -I\n",
reactosDff.c_str (),
bootcdReactos.c_str () );
fprintf ( fMakefile,
"\t${cabman} /C %s /RC %s /L %s /N\n",
"\t${cabman} -C %s -RC %s -L %s -N\n",
reactosDff.c_str (),
reactosInf.c_str (),
bootcdReactos.c_str () );

View file

@ -104,5 +104,7 @@ $(RBUILD_TEST_SPECIAL_OBJECTS): %.o: %.cpp
rbuild_test: $(RBUILD_TEST_TARGET)
$(RBUILD_TEST_TARGET)
clean::
.PHONY: rbuild_clean
rbuild_clean:
-@$(rm) $(RBUILD_TARGET) $(RBUILD_OBJECTS) $(RBUILD_TEST_TARGET) $(RBUILD_TEST_OBJECTS) 2>$(NUL)
clean: rbuild_clean

View file

@ -26,5 +26,7 @@ $(WMC_TARGET): $(WMC_OBJECTS)
$(WMC_OBJECTS): %.o : %.c
${host_gcc} $(WMC_HOST_CXXFLAGS) -c $< -o $@
clean::
.PHONY: wmc_clean
wmc_clean:
-@$(rm) $(WMC_TARGET) $(WMC_OBJECTS) 2>$(NUL)
clean: wmc_clean