@@ -101,6 +101,7 @@ static char *strupr(char *s)
101101#define fEXT ".lng"
102102#define fDMAKEFILE "makefile"
103103#define fTCMAKEFILE "strings.rsp"
104+ #define fTCMAKFILE "strings.mak"
104105
105106typedef enum STATE {
106107 LOOKING_FOR_START
@@ -644,6 +645,47 @@ int loadFile(const char * const fnam)
644645 return 0 ;
645646}
646647
648+ static int create_make_dependency (void )
649+ {
650+ string_count_t cnt1 ;
651+ string_count_t maxCnt1 ;
652+ string_count_t cnt2 ;
653+
654+ strcpy (cfilename , fTCMAKFILE );
655+ if ((lgf = fopen (cfile , "wt" )) == NULL ) {
656+ pxerror ("creating " , cfile );
657+ return 101 ;
658+ }
659+ cnt1 = maxCnt1 = cnt2 = 0 ;
660+ for (cnt = 0 ; cnt < maxCnt ; ++ cnt ) {
661+ if ( cnt1 == 0 ) {
662+ if ( cnt > 0 )
663+ fprintf (lgf , "\n" );
664+ fprintf (lgf , "strings_deps%d : \\\n" , maxCnt1 ++ );
665+ cnt2 = 0 ;
666+ }
667+ fprintf (lgf , " " objfmt , cnt );
668+ if (++ cnt1 > 127 ) {
669+ cnt1 = 0 ;
670+ }
671+ if (++ cnt2 > 7 && cnt1 > 0 ) {
672+ fprintf (lgf , " \\\n" );
673+ cnt2 = 0 ;
674+ }
675+ }
676+ for (cnt = 0 ; cnt < maxCnt1 ; ++ cnt ) {
677+ if ( cnt == 0 )
678+ fprintf (lgf , "\nSTRINGS_DEPS =" );
679+ fprintf (lgf , " strings_deps%d" , cnt );
680+ }
681+ fflush (lgf );
682+ if (ferror (lgf )) {
683+ puts ("Unspecific error writing to " fTCMAKFILE );
684+ return 104 ;
685+ }
686+ fclose (lgf );
687+ return 0 ;
688+ }
647689
648690int main (int argc , char * * argv )
649691{
@@ -653,18 +695,42 @@ int main(int argc, char **argv)
653695 string_count_t cnt ; /* current string number */
654696 string_size_t lsize ;
655697 int makeLib = 0 ;
698+ const char * fmt ;
656699
657700 unlink (logfile );
658701
659- if (argv [1 ] && (stricmp (argv [1 ], "/lib" ) == 0 || stricmp (argv [1 ], "--lib" ) == 0 )) {
660- -- argc ;
661- ++ argv ;
662- makeLib = 1 ;
702+ while (argv [1 ] != NULL ) {
703+ if (stricmp (argv [1 ], "/lib" ) == 0 || stricmp (argv [1 ], "--lib" ) == 0 ) {
704+ -- argc ;
705+ ++ argv ;
706+ makeLib = 1 ;
707+ } else if (stricmp (argv [1 ], "/lib1" ) == 0 || stricmp (argv [1 ], "--lib1" ) == 0 ) {
708+ -- argc ;
709+ ++ argv ;
710+ makeLib = 2 ;
711+ } else if (stricmp (argv [1 ], "/lib2" ) == 0 || stricmp (argv [1 ], "--lib2" ) == 0 ) {
712+ -- argc ;
713+ ++ argv ;
714+ makeLib = 3 ;
715+ } else {
716+ break ;
717+ }
663718 }
664719
665- if (argc > 2 ) {
720+ /*
721+ * Hidden options lib and lib1 and lib2
722+ *
723+ * if one of these option is used then program generate strings library
724+ * source files and generate make files and response file for make utility
725+ *
726+ * lib.. options control response file format
727+ * lib2 format is '+<file name> &'
728+ * lib1 format is '+<file name>'
729+ * lib format is '<file name>' only
730+ */
731+ if (argc > 2 ) {
666732 puts ("FIXSTRS - Generate STRINGS.DAT and STRINGS.H for a language\n"
667- "Useage: FIXSTRS [/lib] [language]\n"
733+ "Useage: FIXSTRS [/lib|/lib1|/lib2 ] [language]\n"
668734 "\tIf no language is specified, only the default strings are read.\n"
669735 "\tThe <language>.LNG file must reside in the current directory.\n"
670736 "Note: DEFAULT.lng must be present in the current directory, too." );
@@ -822,6 +888,8 @@ puts("FIXSTRS: building STRINGS resource");
822888 pxerror ("creating " , cfile );
823889 return 100 ;
824890 }
891+ if ((rc = create_make_dependency ()) != 0 )
892+ return rc ;
825893 strcpy (cfilename , fTCMAKEFILE );
826894 if ((ftc101 = fopen (cfile , "wt" )) == NULL ) {
827895 pxerror ("creating " , cfile );
@@ -847,19 +915,27 @@ strings.lib .LIBRARY : ", fdmake);
847915 dumpString (cnt );
848916 fprintf (fdmake , "\\\n\t" objfmt , cnt );
849917 }
850- for (cnt = 0 ; cnt < maxCnt - 1 ; ++ cnt )
851- #if defined(__TURBOC__ )
852- fprintf (ftc101 , "+" objfmt " &\n" , cnt );
853- #elif defined(GCC )
854- fprintf (ftc101 , objfmt "\n" , cnt );
855- #else
856- fprintf (ftc101 , "+" objfmt "\n" , cnt );
857- #endif
858- #if defined(GCC )
859- fprintf (ftc101 , objfmt " \n" , cnt );
860- #else
861- fprintf (ftc101 , "+" objfmt " \n" , cnt );
862- #endif
918+ if (makeLib == 3 ) {
919+ /* Turbo C */
920+ fmt = "+" objfmt " &\n" ;
921+ } else if (makeLib == 2 ) {
922+ /* Borland C */
923+ fmt = "+" objfmt "\n" ;
924+ } else {
925+ /* GCC, Open Watcom */
926+ fmt = objfmt "\n" ;
927+ }
928+ for (cnt = 0 ; cnt < maxCnt - 1 ; ++ cnt ) {
929+ fprintf (ftc101 , fmt , cnt );
930+ }
931+ if (makeLib > 1 ) {
932+ /* Borland C, Turbo C */
933+ fmt = "+" objfmt "\n" ;
934+ } else {
935+ /* GCC, Open Watcom */
936+ fmt = objfmt "\n" ;
937+ }
938+ fprintf (ftc101 , fmt , cnt );
863939 /********************** epilogue */
864940
865941 fputs ("\n\
0 commit comments