2000-10-05 00:03:01 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2001-03-21 23:22:16 +00:00
|
|
|
* Copyright (C) 2000-2001, International Business Machines
|
2000-10-05 00:03:01 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: filemode.c
|
|
|
|
* encoding: ANSI X3.4 (1968)
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2000sep28
|
|
|
|
* created by: Steven \u24C7 Loomis
|
|
|
|
*
|
|
|
|
* The mode which uses raw files (i.e. does nothing until installation).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "unicode/utypes.h"
|
2001-01-03 02:24:47 +00:00
|
|
|
#include "unicode/putil.h"
|
2000-10-05 00:03:01 +00:00
|
|
|
#include "cmemory.h"
|
|
|
|
#include "cstring.h"
|
|
|
|
#include "filestrm.h"
|
|
|
|
#include "toolutil.h"
|
|
|
|
#include "unewdata.h"
|
|
|
|
#include "uoptions.h"
|
|
|
|
#include "pkgtypes.h"
|
|
|
|
#include "makefile.h"
|
|
|
|
|
|
|
|
/* The file we will make will look like this:
|
|
|
|
|
|
|
|
(where /out is the full path to the output dir)
|
|
|
|
|
|
|
|
SOURCES=/out/filea /out/fileb ./somewhere/filec ../somewhereelse/filed
|
|
|
|
|
|
|
|
TARGETS=/out/filea /out/fileb /out/filec /out/filed
|
|
|
|
|
|
|
|
all: $(TARGETS)
|
|
|
|
|
|
|
|
/out/filec /out/filed: ../somewhere/filec ../somewhereelse/filed
|
|
|
|
$(INSTALL_DATA) $? $(OUTDIR)
|
|
|
|
|
|
|
|
install: all
|
|
|
|
$(INSTALL_DATA) $(TARGETS) $(instdir)
|
|
|
|
|
|
|
|
|
2001-03-21 23:22:16 +00:00
|
|
|
==Note:==
|
2000-10-05 00:03:01 +00:00
|
|
|
The only items in the first '$(INSTALL_DATA)' are files NOT already in the out dir!
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void pkg_mode_files(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
|
|
|
|
{
|
|
|
|
char tmp[1024], tmp2[1024];
|
2002-02-25 07:32:26 +00:00
|
|
|
char stanza[3072];
|
|
|
|
|
2000-10-05 00:03:01 +00:00
|
|
|
CharList *tail = NULL, *infiles = NULL;
|
|
|
|
|
|
|
|
CharList *copyFilesLeft = NULL; /* left hand side of the copy rule*/
|
|
|
|
CharList *copyFilesRight = NULL; /* rhs "" "" */
|
2002-02-25 07:32:26 +00:00
|
|
|
CharList *copyFilesInstall = NULL;
|
2000-10-05 00:03:01 +00:00
|
|
|
|
|
|
|
CharList *copyFilesLeftTail = NULL;
|
|
|
|
CharList *copyFilesRightTail = NULL;
|
2002-02-25 07:32:26 +00:00
|
|
|
CharList *copyFilesInstallTail = NULL;
|
2000-10-05 00:03:01 +00:00
|
|
|
|
2002-02-28 19:43:13 +00:00
|
|
|
/* CharList *copyCommands = NULL;*/
|
2000-10-05 00:03:01 +00:00
|
|
|
|
|
|
|
const char *baseName;
|
|
|
|
|
2002-02-25 07:45:19 +00:00
|
|
|
T_FileStream_writeLine(makefile, "\n.PHONY: $(NAME) all install clean\n\nall: $(NAME)\n\n");
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2000-12-15 20:34:14 +00:00
|
|
|
/* Dont' copy files already in tmp */
|
2000-10-05 00:03:01 +00:00
|
|
|
for(infiles = o->filePaths;infiles;infiles = infiles->next)
|
|
|
|
{
|
|
|
|
baseName = findBasename(infiles->str);
|
|
|
|
|
2001-11-12 17:54:15 +00:00
|
|
|
uprv_strcpy(tmp, o->targetDir);
|
2000-10-05 00:03:01 +00:00
|
|
|
uprv_strcat(tmp, U_FILE_SEP_STRING);
|
|
|
|
uprv_strcat(tmp, baseName);
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2000-10-05 00:03:01 +00:00
|
|
|
o->outFiles = pkg_appendToList(o->outFiles, &tail, uprv_strdup(tmp));
|
|
|
|
|
|
|
|
if(strcmp(tmp, infiles->str) == 0)
|
|
|
|
{
|
2000-12-15 20:34:14 +00:00
|
|
|
/* fprintf(stderr, "### NOT copying: %s\n", tmp); */
|
2000-10-05 00:03:01 +00:00
|
|
|
/* no copy needed.. */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-02-25 07:32:26 +00:00
|
|
|
sprintf(stanza, "%s: %s\n\t$(INSTALL_DATA) $< $@\n", tmp, infiles->str);
|
|
|
|
T_FileStream_writeLine(makefile, stanza);
|
|
|
|
|
2001-11-12 17:54:15 +00:00
|
|
|
uprv_strcpy(tmp2, o->targetDir);
|
2000-10-05 00:03:01 +00:00
|
|
|
uprv_strcat(tmp2, U_FILE_SEP_STRING);
|
|
|
|
uprv_strcat(tmp2, U_FILE_SEP_STRING);
|
|
|
|
uprv_strcat(tmp2, baseName);
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2000-10-05 00:03:01 +00:00
|
|
|
if(strcmp(tmp2, infiles->str) == 0)
|
|
|
|
{
|
2000-12-15 20:34:14 +00:00
|
|
|
/* fprintf(stderr, "### NOT copying: %s\n", tmp2); */
|
2000-10-05 00:03:01 +00:00
|
|
|
/* no copy needed.. */
|
|
|
|
continue;
|
|
|
|
}
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2002-02-25 07:32:26 +00:00
|
|
|
uprv_strcpy(tmp2, "$(INSTALLTO)" U_FILE_SEP_STRING);
|
|
|
|
uprv_strcat(tmp2, baseName);
|
|
|
|
|
|
|
|
if(strcmp(tmp2, infiles->str) == 0)
|
|
|
|
{
|
|
|
|
/* fprintf(stderr, "### NOT copying: %s\n", tmp2); */
|
|
|
|
/* no copy needed.. */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(stanza, "%s: %s\n\t$(INSTALL_DATA) $< $@\n", tmp2, tmp);
|
|
|
|
T_FileStream_writeLine(makefile, stanza);
|
|
|
|
|
2000-10-05 00:03:01 +00:00
|
|
|
/* left hand side: target path, target name */
|
|
|
|
copyFilesLeft = pkg_appendToList(copyFilesLeft, ©FilesLeftTail, uprv_strdup(tmp));
|
|
|
|
|
2001-11-12 17:54:15 +00:00
|
|
|
/* fprintf(stderr, "##### COPY %s from %s\n", tmp, infiles->str); */
|
2000-10-05 00:03:01 +00:00
|
|
|
/* rhs: source path */
|
|
|
|
copyFilesRight = pkg_appendToList(copyFilesRight, ©FilesRightTail, uprv_strdup(infiles->str));
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2002-02-25 07:32:26 +00:00
|
|
|
/* install: installed path */
|
|
|
|
copyFilesInstall = pkg_appendToList(copyFilesInstall, ©FilesInstallTail, uprv_strdup(tmp2));
|
2000-10-05 00:03:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(o->nooutput || o->verbose) {
|
|
|
|
CharList *i;
|
|
|
|
fprintf(stdout, "# Output files: ");
|
|
|
|
for(i = o->outFiles; i; i=i->next) {
|
|
|
|
printf("%s ", i->str);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2000-10-05 00:03:01 +00:00
|
|
|
if(o->nooutput) {
|
|
|
|
*status = U_ZERO_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* these are also the files to delete */
|
|
|
|
T_FileStream_writeLine(makefile, "COPIEDDEST= ");
|
2002-02-25 07:32:26 +00:00
|
|
|
pkg_writeCharListWrap(makefile, copyFilesLeft, " ", " \\\n", 0);
|
2002-02-25 07:45:19 +00:00
|
|
|
T_FileStream_writeLine(makefile, "\n\n");
|
2000-10-05 00:03:01 +00:00
|
|
|
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2002-02-25 07:32:26 +00:00
|
|
|
T_FileStream_writeLine(makefile, "INSTALLEDDEST= ");
|
|
|
|
pkg_writeCharListWrap(makefile, copyFilesInstall, " ", " \\\n", 0);
|
2002-02-25 07:45:19 +00:00
|
|
|
T_FileStream_writeLine(makefile, "\n\n");
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2000-10-05 00:03:01 +00:00
|
|
|
if(copyFilesRight != NULL)
|
|
|
|
{
|
2002-02-25 07:32:26 +00:00
|
|
|
T_FileStream_writeLine(makefile, "$(NAME): $(COPIEDDEST)\n\n");
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2000-10-05 00:03:01 +00:00
|
|
|
T_FileStream_writeLine(makefile, "clean:\n\t-$(RMV) $(COPIEDDEST) $(MAKEFILE)");
|
|
|
|
T_FileStream_writeLine(makefile, "\n\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
T_FileStream_writeLine(makefile, "clean:\n\n");
|
|
|
|
}
|
2002-02-25 07:45:19 +00:00
|
|
|
T_FileStream_writeLine(makefile, "install: $(INSTALLEDDEST)\n\n");
|
2000-10-05 00:03:01 +00:00
|
|
|
}
|
2002-02-25 07:32:26 +00:00
|
|
|
|