Changeset 1832501 in git
- Timestamp:
- Mar 17, 1999, 1:41:31 PM (25 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 1471a87c88809d18580f881efb9a559f31d0baa0
- Parents:
- 773e7f1fa070fb846fa7b455caf6e3fb79049538
- Location:
- modules/tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/tools/Makefile.in
r773e7f r1832501 2 2 # 3 3 # 4 CFLAGS += - I../include -I../../Singular -DNDEBUG -DMODULE_GENERATOR5 LIBS += - lgmp4 CFLAGS += -g -I../include -I../../Singular -DNDEBUG -DMODULE_GENERATOR 5 LIBS += -L/usr/local/lib -lgmp 6 6 7 7 OBJS = scanner.o misc.o … … 15 15 16 16 .cc.o: 17 cc -c ${CFLAGS} $<17 gcc -c ${CFLAGS} $< 18 18 19 19 .c.o: 20 cc -c ${CFLAGS} $<20 gcc -c ${CFLAGS} $< 21 21 22 22 modgen: ${OBJS} modgen.h decl.inc 23 cc -o $@ ${CFLAGS} ${LIBS} ${OBJS}23 gcc -o $@ ${CFLAGS} ${OBJS} ${LIBS} 24 24 25 25 scanner.cc: scanner.l -
modules/tools/misc.cc
r773e7f r1832501 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: misc.cc,v 1. 1 1998-11-19 15:16:41krueger Exp $ */4 /* $Id: misc.cc,v 1.2 1999-03-17 12:41:30 krueger Exp $ */ 5 5 /* 6 6 * ABSTRACT: lib parsing … … 16 16 #include <subexpr.h> 17 17 #include <tok.h> 18 #include <regex.h> 19 18 20 #include "modgen.h" 21 22 #define SYSTYP_NONE 0 23 #define SYSTYP_LINUX 1 24 #define SYSTYP_HPUX9 2 25 #define SYSTYP_HPUX10 3 26 27 char *DYNAinclude[] = { 28 "", 29 "#include <dlfcn.h>", 30 "#include <dl.h>", 31 "#include <dl.h>", 32 "#include <>", 33 "#include <>", 34 "#include <>", 35 NULL 36 }; 37 38 int systyp = SYSTYP_NONE; 19 39 20 40 BOOLEAN expected_parms; … … 200 220 pnew->next = NULL; 201 221 pnew->is_static = 0; 222 pnew->paramcnt = 0; 202 223 strcpy(pnew->procname, name); 203 224 strcpy(pnew->funcname, name); … … 224 245 pp->next = pnew; 225 246 } 226 227 } 228 229 /*========================================================================*/ 230 PrintProclist(procdefv pi)247 (pi->paramcnt)++; 248 } 249 250 /*========================================================================*/ 251 void PrintProclist(procdefv pi) 231 252 { 232 253 procdefv v = pi; 233 254 paramdefv pp; 234 while(v!=NULL) { 255 for(v=pi; v!=NULL; v = v->next) { 256 // while(v!=NULL) { 235 257 pp = v->param; 236 258 printf("proc: %s(", v->procname); … … 243 265 } 244 266 printf(")\n"); 245 v =v ->next; 246 } 247 } 248 249 /*========================================================================*/ 250 void generate_mod(procdefv pi, moddefv module, cfilesv c_filelist) 251 { 252 procdefv v = pi; 267 // v =v ->next; 268 } 269 } 270 271 /*========================================================================*/ 272 void generate_mod( 273 procdefv pi, 274 moddefv module, 275 cfilesv c_filelist 276 ) 277 { 278 procdefv v = NULL; 253 279 FILE *fp_c, *fp_h; 254 280 char *filename; 281 282 if(strcmp(S_UNAME, "ix86-Linux") == 0) { 283 systyp = SYSTYP_LINUX; 284 } else if (strcmp(S_UNAME, "HPUX-9")==0) { 285 systyp = SYSTYP_HPUX9; 286 } else if (strcmp(S_UNAME, "HPUX-10")==0) { 287 systyp = SYSTYP_HPUX10; 288 } 289 printf("SYSTYP:%d\n", systyp); 255 290 256 291 filename = (char *)malloc(strlen(module->name)+5); … … 274 309 if(module->info != NULL) enter_id(fp_c, "info", module->info); 275 310 if(module->helpfile != NULL) enter_id(fp_c, "helpfile", module->helpfile); 276 while(v!=NULL) { 311 for(v=pi; v!=NULL; v = v->next) { 312 // while(v!=NULL) { 313 printf("->%s, %s\n", v->procname, v->funcname); 277 314 fprintf(fp_c, " iiAddCproc(\"%s\",\"%s\",%s, mod_%s);\n", 278 315 module->name, v->procname, 279 316 v->is_static ? "TRUE" : "FALSE", v->funcname); 280 v =v ->next;317 // v =v ->next; 281 318 } 282 319 fprintf(fp_c, " return 0;\n}\n\n"); … … 284 321 285 322 /* building entry-functions */ 286 while(v!=NULL) {323 for(v=pi; v!=NULL; v = v->next) { 287 324 generate_function(v, fp_c); 288 325 generate_header(v, fp_h); 289 v =v ->next;290 326 } 291 327 printf(" done.\n");fflush(stdout); … … 303 339 void generate_function(procdefv pi, FILE *fp) 304 340 { 305 int tok; 341 int cnt = 0, i; 342 printf("%s has %d paramters\n", pi->funcname, pi->paramcnt); 306 343 307 344 paramdefv pp = pi->param; … … 309 346 if(pp!= NULL && pp->typ!=SELF_CMD) { 310 347 fprintf(fp, " leftv v = h;\n"); 311 fprintf(fp, " int tok = NONE;\n"); 312 348 fprintf(fp, " int tok = NONE, index = 0;\n"); 349 for (i=0;i<pi->paramcnt; i++) 350 fprintf(fp, " leftv res%d = (leftv)Alloc0(sizeof(sleftv));\n", i); 351 352 fprintf(fp, "\n"); 353 313 354 while(pp!=NULL) { 314 355 fprintf(fp, " if(v==NULL) goto mod_%s_error;\n", pi->funcname); 315 356 fprintf(fp, " tok = v->Typ();\n"); 316 fprintf(fp, " if(tok!=%s) goto mod_%s_error;\n", 317 pp->typname, pi->funcname); 357 fprintf(fp, " printf(\"test %d.1\\n\");\n", cnt); 358 fprintf(fp, " if((index=iiTestConvert(tok, %s))==0)\n", pp->typname); 359 fprintf(fp, " goto mod_%s_error;\n", pi->funcname); 360 fprintf(fp, " printf(\"test %d.2\\n\");\n", cnt); 361 fprintf(fp, " if(iiConvert(tok, %s, index, v, res%d))\n", 362 pp->typname, cnt); 363 fprintf(fp, " goto mod_%s_error;\n", pi->funcname); 364 fprintf(fp, " printf(\"test %d.3\\n\");\n", cnt); 318 365 fprintf(fp, " v = v->next;\n"); 319 366 pp = pp->next; 367 cnt++; 320 368 } 321 369 fprintf(fp, " if(v!=NULL) { tok = v->Typ(); goto mod_%s_error; }\n", pi->funcname); 370 fprintf(fp, " printf(\"test before return\\n\");\n"); 322 371 323 372 fprintf(fp, "\n"); 324 fprintf(fp, " return(%s(res,h));\n\n", pi->funcname); 373 fprintf(fp, " return(%s(res", pi->funcname); 374 for (i=0;i<pi->paramcnt; i++) 375 fprintf(fp, ", res%d", i); 376 fprintf(fp, "));\n\n"); 325 377 fprintf(fp, " mod_%s_error:\n", pi->funcname); 326 378 fprintf(fp, " Werror(\"%s(`%%s`) is not supported\", Tok2Cmdname(tok));\n", … … 344 396 void mod_write_header(FILE *fp, char *module) 345 397 { 398 #if 0 399 FILE *fp; 400 char buf[BUFLEN]; 401 402 regex_t preg; 403 regmatch_t pmatch[1]; 404 size_t nmatch = 0; 405 char *regex = "@MODULE_NAME@"; 406 407 rc = regcomp(&preg, regex, REG_NOSUB); 408 if(rc) return -1; 409 410 if(!regexec(&preg, d_entry->d_name, nmatch, pmatch, REG_NOTBOL)) 411 cert_count++; 412 regfree(&preg); 413 414 #else 346 415 write_header(fp, module); 347 416 fprintf(fp, "#include <stdlib.h>\n"); … … 349 418 fprintf(fp, "#include <string.h>\n"); 350 419 fprintf(fp, "#include <ctype.h>\n"); 351 fprintf(fp, " #include <dlfcn.h>\n");420 fprintf(fp, "%s\n", DYNAinclude[systyp]); 352 421 fprintf(fp, "\n"); 353 422 fprintf(fp, "#include <locals.h>\n"); 354 423 fprintf(fp, "#include \"%s.h\"\n", module); 355 424 fprintf(fp, "\n"); 356 425 #endif 357 426 } 358 427 … … 363 432 comment, comment); 364 433 fprintf(fp, "%s * version %s\n", comment, MOD_GEN_VERSION); 434 fprintf(fp, "%s * module %s\n", comment, module); 365 435 fprintf(fp, "%s * Don't edit this file\n%s */\n", comment, comment); 366 436 fprintf(fp, "%s\n", comment); … … 387 457 static char *object_name(char *p) 388 458 { 389 char *q = strrchr(p, '.');459 char *q = (char *)strrchr(p, '.'); 390 460 if(q==NULL) return ""; 391 461 *q = '\0'; 392 462 char *r = (char *)malloc(strlen(p)+4); 393 sprintf(r, "%s.lo", p); 463 switch(systyp) { 464 case SYSTYP_LINUX: 465 sprintf(r, "%s.lo", p); 466 break; 467 468 case SYSTYP_HPUX9: 469 sprintf(r, "%s.o", p); 470 break; 471 } 472 394 473 *q = '.'; 395 474 return(r); … … 408 487 fprintf(fp, "CXX\t= gcc\n"); 409 488 fprintf(fp, "CFLAGS\t= -DNDEBUG -I. -I../include\n"); 489 fprintf(fp, "#LD\t=\n"); 410 490 fprintf(fp, "\n"); 411 491 fprintf(fp, "SRCS\t= "); … … 418 498 419 499 fprintf(fp, "\n\n"); 420 fprintf(fp, "all:\t%s.so\n", module->name); 421 fprintf(fp, "\n"); 422 fprintf(fp, "%%.lo: %%.cc Makefile\n"); 423 fprintf(fp, "\t${CC} ${CFLAGS} -c -fPIC -DPIC $< -o $*.lo\n"); 424 fprintf(fp, "\n"); 425 426 fprintf(fp, "%%.la: %%.cc Makefile\n"); 427 fprintf(fp, "\t${CC} ${CFLAGS} -c $< -o $*.la\n"); 428 fprintf(fp, "\n"); 429 430 fprintf(fp, "%s.so: ${OBJS}\n", module->name); 431 fprintf(fp, "\t${CC} ${CFLAGS} -shared -Wl,-soname -Wl,%s.so.%d \\\n", 432 module->name, module->major); 433 fprintf(fp, "\t\t-o %s.so.%d.%d.%d ${OBJS}\n", module->name, 434 module->major, module->minor, module->level); 435 fprintf(fp, "\trm -f %s.so\n", module->name); 436 fprintf(fp, "\tln -s %s.so.%d.%d.%d %s.so\n", module->name, module->major, 437 module->minor, module->level, module->name); 438 fprintf(fp, "\n"); 500 switch(systyp) { 501 case SYSTYP_LINUX: 502 fprintf(fp, "all:\t%s.so\n", module->name); 503 fprintf(fp, "\n"); 504 fprintf(fp, "%%.lo: %%.cc Makefile\n"); 505 fprintf(fp, "\t${CC} ${CFLAGS} -c -fPIC -DPIC $< -o $*.lo\n"); 506 fprintf(fp, "\n"); 507 508 fprintf(fp, "%%.la: %%.cc Makefile\n"); 509 fprintf(fp, "\t${CC} ${CFLAGS} -c $< -o $*.la\n"); 510 fprintf(fp, "\n"); 511 512 fprintf(fp, "%s.so: ${OBJS}\n", module->name); 513 fprintf(fp, "\t${CC} ${CFLAGS} -shared -Wl,-soname -Wl,%s.so.%d \\\n", 514 module->name, module->major); 515 fprintf(fp, "\t\t-o %s.so.%d.%d.%d ${OBJS}\n", module->name, 516 module->major, module->minor, module->level); 517 fprintf(fp, "\trm -f %s.so\n", module->name); 518 fprintf(fp, "\tln -s %s.so.%d.%d.%d %s.so\n", module->name, module->major, 519 module->minor, module->level, module->name); 520 fprintf(fp, "\n"); 521 break; 522 523 case SYSTYP_HPUX9: 524 fprintf(fp, "all:\t%s.sl\n", module->name); 525 fprintf(fp, "\n"); 526 fprintf(fp, "%%.o: %%.cc Makefile\n"); 527 fprintf(fp, "\t${CC} ${CFLAGS} -c -fPIC -DPIC $< -o $*.o\n"); 528 fprintf(fp, "\n"); 529 fprintf(fp, "%s.sl: ${OBJS}\n", module->name); 530 fprintf(fp, "\t${LD} -b -o %s.sl \\\n", module->name); 531 fprintf(fp, "\t\t${OBJS}\n"); 532 break; 533 534 } 439 535 440 536 fprintf(fp, "clean:\n"); 441 fprintf(fp, "\trm -f *.o *.lo *.so* *. la *~ core\n\n");537 fprintf(fp, "\trm -f *.o *.lo *.so* *.sl *.la *~ core\n\n"); 442 538 443 539 fprintf(fp, "distclean: clean\n"); -
modules/tools/modgen.h
r773e7f r1832501 1 1 /* 2 * $Id: modgen.h,v 1. 1 1998-11-19 15:16:42krueger Exp $2 * $Id: modgen.h,v 1.2 1999-03-17 12:41:31 krueger Exp $ 3 3 * 4 4 */ 5 5 6 #define MOD_GEN_VERSION "0.1" 6 #define MOD_GEN_VERSION "0.2" 7 8 #define BUFLEN 128 9 #define TMPL_HEAD "" 10 #define TMPL_FOOT "" 7 11 8 12 class paramdef; … … 31 35 int is_static; 32 36 paramdefv param; 37 int paramcnt; 33 38 }; 34 39 … … 42 47 public: 43 48 char * name; 44 unsigned short major, minor, level;49 unsigned int major, minor, level; 45 50 char * version; 46 51 char * revision; … … 56 61 57 62 extern procdefv Add2proclist(procdefv pi, char *name); 58 extern PrintProclist(procdefv pi);59 63 extern void AddParam(procdefv pi, char *name, char *typname, int typ); 60 64 extern void generate_mod(procdefv pi, moddefv module, cfilesv c_filelist); … … 66 70 extern void make_version(char *p, moddefv module); 67 71 extern cfilesv Add2files(cfilesv cf, char *buff); 72 extern void PrintProclist(procdefv pi); 73 -
modules/tools/scanner.l
r773e7f r1832501 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 /* $Id: scanner.l,v 1. 1 1998-11-19 15:16:43krueger Exp $ */5 /* $Id: scanner.l,v 1.2 1999-03-17 12:41:31 krueger Exp $ */ 6 6 #include <stdio.h> 7 7 #include <string.h> … … 122 122 } 123 123 <pdef>{name}+, { 124 char param[256], n1[32],n2[32];124 char param[256], n2[32]; 125 125 int cmd; 126 126 param[0]='\0'; … … 132 132 } 133 133 <pdef>{name}+\)+{eq}+{name} { 134 char param[256], n1[32],n2[32],funcname[256];134 char param[256], n2[32],funcname[256]; 135 135 int cmd; 136 136 BEGIN(old_state); 137 memset(funcname, '\0', 256); 137 138 param[0]='\0'; 138 139 sscanf( yytext, "%[^)])%*[^=]=%s", param, funcname); … … 148 149 <pdef>\)+{eq}+{name}|{eq}+{tos}+{name} { 149 150 char funcname[256]; 150 int cmd;151 151 BEGIN(old_state); 152 152 sscanf( yytext, "%*[^=]=%s", funcname); … … 173 173 int yywrap() { 174 174 //printf("yywrap()\n"); 175 return 1; 175 176 } 176 177 } … … 188 189 module_def.helpfile=NULL; 189 190 yylex(); 190 //PrintProclist(proclist);191 PrintProclist(proclist); 191 192 generate_mod(proclist, &module_def, c_filelist); 192 193 mod_create_makefile(&module_def, c_filelist);
Note: See TracChangeset
for help on using the changeset viewer.