3 * $Id: sw_arch.h,v 1.1 1999/06/02 16:53:35 mdw Exp $
5 * Messing with architectures
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of sw-tools.
14 * sw-tools is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * sw-tools is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with sw-tools; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.1 1999/06/02 16:53:35 mdw
44 /*----- Header files ------------------------------------------------------*/
46 #include <mLib/dstr.h>
48 /*----- Data structures ---------------------------------------------------*/
50 /* --- @archcons@ --- *
52 * Links architectures into a list. It's done like this so that we can have
53 * multiple lists all referring to the same data.
56 typedef struct archcons {
61 /* --- @archent@ --- *
63 * Records information extracted from the `archtab' file, together with some
64 * other data used at run-time for the parallel build stuff.
67 typedef struct archent {
68 struct archcons cons; /* Cons for linking these together */
69 char *arch; /* The architecture name */
70 char *host; /* The architecture representative */
71 int status; /* Exit status from build process */
72 struct sw_remote *r; /* Remote command control block */
73 void *pres; /* Data for presentation handler */
74 unsigned flags; /* Various other flags */
80 archFlag_touched = 1, /* Unique flag: see @arch_filter@ */
81 archFlag_built = 2, /* This architecture is up-to-date */
82 archFlag_home = 4 /* This is the current arch */
85 /*----- Functions provided ------------------------------------------------*/
87 /* --- @arch_readtab@ --- *
91 * Returns: The address of the archtab list.
93 * Use: Reads the archtab file (if necessary) and returns a list of
97 extern archcons *arch_readtab(void);
99 /* --- @arch_lookup@ --- *
101 * Arguments: @const char *arch@ = pointer to archtecture name
102 * @int abbrev@ = whether abbreviations are OK
104 * Returns: Pointer to archtab block, or null.
106 * Use: Translates an architecture name into the name of a host
107 * supporting that architecture.
110 extern archent *arch_lookup(const char */*arch*/, int /*abbrev*/);
112 /* --- @arch_filter@ --- *
114 * Arguments: @archcons *a@ = input list to filter
115 * @const char *p@ = pointer to a textual list of architectures
116 * @unsigned and@, @unsigned xor@ = flags to look for
118 * Returns: A newly constructed architecture list containing only the
119 * listed architectures.
121 * Use: Filters the architecture list down to a few interesting
124 * If @p@ is non-null, it is a textual list of architecture
125 * names (possibly abbreviated), and separated by whitespace
126 * and/or commas: only the named architectures are included in
127 * the resulting list. If @p@ is null, all architectures are
130 * The list is further trimmed down by examining the flags words
131 * in each entry. Only entries with flags @f@ where @(f ^ xor)
132 * & and@ is zero are left in the resulting list. (To include
133 * all entries, clear @and@ to zero. To require a flag to be
134 * clear, set the corresponding bit in @and@. To require a flag
135 * to be set, set the corresponding bit in both @and@ and @xor@.
137 * (Don't try to filter on the @archFlag_touched@ flag. That
138 * flag is for the internal use of this routine.)
141 extern archcons *arch_filter(archcons */*a*/, const char */*p*/,
142 unsigned /*and*/, unsigned /*xor*/);
144 /* --- @arch_free@ --- *
146 * Arguments: @archcons *a@ = pointer to a list
150 * Use: Contrary to anything you might have expected from the Lispy
151 * naming, old architecture lists don't get garbage collected.
152 * This routine throws away an old list when you don't want it
153 * any more. Don't call this on the main list! It will fail
154 * miserably, because the cons cells in the main list are
158 extern void arch_free(archcons */*a*/);
160 /* --- @arch_toText@ --- *
162 * Arguments: @dstr *d@ = pointer to dynamic string to build result in
163 * @archcons *a@ = list to write into the string
164 * @unsigned and@, @unsigned xor@ = flags to look for
168 * Use: Writes a textual list of architectures to a string. This can
169 * then be used (for example) as the `only-arch' list in the
170 * info file, by filling it into a skeleton and calling
171 * @swinfo_update@. The @and@ and @xor@ arguments work in the
172 * same way as with @arch_filter@.
175 extern void arch_toText(dstr */*d*/, archcons */*a*/,
176 unsigned /*and*/, unsigned /*xor*/);
178 /* --- Subcommands --- */
180 extern int sw_arch(int /*argc*/, char */*argv*/[]);
181 extern int sw_listarch(int /*argc*/, char */*argv*/[]);
182 extern int sw_host(int /*argc*/, char */*argv*/[]);
183 extern int sw_only(int /*argc*/, char */*argv*/[]);
184 extern int sw_all(int /*argc*/, char */*argv*/[]);
187 static cmd cmd_only = {
188 CMD_LINK, "only-arch", sw_only,
189 "only-arch ARCH,...\n\
190 Restrict builds to a selection of architectures. (This option is\n\
191 persistent. An `--arch' command-line option takes precedence,\n\
194 static cmd cmd_all = {
195 &cmd_only, "all-arch", sw_all,
197 Clears the `only-arch' list. Subsequent builds occur across all\n\
200 static cmd cmd_host = {
201 &cmd_all, "host", sw_host,
203 Display the name of a host supporting architecture ARCH.\n"
205 static cmd cmd_listarch = {
206 &cmd_host, "listarch", sw_listarch,
208 Display a list of all architectures known.\n"
210 static cmd cmd_arch = {
211 &cmd_listarch, "arch", sw_arch,
212 "arch\tDisplay the architecture name of the current host.\n"
215 # define CMD_LINK &cmd_arch
218 /*----- That's all, folks -------------------------------------------------*/