]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/pkgdata/filemode.c
1 /******************************************************************************
3 * Copyright (C) 2000-2004, International Business Machines
4 * Corporation and others. All Rights Reserved.
6 *******************************************************************************
7 * file name: filemode.c
8 * encoding: ANSI X3.4 (1968)
9 * tab size: 8 (not used)
12 * created on: 2000sep28
13 * created by: Steven \u24C7 Loomis
15 * The mode which uses raw files (i.e. does nothing until installation).
20 #include "unicode/utypes.h"
21 #include "unicode/putil.h"
31 /* The file we will make will look like this:
33 (where /out is the full path to the output dir)
35 SOURCES=/out/filea /out/fileb ./somewhere/filec ../somewhereelse/filed
37 TARGETS=/out/filea /out/fileb /out/filec /out/filed
41 /out/filec /out/filed: ../somewhere/filec ../somewhereelse/filed
42 $(INSTALL_DATA) $? $(OUTDIR)
45 $(INSTALL_DATA) $(TARGETS) $(instdir)
49 The only items in the first '$(INSTALL_DATA)' are files NOT already in the out dir!
56 void pkg_mode_files(UPKGOptions
*o
, FileStream
*makefile
, UErrorCode
*status
)
58 char tmp
[1024], tmp2
[1024], srcPath
[1024];
61 CharList
*tail
= NULL
, *infiles
= NULL
;
63 CharList
*copyFilesLeft
= NULL
; /* left hand side of the copy rule*/
64 CharList
*copyFilesRight
= NULL
; /* rhs "" "" */
65 CharList
*copyFilesInstall
= NULL
;
67 CharList
*copyFilesLeftTail
= NULL
;
68 CharList
*copyFilesRightTail
= NULL
;
69 CharList
*copyFilesInstallTail
= NULL
;
71 CharList
*copyDirs
= NULL
; /* list of dirs to create for copying */
72 CharList
*installDirs
= NULL
; /* list of dirs to create for installation */
74 /* CharList *copyCommands = NULL;*/
78 T_FileStream_writeLine(makefile
, "\n.PHONY: $(NAME) all install clean\n\nall: $(NAME)\n\n");
81 infiles
= o
->filePaths
;
83 infiles
= o
->files
; /* raw files - no paths other than tree paths */
86 /* Dont' copy files already in tmp */
87 for(;infiles
;infiles
= infiles
->next
)
89 uprv_strcpy(tmp
, o
->targetDir
);
90 uprv_strcat(tmp
, U_FILE_SEP_STRING
);
92 baseName
= findBasename(infiles
->str
);
93 uprv_strcpy(srcPath
, baseName
);
95 baseName
= infiles
->str
;
96 uprv_strcat(tmp
, o
->shortName
);
97 uprv_strcat(tmp
, U_FILE_SEP_STRING
);
98 uprv_strcpy(srcPath
, "$(SRCDIR)/");
99 uprv_strcat(srcPath
, infiles
->str
);
101 uprv_strcat(tmp
, baseName
);
103 copyDirs
= pkg_appendUniqueDirToList(copyDirs
, NULL
, tmp
);
105 o
->outFiles
= pkg_appendToList(o
->outFiles
, &tail
, uprv_strdup(tmp
));
107 if(strcmp(tmp
, infiles
->str
) == 0)
109 /* fprintf(stderr, "### NOT copying: %s\n", tmp); */
110 /* no copy needed.. */
112 sprintf(stanza
, "%s: %s\n\t$(INSTALL_DATA) $< $@\n", tmp
, srcPath
);
113 T_FileStream_writeLine(makefile
, stanza
);
116 uprv_strcpy(tmp2
, "$(INSTALLTO)" U_FILE_SEP_STRING
);
118 uprv_strcat(tmp2
, o
->shortName
);
119 uprv_strcat(tmp2
, U_FILE_SEP_STRING
);
121 uprv_strcat(tmp2
, baseName
);
123 installDirs
= pkg_appendUniqueDirToList(installDirs
, NULL
, tmp2
);
125 if(strcmp(tmp2
, infiles
->str
) == 0) {
126 /* fprintf(stderr, "### NOT copying: %s\n", tmp2); */
127 /* no copy needed.. */
129 sprintf(stanza
, "%s: %s\n\t$(INSTALL_DATA) $< $@\n", tmp2
, tmp
);
130 T_FileStream_writeLine(makefile
, stanza
);
132 /* left hand side: target path, target name */
133 copyFilesLeft
= pkg_appendToList(copyFilesLeft
, ©FilesLeftTail
, uprv_strdup(tmp
));
135 /* fprintf(stderr, "##### COPY %s from %s\n", tmp, infiles->str); */
136 /* rhs: source path */
137 copyFilesRight
= pkg_appendToList(copyFilesRight
, ©FilesRightTail
, uprv_strdup(infiles
->str
));
139 /* install: installed path */
140 copyFilesInstall
= pkg_appendToList(copyFilesInstall
, ©FilesInstallTail
, uprv_strdup(tmp2
));
144 if(o
->nooutput
|| o
->verbose
) {
146 fprintf(stdout
, "# Output files: ");
147 for(i
= o
->outFiles
; i
; i
=i
->next
) {
148 printf("%s ", i
->str
);
154 *status
= U_ZERO_ERROR
;
158 /* these are also the files to delete */
159 T_FileStream_writeLine(makefile
, "COPIEDDEST= ");
160 pkg_writeCharListWrap(makefile
, copyFilesLeft
, " ", " \\\n", 0);
161 T_FileStream_writeLine(makefile
, "\n\n");
164 T_FileStream_writeLine(makefile
, "INSTALLEDDEST= ");
165 pkg_writeCharListWrap(makefile
, copyFilesInstall
, " ", " \\\n", 0);
166 T_FileStream_writeLine(makefile
, "\n\n");
168 T_FileStream_writeLine(makefile
, "COPYDIRS= ");
169 pkg_writeCharListWrap(makefile
, copyDirs
, " ", " \\\n", 0);
170 T_FileStream_writeLine(makefile
, "\n\n");
173 T_FileStream_writeLine(makefile
, "INSTALLDIRS= ");
174 pkg_writeCharListWrap(makefile
, installDirs
, " ", " \\\n", 0);
175 T_FileStream_writeLine(makefile
, "\n\n");
177 if(copyFilesRight
!= NULL
)
179 T_FileStream_writeLine(makefile
, "$(NAME): copy-dirs $(COPIEDDEST)\n\n");
181 T_FileStream_writeLine(makefile
, "clean:\n\t-$(RMV) $(COPIEDDEST) $(MAKEFILE)");
182 T_FileStream_writeLine(makefile
, "\n\n");
187 T_FileStream_writeLine(makefile
, "clean:\n\n");
189 T_FileStream_writeLine(makefile
, "install: install-dirs $(INSTALLEDDEST)\n\n");
190 T_FileStream_writeLine(makefile
, "install-dirs:\n\t$(MKINSTALLDIRS) $(INSTALLDIRS)\n\n");
191 T_FileStream_writeLine(makefile
, "copy-dirs:\n\t$(MKINSTALLDIRS) $(COPYDIRS)\n\n");