options.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. *
  5. * Author: Ceriel J.H. Jacobs
  6. */
  7. /* U S E R O P T I O N - H A N D L I N G */
  8. /* stripped down version from the one in the Modula-2 compiler */
  9. /* $Header$ */
  10. #include <alloc.h>
  11. #include "main.h"
  12. static int ndirs = 1;
  13. DoOption(text)
  14. register char *text;
  15. {
  16. extern char *mflags;
  17. extern char *suff;
  18. extern char *compiler;
  19. extern char *llibs;
  20. switch(*text++) {
  21. case 'L' :
  22. AddLibDir(text);
  23. break;
  24. case 'I' :
  25. AddInclDir(text);
  26. break;
  27. case 'M':
  28. mflags = text;
  29. break;
  30. case 'C':
  31. compiler = text;
  32. break;
  33. case 'S':
  34. suff = text;
  35. break;
  36. case 'l':
  37. { static unsigned int liblen = 0;
  38. unsigned int len = strlen(text) + 4;
  39. if (liblen) {
  40. llibs = Realloc(llibs, liblen += len);
  41. }
  42. else {
  43. llibs = Malloc(liblen = len);
  44. *llibs = '\0';
  45. }
  46. strcat(llibs,"\\\n\t");
  47. strcat(llibs, text);
  48. }
  49. break;
  50. default:
  51. Gerror("Unrecognized option: -%s", text-1);
  52. break;
  53. }
  54. }
  55. AddInclDir(text)
  56. char *text;
  57. {
  58. register int i;
  59. register char *new = text;
  60. if (! *text) {
  61. DEFPATH[ndirs] = 0;
  62. return;
  63. }
  64. if (++nDEF > mDEF) {
  65. mDEF += 10;
  66. DEFPATH = (char **) Realloc((char *)DEFPATH,
  67. (unsigned)(mDEF * sizeof(char *)));
  68. }
  69. for (i = ndirs++; i < nDEF; i++) {
  70. char *tmp = DEFPATH[i];
  71. DEFPATH[i] = new;
  72. new = tmp;
  73. }
  74. }
  75. AddLibDir(text)
  76. char *text;
  77. {
  78. if (*text) {
  79. set_libdir(ndirs);
  80. AddInclDir(text);
  81. }
  82. }