diff --git a/icu4c/source/data/makedata.mak b/icu4c/source/data/makedata.mak index 4e659e16f56..157df5b9c77 100644 --- a/icu4c/source/data/makedata.mak +++ b/icu4c/source/data/makedata.mak @@ -129,17 +129,6 @@ ICUTOOLS=$(ICUP)\source\tools PATH = $(PATH);$(ICUP)\bin - -# We have to prepare params for pkgdata - to help it find the tools -!IF "$(CFG)" == "Debug" || "$(CFG)" == "debug" -!MESSAGE makedata.mak: doing a Debug build. -PKGOPT=D:$(ICUP) -!ELSE -!MESSAGE makedata.mak: doing a Release build. -PKGOPT=R:$(ICUP) -!ENDIF - - # Suffixes for data files .SUFFIXES : .ucm .cnv .dll .dat .res .txt .c @@ -249,7 +238,7 @@ ALL : GODATA "$(DLL_OUTPUT)\$(U_ICUDATA_NAME).dll" "$(TESTDATAOUT)\testdata.dat" "$(TESTDATAOUT)\testdata.dat": $(ICUDT)ucadata.icu $(TRANSLIT_FILES) $(MISC_FILES) $(RB_FILES) {"$(ICUTOOLS)\genrb\$(CFG)"}genrb.exe @cd "$(TESTDATA)" @echo building testdata... - nmake /nologo /f "$(TESTDATA)\testdata.mk" TESTDATA=. ICUTOOLS="$(ICUTOOLS)" PKGOPT="$(PKGOPT)" CFG=$(CFG) TESTDATAOUT="$(TESTDATAOUT)" ICUDATA="$(ICUDATA)" TESTDATABLD="$(TESTDATABLD)" + nmake /nologo /f "$(TESTDATA)\testdata.mk" TESTDATA=. ICUTOOLS="$(ICUTOOLS)" ICUP="$(ICUP)" CFG=$(CFG) TESTDATAOUT="$(TESTDATAOUT)" ICUDATA="$(ICUDATA)" TESTDATABLD="$(TESTDATABLD)" # # Break iterator data files. @@ -261,10 +250,10 @@ BRK_FILES = $(ICUDT)sent.brk $(ICUDT)char.brk $(ICUDT)line.brk $(ICUDT)word.brk # move the .dll and .lib files to their final destination afterwards. # The $(U_ICUDATA_NAME).lib and $(U_ICUDATA_NAME).exp should already be in the right place due to stubdata. # -"$(DLL_OUTPUT)\$(U_ICUDATA_NAME).dll" : "$(ICUTOOLS)\pkgdata\$(CFG)\pkgdata.exe" $(CNV_FILES) $(BRK_FILES) "$(ICUBLD)\$(ICUDT)uprops.icu" "$(ICUBLD)\$(ICUDT)unames.icu" "$(ICUBLD)\$(ICUDT)pnames.icu" "$(ICUBLD)\$(ICUDT)unorm.icu" "$(ICUBLD)\$(ICUDT)cnvalias.icu" "$(ICUBLD)\$(ICUDT)ucadata.icu" "$(ICUBLD)\$(ICUDT)invuca.icu" "$(ICUBLD)\$(ICUDT)uidna.spp" $(ALL_RES) "$(ICUBLD)\$(ICUDT)icudata.res" "$(ICUP)\source\stubdata\stubdatabuilt.txt" +"$(DLL_OUTPUT)\$(U_ICUDATA_NAME).dll" : "$(ICUP)\bin\pkgdata.exe" $(CNV_FILES) $(BRK_FILES) "$(ICUBLD)\$(ICUDT)uprops.icu" "$(ICUBLD)\$(ICUDT)unames.icu" "$(ICUBLD)\$(ICUDT)pnames.icu" "$(ICUBLD)\$(ICUDT)unorm.icu" "$(ICUBLD)\$(ICUDT)cnvalias.icu" "$(ICUBLD)\$(ICUDT)ucadata.icu" "$(ICUBLD)\$(ICUDT)invuca.icu" "$(ICUBLD)\$(ICUDT)uidna.spp" $(ALL_RES) "$(ICUBLD)\$(ICUDT)icudata.res" "$(ICUP)\source\stubdata\stubdatabuilt.txt" @echo Building icu data @cd "$(ICUBLD)" - @"$(ICUTOOLS)\pkgdata\$(CFG)\pkgdata" -f -e $(U_ICUDATA_NAME) -v -m dll -c -p $(ICUPKG) -O "$(PKGOPT)" -d "$(ICUBLD)" -s . <value = buf; - option->doesOccur = TRUE; + FILE *p; + size_t n; + static char buf[512] = ""; + static const char cmd[] = "icu-config --incfile"; + + if(options[5].doesOccur) + { + /* informational */ + fprintf(stderr, "%s: No -O option found, trying '%s'.\n", progname, cmd); + } + + p = popen(cmd, "r"); + + if(p == NULL) + { + fprintf(stderr, "%s: icu-config: No icu-config found. (fix PATH or use -O option)\n", progname); + return; + } + + n = fread(buf, 1, 511, p); + + pclose(p); + + if(n<=0) + { + fprintf(stderr,"%s: icu-config: Could not read from icu-config. (fix PATH or use -O option)\n", progname); + return; + } + + if(buf[strlen(buf)-1]=='\n') + { + buf[strlen(buf)-1]=0; + } + + if(buf[0] == 0) + { + fprintf(stderr, "%s: icu-config: invalid response from icu-config (fix PATH or use -O option)\n", progname); + return; + } + + if(options[5].doesOccur) + { + /* informational */ + fprintf(stderr, "%s: icu-config: using '-O %s'\n", progname, buf); + } + option->value = buf; + option->doesOccur = TRUE; #else /* ! U_HAVE_POPEN */ - /* no popen available */ - /* Put other OS specific ways to search for the Makefile.inc type - information or else fail.. */ +#ifdef WIN32 + char tmp[1024]; + char *fullEXEpath = _fullpath(tmp, progname, sizeof(tmp)); + char *pathstuff = (char *)options[1].value; + + if (fullEXEpath) { + pathstuff = strrchr(fullEXEpath, U_FILE_SEP_CHAR); + if (pathstuff) { + pathstuff[1] = 0; + uprv_memmove(fullEXEpath + 2, fullEXEpath, uprv_strlen(fullEXEpath)+1); + fullEXEpath[0] = PKGDATA_DERIVED_PATH; + fullEXEpath[1] = ':'; + option->value = uprv_strdup(fullEXEpath); + option->doesOccur = TRUE; + } + } + /* else can't determine the path */ +#endif + + /* no popen available */ + /* Put other OS specific ways to search for the Makefile.inc type + information or else fail.. */ #endif } diff --git a/icu4c/source/tools/pkgdata/pkgtypes.h b/icu4c/source/tools/pkgdata/pkgtypes.h index 860c958f80a..0f62407f23c 100644 --- a/icu4c/source/tools/pkgdata/pkgtypes.h +++ b/icu4c/source/tools/pkgdata/pkgtypes.h @@ -147,5 +147,6 @@ typedef struct UPKGOptions_ #define UDATA_CMN_SUFFIX ".dat" #define UDATA_CMN_INTERMEDIATE_SUFFIX "_dat" +#define PKGDATA_DERIVED_PATH '\t' #endif diff --git a/icu4c/source/tools/pkgdata/winmode.c b/icu4c/source/tools/pkgdata/winmode.c index 2925392321b..734582ff30a 100644 --- a/icu4c/source/tools/pkgdata/winmode.c +++ b/icu4c/source/tools/pkgdata/winmode.c @@ -32,7 +32,8 @@ #include #include -#define WINBUILDMODE (*(o->options)=='R'?"Release":"Debug") +/*#define WINBUILDMODE (*(o->options)=='R'?"Release":"Debug")*/ +#define CONTAINS_REAL_PATH(o) (*(o->options)==PKGDATA_DERIVED_PATH) void writeCmnRules(UPKGOptions *o, FileStream *makefile) { @@ -79,8 +80,14 @@ void pkg_mode_windows(UPKGOptions *o, FileStream *makefile, UErrorCode *status) sprintf(tmp2, "ICUROOT=%s\n\n", o->icuroot); T_FileStream_writeLine(makefile, tmp2); - sprintf(tmp2, - "GENCMN = $(ICUROOT)%sbin\\gencmn.exe\n", separator); + if (CONTAINS_REAL_PATH(o)) { + sprintf(tmp2, + "GENCMN = $(ICUROOT)%sgencmn.exe\n", separator); + } + else { + sprintf(tmp2, + "GENCMN = $(ICUROOT)%sbin\\gencmn.exe\n", separator); + } T_FileStream_writeLine(makefile, tmp2); if(isDll) { @@ -110,8 +117,14 @@ void pkg_mode_windows(UPKGOptions *o, FileStream *makefile, UErrorCode *status) ); T_FileStream_writeLine(makefile, tmp2); - sprintf(tmp2, - "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator); + if (CONTAINS_REAL_PATH(o)) { + sprintf(tmp2, + "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator); + } + else { + sprintf(tmp2, + "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator); + } T_FileStream_writeLine(makefile, tmp2); T_FileStream_writeLine(makefile, "\n" @@ -159,8 +172,15 @@ void pkg_mode_windows(UPKGOptions *o, FileStream *makefile, UErrorCode *status) ); T_FileStream_writeLine(makefile, tmp2); - sprintf(tmp2, - "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator); + + if (CONTAINS_REAL_PATH(o)) { + sprintf(tmp2, + "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator); + } + else { + sprintf(tmp2, + "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator); + } T_FileStream_writeLine(makefile, tmp2); T_FileStream_writeLine(makefile, "\n"