~ubuntu-branches/ubuntu/quantal/icu/quantal

« back to all changes in this revision

Viewing changes to source/tools/pkgdata/cmnmode.c

  • Committer: Package Import Robot
  • Author(s): Yves Arrouye
  • Date: 2002-03-03 15:31:13 UTC
  • Revision ID: package-import@ubuntu.com-20020303153113-3ssceqlq45xbmbnc
Tags: upstream-2.0-2.1pre20020303
ImportĀ upstreamĀ versionĀ 2.0-2.1pre20020303

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
*
 
3
*   Copyright (C) 2000, International Business Machines
 
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"
 
22
#include "cmemory.h"
 
23
#include "cstring.h"
 
24
#include "filestrm.h"
 
25
#include "toolutil.h"
 
26
#include "unewdata.h"
 
27
#include "uoptions.h"
 
28
#include "pkgtypes.h"
 
29
#include "makefile.h"
 
30
 
 
31
void pkg_mode_common(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
 
32
{
 
33
  char tmp[1024];
 
34
  CharList *tail = NULL;
 
35
 
 
36
  uprv_strcpy(tmp, UDATA_CMN_PREFIX);
 
37
  uprv_strcat(tmp, o->shortName);
 
38
  uprv_strcat(tmp, UDATA_CMN_SUFFIX);
 
39
  
 
40
  if(!uprv_strcmp(o->mode, "common")) {
 
41
    /* If we're not the main mode.. don't change the output file list */
 
42
    
 
43
    /* We should be the only item. So we don't care about the order. */
 
44
    o->outFiles = pkg_appendToList(o->outFiles, &tail, uprv_strdup(tmp));
 
45
    
 
46
    if(o->nooutput || o->verbose) {
 
47
      fprintf(stdout, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp);
 
48
    }
 
49
    
 
50
    if(o->nooutput) {
 
51
      *status = U_ZERO_ERROR;
 
52
      return;
 
53
    }
 
54
    
 
55
    sprintf(tmp, "# File to make:\nTARGET=%s%s%s\n\nTARGETNAME=%s\n", o->targetDir,
 
56
            U_FILE_SEP_STRING,
 
57
            o->outFiles->str,
 
58
            o->outFiles->str);
 
59
    T_FileStream_writeLine(makefile, tmp);
 
60
  } else {
 
61
    /* We're in another mode. but, set the target so they can find us.. */
 
62
    T_FileStream_writeLine(makefile, "TARGET=");
 
63
    T_FileStream_writeLine(makefile, tmp);
 
64
    T_FileStream_writeLine(makefile, "\n\n");
 
65
    
 
66
  } /* end [check to make sure we are in mode 'common' ] */
 
67
  
 
68
  sprintf(tmp, "# List file for gencmn:\n"
 
69
          "CMNLIST=%s%s%s_common.lst\n\n",
 
70
          o->tmpDir,
 
71
          U_FILE_SEP_STRING,
 
72
          o->shortName);
 
73
  T_FileStream_writeLine(makefile, tmp);
 
74
 
 
75
  sprintf(tmp, "all: $(TARGET)\n\n");
 
76
  T_FileStream_writeLine(makefile, tmp);
 
77
  
 
78
  T_FileStream_writeLine(makefile, "$(TARGET): $(CMNLIST) $(DATAFILEPATHS)\n"
 
79
               "\t$(INVOKE) $(GENCMN) -n $(NAME) -c -d $(TARGETDIR) 0 $(CMNLIST)\n\n");
 
80
 
 
81
  if(o->hadStdin == FALSE) { /* shortcut */
 
82
    T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n"
 
83
                                   "\tcat $(LISTFILES) > $(CMNLIST)\n\n");
 
84
  } else {
 
85
    T_FileStream_writeLine(makefile, "$(CMNLIST): \n"
 
86
                                   "\t@echo \"generating $@ (list of data files)\"\n"
 
87
                                   "\t@-$(RMV) $@\n"
 
88
                                   "\t@for file in $(DATAFILEPATHS); do \\\n"
 
89
                                   "\t  echo $$file >> $@; \\\n"
 
90
                                   "\tdone;\n\n");
 
91
  }
 
92
 
 
93
  if(!uprv_strcmp(o->mode, "common")) { /* only install/clean in our own mode */
 
94
    T_FileStream_writeLine(makefile, "CLEANFILES= $(CMNLIST) $(TARGET)\n\nclean:\n\t-$(RMV) $(CLEANFILES) $(MAKEFILE)");
 
95
    T_FileStream_writeLine(makefile, "\n\n");
 
96
    
 
97
    sprintf(tmp, "install: $(TARGET)\n"
 
98
            "\t$(INSTALL_DATA) $(TARGET) $(INSTALLTO)%s$(TARGETNAME)\n\n",
 
99
            U_FILE_SEP_STRING);
 
100
 
 
101
    T_FileStream_writeLine(makefile, tmp);
 
102
 
 
103
  }
 
104
}