]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/pkgdata/filemode.c
1 /******************************************************************************
3 * Copyright (C) 2000-2006, 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!
54 #ifdef U_MAKE_IS_NMAKE
55 #define DEPENDENT_FILE_RULE "$?"
57 #define DEPENDENT_FILE_RULE "$<"
60 void pkg_mode_files(UPKGOptions
*o
, FileStream
*makefile
, UErrorCode
*status
)
62 char tmp
[1024], tmp2
[1024], srcPath
[1024];
65 CharList
*tail
= NULL
, *infiles
= NULL
;
67 CharList
*copyFilesLeft
= NULL
; /* left hand side of the copy rule*/
68 CharList
*copyFilesRight
= NULL
; /* rhs "" "" */
69 CharList
*copyFilesInstall
= NULL
;
71 CharList
*copyFilesLeftTail
= NULL
;
72 CharList
*copyFilesRightTail
= NULL
;
73 CharList
*copyFilesInstallTail
= NULL
;
75 CharList
*copyDirs
= NULL
; /* list of dirs to create for copying */
76 CharList
*installDirs
= NULL
; /* list of dirs to create for installation */
78 /* CharList *copyCommands = NULL;*/
82 #ifndef U_MAKE_IS_NMAKE
83 T_FileStream_writeLine(makefile
, "\n.PHONY: $(NAME) all install clean\n");
85 T_FileStream_writeLine(makefile
, "\nall: $(NAME)\n\n");
87 infiles
= o
->files
; /* raw files - no paths other than tree paths */
89 /* Dont' copy files already in tmp */
90 for(;infiles
;infiles
= infiles
->next
)
92 uprv_strcpy(tmp
, o
->targetDir
);
93 uprv_strcat(tmp
, U_FILE_SEP_STRING
);
94 baseName
= infiles
->str
;
95 uprv_strcat(tmp
, o
->shortName
);
96 uprv_strcat(tmp
, U_FILE_SEP_STRING
);
97 uprv_strcpy(srcPath
, "$(SRCDIR)/");
98 uprv_strcat(srcPath
, infiles
->str
);
99 uprv_strcat(tmp
, baseName
);
101 copyDirs
= pkg_appendUniqueDirToList(copyDirs
, NULL
, tmp
);
103 o
->outFiles
= pkg_appendToList(o
->outFiles
, &tail
, uprv_strdup(tmp
));
105 if(strcmp(tmp
, infiles
->str
) == 0)
107 /* fprintf(stderr, "### NOT copying: %s\n", tmp); */
108 /* no copy needed.. */
110 sprintf(stanza
, "%s: %s\n\t$(INSTALL_DATA) "DEPENDENT_FILE_RULE
" $@\n", tmp
, srcPath
);
111 convertToNativePathSeparators(stanza
);
112 T_FileStream_writeLine(makefile
, stanza
);
115 uprv_strcpy(tmp2
, "$(INSTALLTO)" U_FILE_SEP_STRING
);
116 uprv_strcat(tmp2
, o
->shortName
);
117 uprv_strcat(tmp2
, U_FILE_SEP_STRING
);
118 uprv_strcat(tmp2
, baseName
);
120 installDirs
= pkg_appendUniqueDirToList(installDirs
, NULL
, tmp2
);
122 if(strcmp(tmp2
, infiles
->str
) == 0) {
123 /* fprintf(stderr, "### NOT copying: %s\n", tmp2); */
124 /* no copy needed.. */
126 sprintf(stanza
, "%s: %s\n\t$(INSTALL_DATA) "DEPENDENT_FILE_RULE
" $@\n", tmp2
, tmp
);
127 convertToNativePathSeparators(stanza
);
128 T_FileStream_writeLine(makefile
, stanza
);
130 /* left hand side: target path, target name */
131 copyFilesLeft
= pkg_appendToList(copyFilesLeft
, ©FilesLeftTail
, uprv_strdup(tmp
));
133 /* fprintf(stderr, "##### COPY %s from %s\n", tmp, infiles->str); */
134 /* rhs: source path */
135 copyFilesRight
= pkg_appendToList(copyFilesRight
, ©FilesRightTail
, uprv_strdup(infiles
->str
));
137 /* install: installed path */
138 copyFilesInstall
= pkg_appendToList(copyFilesInstall
, ©FilesInstallTail
, uprv_strdup(tmp2
));
142 if(o
->nooutput
|| o
->verbose
) {
144 fprintf(stdout
, "# Output files: ");
145 for(i
= o
->outFiles
; i
; i
=i
->next
) {
146 printf("%s ", i
->str
);
152 *status
= U_ZERO_ERROR
;
156 /* these are also the files to delete */
157 T_FileStream_writeLine(makefile
, "COPIEDDEST= ");
158 pkg_writeCharListWrap(makefile
, copyFilesLeft
, " ", " \\\n", 0);
159 T_FileStream_writeLine(makefile
, "\n\n");
162 T_FileStream_writeLine(makefile
, "INSTALLEDDEST= ");
163 pkg_writeCharListWrap(makefile
, copyFilesInstall
, " ", " \\\n", 0);
164 T_FileStream_writeLine(makefile
, "\n\n");
166 T_FileStream_writeLine(makefile
, "COPYDIRS= ");
167 pkg_writeCharListWrap(makefile
, copyDirs
, " ", " \\\n", 0);
168 T_FileStream_writeLine(makefile
, "\n\n");
171 T_FileStream_writeLine(makefile
, "INSTALLDIRS= ");
172 pkg_writeCharListWrap(makefile
, installDirs
, " ", " \\\n", 0);
173 T_FileStream_writeLine(makefile
, "\n\n");
175 if(copyFilesRight
!= NULL
)
177 T_FileStream_writeLine(makefile
, "$(NAME): copy-dirs $(COPIEDDEST)\n\n");
179 T_FileStream_writeLine(makefile
, "clean:\n\t-$(RMV) $(COPIEDDEST) $(MAKEFILE)");
180 T_FileStream_writeLine(makefile
, "\n\n");
185 T_FileStream_writeLine(makefile
, "clean:\n\n");
187 T_FileStream_writeLine(makefile
, "install: install-dirs $(INSTALLEDDEST)\n\n");
188 T_FileStream_writeLine(makefile
, "install-dirs:\n\t$(MKINSTALLDIRS) $(INSTALLDIRS)\n\n");
189 T_FileStream_writeLine(makefile
, "copy-dirs:\n\t$(MKINSTALLDIRS) $(COPYDIRS)\n\n");