]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/pkgdata/filemode.c
1 /******************************************************************************
3 * Copyright (C) 2000-2001, 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];
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 *copyCommands = NULL;*/
75 T_FileStream_writeLine(makefile
, "\n.PHONY: $(NAME) all install clean\n\nall: $(NAME)\n\n");
77 /* Dont' copy files already in tmp */
78 for(infiles
= o
->filePaths
;infiles
;infiles
= infiles
->next
)
80 baseName
= findBasename(infiles
->str
);
82 uprv_strcpy(tmp
, o
->targetDir
);
83 uprv_strcat(tmp
, U_FILE_SEP_STRING
);
84 uprv_strcat(tmp
, baseName
);
86 o
->outFiles
= pkg_appendToList(o
->outFiles
, &tail
, uprv_strdup(tmp
));
88 if(strcmp(tmp
, infiles
->str
) == 0)
90 /* fprintf(stderr, "### NOT copying: %s\n", tmp); */
91 /* no copy needed.. */
95 sprintf(stanza
, "%s: %s\n\t$(INSTALL_DATA) $< $@\n", tmp
, infiles
->str
);
96 T_FileStream_writeLine(makefile
, stanza
);
98 uprv_strcpy(tmp2
, o
->targetDir
);
99 uprv_strcat(tmp2
, U_FILE_SEP_STRING
);
100 uprv_strcat(tmp2
, U_FILE_SEP_STRING
);
101 uprv_strcat(tmp2
, baseName
);
103 if(strcmp(tmp2
, infiles
->str
) == 0)
105 /* fprintf(stderr, "### NOT copying: %s\n", tmp2); */
106 /* no copy needed.. */
110 uprv_strcpy(tmp2
, "$(INSTALLTO)" U_FILE_SEP_STRING
);
111 uprv_strcat(tmp2
, baseName
);
113 if(strcmp(tmp2
, infiles
->str
) == 0)
115 /* fprintf(stderr, "### NOT copying: %s\n", tmp2); */
116 /* no copy needed.. */
120 sprintf(stanza
, "%s: %s\n\t$(INSTALL_DATA) $< $@\n", tmp2
, tmp
);
121 T_FileStream_writeLine(makefile
, stanza
);
123 /* left hand side: target path, target name */
124 copyFilesLeft
= pkg_appendToList(copyFilesLeft
, ©FilesLeftTail
, uprv_strdup(tmp
));
126 /* fprintf(stderr, "##### COPY %s from %s\n", tmp, infiles->str); */
127 /* rhs: source path */
128 copyFilesRight
= pkg_appendToList(copyFilesRight
, ©FilesRightTail
, uprv_strdup(infiles
->str
));
130 /* install: installed path */
131 copyFilesInstall
= pkg_appendToList(copyFilesInstall
, ©FilesInstallTail
, uprv_strdup(tmp2
));
134 if(o
->nooutput
|| o
->verbose
) {
136 fprintf(stdout
, "# Output files: ");
137 for(i
= o
->outFiles
; i
; i
=i
->next
) {
138 printf("%s ", i
->str
);
144 *status
= U_ZERO_ERROR
;
148 /* these are also the files to delete */
149 T_FileStream_writeLine(makefile
, "COPIEDDEST= ");
150 pkg_writeCharListWrap(makefile
, copyFilesLeft
, " ", " \\\n", 0);
151 T_FileStream_writeLine(makefile
, "\n\n");
154 T_FileStream_writeLine(makefile
, "INSTALLEDDEST= ");
155 pkg_writeCharListWrap(makefile
, copyFilesInstall
, " ", " \\\n", 0);
156 T_FileStream_writeLine(makefile
, "\n\n");
158 if(copyFilesRight
!= NULL
)
160 T_FileStream_writeLine(makefile
, "$(NAME): $(COPIEDDEST)\n\n");
162 T_FileStream_writeLine(makefile
, "clean:\n\t-$(RMV) $(COPIEDDEST) $(MAKEFILE)");
163 T_FileStream_writeLine(makefile
, "\n\n");
168 T_FileStream_writeLine(makefile
, "clean:\n\n");
170 T_FileStream_writeLine(makefile
, "install: $(INSTALLEDDEST)\n\n");