1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/******************************************************************************
*
* Copyright (C) 2000-2004, International Business Machines
* 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"
#include "unicode/putil.h"
#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)
==Note:==
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], srcPath[1024];
char stanza[3072];
CharList *tail = NULL, *infiles = NULL;
CharList *copyFilesLeft = NULL; /* left hand side of the copy rule*/
CharList *copyFilesRight = NULL; /* rhs "" "" */
CharList *copyFilesInstall = NULL;
CharList *copyFilesLeftTail = NULL;
CharList *copyFilesRightTail = NULL;
CharList *copyFilesInstallTail = NULL;
CharList *copyDirs = NULL; /* list of dirs to create for copying */
CharList *installDirs = NULL; /* list of dirs to create for installation */
/* CharList *copyCommands = NULL;*/
const char *baseName;
T_FileStream_writeLine(makefile, "\n.PHONY: $(NAME) all install clean\n\nall: $(NAME)\n\n");
if(o->embed) {
infiles = o->filePaths;
} else {
infiles = o->files; /* raw files - no paths other than tree paths */
}
/* Dont' copy files already in tmp */
for(;infiles;infiles = infiles->next)
{
uprv_strcpy(tmp, o->targetDir);
uprv_strcat(tmp, U_FILE_SEP_STRING);
if(o->embed) {
baseName = findBasename(infiles->str);
uprv_strcpy(srcPath, baseName);
} else {
baseName = infiles->str;
uprv_strcat(tmp, o->shortName);
uprv_strcat(tmp, U_FILE_SEP_STRING);
uprv_strcpy(srcPath, "$(SRCDIR)/");
uprv_strcat(srcPath, infiles->str);
}
uprv_strcat(tmp, baseName);
copyDirs = pkg_appendUniqueDirToList(copyDirs, NULL, tmp);
o->outFiles = pkg_appendToList(o->outFiles, &tail, uprv_strdup(tmp));
if(strcmp(tmp, infiles->str) == 0)
{
/* fprintf(stderr, "### NOT copying: %s\n", tmp); */
/* no copy needed.. */
} else {
sprintf(stanza, "%s: %s\n\t$(INSTALL_DATA) $< $@\n", tmp, srcPath);
T_FileStream_writeLine(makefile, stanza);
}
uprv_strcpy(tmp2, "$(INSTALLTO)" U_FILE_SEP_STRING);
if(!o->embed) {
uprv_strcat(tmp2, o->shortName);
uprv_strcat(tmp2, U_FILE_SEP_STRING);
}
uprv_strcat(tmp2, baseName);
installDirs = pkg_appendUniqueDirToList(installDirs, NULL, tmp2);
if(strcmp(tmp2, infiles->str) == 0) {
/* fprintf(stderr, "### NOT copying: %s\n", tmp2); */
/* no copy needed.. */
} else {
sprintf(stanza, "%s: %s\n\t$(INSTALL_DATA) $< $@\n", tmp2, tmp);
T_FileStream_writeLine(makefile, stanza);
/* left hand side: target path, target name */
copyFilesLeft = pkg_appendToList(copyFilesLeft, ©FilesLeftTail, uprv_strdup(tmp));
/* fprintf(stderr, "##### COPY %s from %s\n", tmp, infiles->str); */
/* rhs: source path */
copyFilesRight = pkg_appendToList(copyFilesRight, ©FilesRightTail, uprv_strdup(infiles->str));
/* install: installed path */
copyFilesInstall = pkg_appendToList(copyFilesInstall, ©FilesInstallTail, uprv_strdup(tmp2));
}
}
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");
}
if(o->nooutput) {
*status = U_ZERO_ERROR;
return;
}
/* these are also the files to delete */
T_FileStream_writeLine(makefile, "COPIEDDEST= ");
pkg_writeCharListWrap(makefile, copyFilesLeft, " ", " \\\n", 0);
T_FileStream_writeLine(makefile, "\n\n");
T_FileStream_writeLine(makefile, "INSTALLEDDEST= ");
pkg_writeCharListWrap(makefile, copyFilesInstall, " ", " \\\n", 0);
T_FileStream_writeLine(makefile, "\n\n");
T_FileStream_writeLine(makefile, "COPYDIRS= ");
pkg_writeCharListWrap(makefile, copyDirs, " ", " \\\n", 0);
T_FileStream_writeLine(makefile, "\n\n");
T_FileStream_writeLine(makefile, "INSTALLDIRS= ");
pkg_writeCharListWrap(makefile, installDirs, " ", " \\\n", 0);
T_FileStream_writeLine(makefile, "\n\n");
if(copyFilesRight != NULL)
{
T_FileStream_writeLine(makefile, "$(NAME): copy-dirs $(COPIEDDEST)\n\n");
T_FileStream_writeLine(makefile, "clean:\n\t-$(RMV) $(COPIEDDEST) $(MAKEFILE)");
T_FileStream_writeLine(makefile, "\n\n");
}
else
{
T_FileStream_writeLine(makefile, "clean:\n\n");
}
T_FileStream_writeLine(makefile, "install: install-dirs $(INSTALLEDDEST)\n\n");
T_FileStream_writeLine(makefile, "install-dirs:\n\t$(MKINSTALLDIRS) $(INSTALLDIRS)\n\n");
T_FileStream_writeLine(makefile, "copy-dirs:\n\t$(MKINSTALLDIRS) $(COPYDIRS)\n\n");
}
|