]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /****************************************************************************** |
2 | * | |
73c04bcf | 3 | * Copyright (C) 2000-2006, International Business Machines |
b75a7d8f A |
4 | * Corporation and others. All Rights Reserved. |
5 | * | |
6 | ******************************************************************************* | |
7 | * file name: pkgdata.c | |
8 | * encoding: ANSI X3.4 (1968) | |
9 | * tab size: 8 (not used) | |
10 | * indentation:4 | |
11 | * | |
12 | * created on: 2000may15 | |
13 | * created by: Steven \u24C7 Loomis | |
14 | * | |
15 | * This program packages the ICU data into different forms | |
16 | * (DLL, common data, etc.) | |
17 | */ | |
18 | ||
19 | #include <stdio.h> | |
20 | #include <stdlib.h> | |
21 | #include "unicode/utypes.h" | |
374ca955 | 22 | #include "unicode/putil.h" |
b75a7d8f A |
23 | #include "cmemory.h" |
24 | #include "cstring.h" | |
25 | #include "filestrm.h" | |
26 | #include "toolutil.h" | |
27 | #include "unewdata.h" | |
28 | #include "uoptions.h" | |
29 | #include "pkgtypes.h" | |
30 | #include "makefile.h" | |
31 | ||
32 | void pkg_mode_common(UPKGOptions *o, FileStream *makefile, UErrorCode *status) | |
33 | { | |
34 | char tmp[1024]; | |
35 | CharList *tail = NULL; | |
36 | ||
37 | uprv_strcpy(tmp, UDATA_CMN_PREFIX); | |
38 | uprv_strcat(tmp, o->shortName); | |
39 | uprv_strcat(tmp, UDATA_CMN_SUFFIX); | |
40 | ||
41 | if(!uprv_strcmp(o->mode, "common")) { | |
42 | /* If we're not the main mode.. don't change the output file list */ | |
43 | ||
44 | /* We should be the only item. So we don't care about the order. */ | |
45 | o->outFiles = pkg_appendToList(o->outFiles, &tail, uprv_strdup(tmp)); | |
46 | ||
47 | if(o->nooutput || o->verbose) { | |
48 | fprintf(stdout, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp); | |
49 | } | |
50 | ||
51 | if(o->nooutput) { | |
52 | *status = U_ZERO_ERROR; | |
53 | return; | |
54 | } | |
55 | ||
56 | sprintf(tmp, "# File to make:\nTARGET=%s%s%s\n\nTARGETNAME=%s\n", o->targetDir, | |
57 | U_FILE_SEP_STRING, | |
58 | o->outFiles->str, | |
59 | o->outFiles->str); | |
60 | T_FileStream_writeLine(makefile, tmp); | |
61 | } else { | |
62 | /* We're in another mode. but, set the target so they can find us.. */ | |
63 | T_FileStream_writeLine(makefile, "TARGET="); | |
64 | T_FileStream_writeLine(makefile, tmp); | |
65 | T_FileStream_writeLine(makefile, "\n\n"); | |
66 | ||
67 | } /* end [check to make sure we are in mode 'common' ] */ | |
68 | ||
69 | sprintf(tmp, "# List file for gencmn:\n" | |
70 | "CMNLIST=%s%s%s_common.lst\n\n", | |
71 | o->tmpDir, | |
72 | U_FILE_SEP_STRING, | |
73 | o->shortName); | |
74 | T_FileStream_writeLine(makefile, tmp); | |
75 | ||
76 | sprintf(tmp, "all: $(TARGET)\n\n"); | |
77 | T_FileStream_writeLine(makefile, tmp); | |
78 | ||
79 | T_FileStream_writeLine(makefile, "$(TARGET): $(CMNLIST) $(DATAFILEPATHS)\n" | |
374ca955 | 80 | "\t$(INVOKE) $(GENCMN) -n $(CNAME) -c -s $(SRCDIR) -d $(TARGETDIR) 0 $(CMNLIST)\n\n"); |
b75a7d8f A |
81 | |
82 | if(o->hadStdin == FALSE) { /* shortcut */ | |
83 | T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n" | |
84 | "\tcat $(LISTFILES) > $(CMNLIST)\n\n"); | |
85 | } else { | |
86 | T_FileStream_writeLine(makefile, "$(CMNLIST): \n" | |
87 | "\t@echo \"generating $@ (list of data files)\"\n" | |
88 | "\t@-$(RMV) $@\n" | |
89 | "\t@for file in $(DATAFILEPATHS); do \\\n" | |
90 | "\t echo $$file >> $@; \\\n" | |
91 | "\tdone;\n\n"); | |
92 | } | |
93 | ||
94 | if(!uprv_strcmp(o->mode, "common")) { /* only install/clean in our own mode */ | |
95 | T_FileStream_writeLine(makefile, "CLEANFILES= $(CMNLIST) $(TARGET)\n\nclean:\n\t-$(RMV) $(CLEANFILES) $(MAKEFILE)"); | |
96 | T_FileStream_writeLine(makefile, "\n\n"); | |
97 | ||
98 | sprintf(tmp, "install: $(TARGET)\n" | |
99 | "\t$(INSTALL_DATA) $(TARGET) $(INSTALLTO)%s$(TARGETNAME)\n\n", | |
100 | U_FILE_SEP_STRING); | |
101 | ||
102 | T_FileStream_writeLine(makefile, tmp); | |
103 | ||
104 | } | |
105 | } |