initMacros must be called someplace to enable full reursion.
authorjbj <devnull@localhost>
Fri, 7 Aug 1998 18:35:05 +0000 (18:35 +0000)
committerjbj <devnull@localhost>
Fri, 7 Aug 1998 18:35:05 +0000 (18:35 +0000)
Suggestions for further arch/os decimation.

CVS patchset: 2238
CVS date: 1998/08/07 18:35:05

Makefile.inc.in
lib/Makefile.in
lib/macro.c
lib/rpmmacro.h
lib/rpmrc.c
rpmio/macro.c
rpmio/rpmmacro.h

index acfc27a..47639b9 100644 (file)
@@ -13,7 +13,7 @@ FINDPROVIDES=$(RPMCONFIGDIR)/find-provides
 FINDREQUIRES=$(RPMCONFIGDIR)/find-requires
 LIBRPMRC_FILENAME=$(RPMCONFIGDIR)/rpmrc
 LIBRPMALIAS_FILENAME=$(RPMCONFIGDIR)/rpmpopt
-MACROFILE=$(RPMCONFIGDIR)/macros
+MACROFILES=$(RPMCONFIGDIR)/macros
 RPMNLSDIR=@datadir@/locale
 RPMNLSPACKAGE=rpm
 CFLAGS = -I$(topdir) -I$(topsrcdir) @CFLAGS@ @INCPATH@ $(OPTS) \
index fbdf286..3c5e025 100644 (file)
@@ -37,7 +37,7 @@ misc.o: misc.c
 
 # ditto
 rpmrc.o: rpmrc.c
-       $(CC) $(CFLAGS) -DLIBRPMRC_FILENAME="\"$(LIBRPMRC_FILENAME)"\" -DMACROFILE=\"$(MACROFILE)\" -o $@ -c $<
+       $(CC) $(CFLAGS) -DLIBRPMRC_FILENAME="\"$(LIBRPMRC_FILENAME)"\" -DMACROFILES=\"$(MACROFILES)\" -o $@ -c $<
 
 $(PROGS): $(LIBRPM)
 
index c7d11ac..fc2f6fa 100644 (file)
@@ -1128,7 +1128,7 @@ initMacros(MacroContext *mc, const char *macrofile)
                                continue;
                        n++;
                        mb->mc = mc;    /* XXX just enough to get by */
-                       doDefine(mb, n, RMIL_MACROFILE, 0);
+                       doDefine(mb, n, RMIL_MACROFILES, 0);
                }
                fclose(fp);
        }
index 4f92426..6d3725b 100644 (file)
@@ -19,7 +19,7 @@ typedef struct MacroContext {
 /*
  * Markers for types of macros added throughout rpm.
  */
-#define        RMIL_MACROFILE  -9
+#define        RMIL_MACROFILES -9
 #define        RMIL_RPMRC      -7
 #define        RMIL_SPEC       -1
 #define        RMIL_OLDSPEC    -1
index 61eb894..d184592 100644 (file)
@@ -478,6 +478,7 @@ addMacro(&globalMacroContext, "_buildos_lc", NULL, buf, RMIL_RPMRC);
 /*    rpmSetMachine(canonarch, canonos); */
 
 
+/* XXX getMacroBody() may be nuked -- (see below) */
 buildarch = (char *) getMacroBody(&globalMacroContext, "buildarch");
 buildos = (char *) getMacroBody(&globalMacroContext, "buildos");
 
@@ -517,6 +518,9 @@ static void setPathDefault(int var, char *macroname, char *subdir) {
 
 static void setDefaults(void) {
 
+    /* Read in all macro files (and also set maximum recursion depth) */
+    initMacros(&globalMacroContext, MACROFILES);
+
     rpmSetVar(RPMVAR_OPTFLAGS, "-O2");
     rpmSetVar(RPMVAR_SIGTYPE, "none");
     rpmSetVar(RPMVAR_DEFAULTDOCDIR, "/usr/doc");
@@ -655,6 +659,18 @@ static int doReadRC(int fd, char * filename) {
            }
 
            switch (option->var) {
+/*
+ * XXX This can *easily* be achieved by just 
+ *     1) Create a file someplace.
+ *     2) Put whatever macros you want in it.
+ *     3) Add the file name to MACROFILE in Makefile.inc.in --
+ *     the compile parameter is actually a ':' separated list.
+ * I'll change the name to MACROFILES :-)
+ *
+ *     Alternatively, I'd rather just slurp the entire rpmrc file
+ *     and run it through expandMacros() before parsing here -- all %define
+ *     lines will work just fine without adding more syntax here.
+ */
            case RPMVAR_SETENV:
              {
                char * macroname, *envname;
@@ -1095,6 +1111,19 @@ void rpmRebuildPlatformVars(char ** buildplatform, char **canonarch,
     int x;
 /*
 */
+
+/*
+ * XXX getMacroBody() may be nuked -- I originally added it for tdyas and it's
+ * kinda half-baked (remember, each macro is actually a stack so it's not
+ * clear which body is intended).
+ *
+ * You can, however, always do
+ *     char buf[BUFSIZ];
+ *     strcpy(buf, "%_buildplatform_preset")
+ *     expandMacros(NULL, &globalMacroContext, buf, sizeof(buf))) {
+ *     presetbuildplatform = strdup(buf);
+ *
+ */
     presetbuildplatform= (char *) getMacroBody(&globalMacroContext,
               "_buildplatform_preset");
 
@@ -1119,6 +1148,15 @@ void rpmRebuildPlatformVars(char ** buildplatform, char **canonarch,
       b = malloc(strlen(co)+strlen(ca)+2);
       sprintf(b,"%s-%s",ca,co);
 
+/*
+ * XXX All this macro pokery/jiggery could be achieved (I think)
+ * by doing a delayed
+ *     initMacros(&globalMacroContext, PER-PLATFORM-MACRO-FILE-NAMES);
+ * (I haven't looked at the code :-)
+ *
+ * In fact, if you want to get really sophisticatedf, you could encapsulate
+ * within per-platform MacroContexts (but I'm not quite ready for that yet).
+ */
       delMacro(&globalMacroContext, "buildplatform");
 
     if (!presetbuildplatform) {
index c7d11ac..fc2f6fa 100644 (file)
@@ -1128,7 +1128,7 @@ initMacros(MacroContext *mc, const char *macrofile)
                                continue;
                        n++;
                        mb->mc = mc;    /* XXX just enough to get by */
-                       doDefine(mb, n, RMIL_MACROFILE, 0);
+                       doDefine(mb, n, RMIL_MACROFILES, 0);
                }
                fclose(fp);
        }
index 4f92426..6d3725b 100644 (file)
@@ -19,7 +19,7 @@ typedef struct MacroContext {
 /*
  * Markers for types of macros added throughout rpm.
  */
-#define        RMIL_MACROFILE  -9
+#define        RMIL_MACROFILES -9
 #define        RMIL_RPMRC      -7
 #define        RMIL_SPEC       -1
 #define        RMIL_OLDSPEC    -1