3 * $Id: sw_arch.h,v 1.2 2004/04/08 01:52:19 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.
36 /*----- Header files ------------------------------------------------------*/
38 #include <mLib/dstr.h>
40 /*----- Data structures ---------------------------------------------------*/
42 /* --- @archcons@ --- *
44 * Links architectures into a list. It's done like this so that we can have
45 * multiple lists all referring to the same data.
48 typedef struct archcons
{
53 /* --- @archent@ --- *
55 * Records information extracted from the `archtab' file, together with some
56 * other data used at run-time for the parallel build stuff.
59 typedef struct archent
{
60 struct archcons cons
; /* Cons for linking these together */
61 char *arch
; /* The architecture name */
62 char *host
; /* The architecture representative */
63 int status
; /* Exit status from build process */
64 struct sw_remote
*r
; /* Remote command control block */
65 void *pres
; /* Data for presentation handler */
66 unsigned flags
; /* Various other flags */
72 archFlag_touched
= 1, /* Unique flag: see @arch_filter@ */
73 archFlag_built
= 2, /* This architecture is up-to-date */
74 archFlag_home
= 4 /* This is the current arch */
77 /*----- Functions provided ------------------------------------------------*/
79 /* --- @arch_readtab@ --- *
83 * Returns: The address of the archtab list.
85 * Use: Reads the archtab file (if necessary) and returns a list of
89 extern archcons
*arch_readtab(void);
91 /* --- @arch_lookup@ --- *
93 * Arguments: @const char *arch@ = pointer to archtecture name
94 * @int abbrev@ = whether abbreviations are OK
96 * Returns: Pointer to archtab block, or null.
98 * Use: Translates an architecture name into the name of a host
99 * supporting that architecture.
102 extern archent
*arch_lookup(const char */
*arch*/
, int /*abbrev*/);
104 /* --- @arch_filter@ --- *
106 * Arguments: @archcons *a@ = input list to filter
107 * @const char *p@ = pointer to a textual list of architectures
108 * @unsigned and@, @unsigned xor@ = flags to look for
110 * Returns: A newly constructed architecture list containing only the
111 * listed architectures.
113 * Use: Filters the architecture list down to a few interesting
116 * If @p@ is non-null, it is a textual list of architecture
117 * names (possibly abbreviated), and separated by whitespace
118 * and/or commas: only the named architectures are included in
119 * the resulting list. If @p@ is null, all architectures are
122 * The list is further trimmed down by examining the flags words
123 * in each entry. Only entries with flags @f@ where @(f ^ xor)
124 * & and@ is zero are left in the resulting list. (To include
125 * all entries, clear @and@ to zero. To require a flag to be
126 * clear, set the corresponding bit in @and@. To require a flag
127 * to be set, set the corresponding bit in both @and@ and @xor@.
129 * (Don't try to filter on the @archFlag_touched@ flag. That
130 * flag is for the internal use of this routine.)
133 extern archcons
*arch_filter(archcons */
*a*/
, const char */
*p*/
,
134 unsigned /*and*/, unsigned /*xor*/);
136 /* --- @arch_free@ --- *
138 * Arguments: @archcons *a@ = pointer to a list
142 * Use: Contrary to anything you might have expected from the Lispy
143 * naming, old architecture lists don't get garbage collected.
144 * This routine throws away an old list when you don't want it
145 * any more. Don't call this on the main list! It will fail
146 * miserably, because the cons cells in the main list are
150 extern void arch_free(archcons */
*a*/
);
152 /* --- @arch_toText@ --- *
154 * Arguments: @dstr *d@ = pointer to dynamic string to build result in
155 * @archcons *a@ = list to write into the string
156 * @unsigned and@, @unsigned xor@ = flags to look for
160 * Use: Writes a textual list of architectures to a string. This can
161 * then be used (for example) as the `only-arch' list in the
162 * info file, by filling it into a skeleton and calling
163 * @swinfo_update@. The @and@ and @xor@ arguments work in the
164 * same way as with @arch_filter@.
167 extern void arch_toText(dstr */
*d*/
, archcons */
*a*/
,
168 unsigned /*and*/, unsigned /*xor*/);
170 /* --- Subcommands --- */
172 extern int sw_arch(int /*argc*/, char */
*argv*/
[]);
173 extern int sw_listarch(int /*argc*/, char */
*argv*/
[]);
174 extern int sw_host(int /*argc*/, char */
*argv*/
[]);
175 extern int sw_only(int /*argc*/, char */
*argv*/
[]);
176 extern int sw_all(int /*argc*/, char */
*argv*/
[]);
179 static cmd cmd_only
= {
180 CMD_LINK
, "only-arch", sw_only
,
181 "only-arch ARCH,...\n\
182 Restrict builds to a selection of architectures. (This option is\n\
183 persistent. An `--arch' command-line option takes precedence,\n\
186 static cmd cmd_all
= {
187 &cmd_only
, "all-arch", sw_all
,
189 Clears the `only-arch' list. Subsequent builds occur across all\n\
192 static cmd cmd_host
= {
193 &cmd_all
, "host", sw_host
,
195 Display the name of a host supporting architecture ARCH.\n"
197 static cmd cmd_listarch
= {
198 &cmd_host
, "listarch", sw_listarch
,
200 Display a list of all architectures known.\n"
202 static cmd cmd_arch
= {
203 &cmd_listarch
, "arch", sw_arch
,
204 "arch\tDisplay the architecture name of the current host.\n"
207 # define CMD_LINK &cmd_arch
210 /*----- That's all, folks -------------------------------------------------*/