]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/pkgdata/cmnmode.c
ICU-6.2.4.tar.gz
[apple/icu.git] / icuSources / tools / pkgdata / cmnmode.c
CommitLineData
b75a7d8f
A
1/******************************************************************************
2*
374ca955 3* Copyright (C) 2000-2004, 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
32void 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
374ca955 79 if(!o->embed) {
b75a7d8f 80 T_FileStream_writeLine(makefile, "$(TARGET): $(CMNLIST) $(DATAFILEPATHS)\n"
374ca955
A
81 "\t$(INVOKE) $(GENCMN) -n $(CNAME) -c -s $(SRCDIR) -d $(TARGETDIR) 0 $(CMNLIST)\n\n");
82 } else {
83 T_FileStream_writeLine(makefile, "$(TARGET): $(CMNLIST) $(DATAFILEPATHS)\n"
84 "\t$(INVOKE) $(GENCMN) -n $(CNAME) -c -d $(TARGETDIR) 0 -E $(CMNLIST)\n\n");
85 }
b75a7d8f
A
86
87 if(o->hadStdin == FALSE) { /* shortcut */
88 T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n"
89 "\tcat $(LISTFILES) > $(CMNLIST)\n\n");
90 } else {
91 T_FileStream_writeLine(makefile, "$(CMNLIST): \n"
92 "\t@echo \"generating $@ (list of data files)\"\n"
93 "\t@-$(RMV) $@\n"
94 "\t@for file in $(DATAFILEPATHS); do \\\n"
95 "\t echo $$file >> $@; \\\n"
96 "\tdone;\n\n");
97 }
98
99 if(!uprv_strcmp(o->mode, "common")) { /* only install/clean in our own mode */
100 T_FileStream_writeLine(makefile, "CLEANFILES= $(CMNLIST) $(TARGET)\n\nclean:\n\t-$(RMV) $(CLEANFILES) $(MAKEFILE)");
101 T_FileStream_writeLine(makefile, "\n\n");
102
103 sprintf(tmp, "install: $(TARGET)\n"
104 "\t$(INSTALL_DATA) $(TARGET) $(INSTALLTO)%s$(TARGETNAME)\n\n",
105 U_FILE_SEP_STRING);
106
107 T_FileStream_writeLine(makefile, tmp);
108
109 }
110}