summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbencollins <tailor@grayson>2001-05-23 00:24:33 -0400
committerBen Collins <bcollins@ubuntu.com>2006-06-01 13:17:35 -0400
commit8886ec92a41a2f9ab10a847d79f64448a2668fe6 (patch)
tree4c7bef253981a26b1a1dce38a5a9310325194046
parent4e8c35262a55da474d246d0363e041eade17cc0d (diff)
downloadsilo-8886ec92a41a2f9ab10a847d79f64448a2668fe6.tar.gz
[silo @ 12]
* silo/Makefile: Rewrite logic for checking arch/OS. Make it cleaner. Remove need for seperate names of programs on Solaris. * silo/silo.c: Rename __solaris__ to __sun__ so cpp handles this for us. The Makefile will weed out unsupported builds. Also, include ufs.c on Solaris builds. * silo/silocheck.c: Likewise. * silo/util.c: Take array name on the command line, and add some error checking.#
-rw-r--r--ChangeLog11
-rw-r--r--silo/Makefile71
-rw-r--r--silo/prom.c4
-rw-r--r--silo/silo.c22
-rw-r--r--silo/silocheck.c16
-rw-r--r--silo/util.c16
6 files changed, 85 insertions, 55 deletions
diff --git a/ChangeLog b/ChangeLog
index f1e875b..609dcc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Tue May 22 20:16:48 EDT 2001 Ben Collins <bcollins@debian.org>
+
+ * silo/Makefile: Rewrite logic for checking arch/OS. Make it cleaner.
+ Remove need for seperate names of programs on Solaris.
+ * silo/silo.c: Rename __solaris__ to __sun__ so cpp handles this for
+ us. The Makefile will weed out unsupported builds. Also, include ufs.c
+ on Solaris builds.
+ * silo/silocheck.c: Likewise.
+ * silo/util.c: Take array name on the command line, and add some error
+ checking.
+
Tue May 22 12:14:55 EDT 2001 Ben Collins <bcollins@debian.org>
* Rules.make: New file. For now just includes the VERSION and
diff --git a/silo/Makefile b/silo/Makefile
index baf81d0..5d9741f 100644
--- a/silo/Makefile
+++ b/silo/Makefile
@@ -1,53 +1,54 @@
include ../Rules.make
+MESSAGE="SILO is now only supported on SPARC Linux and Solaris."
+PROGRAMS=
+UFSDEPS=
+
ifeq (Linux,$(shell uname))
-ifeq (sparc,$(subst sparc64,sparc,$(shell uname -m)))
-all: silo silocheck
-else
-all:
- @echo SILO install program now supported on Linux/SPARC and Solaris only
-endif
-else
-ifeq (SunOS,$(shell uname -s))
-ifeq (5.,$(findstring 5.,$(shell uname -r)))
-all: solarissilo solarissilocheck
+ ifeq (sparc,$(subst sparc64,sparc,$(shell uname -m)))
+ PROGRAMS=silo silocheck
+ MESSAGE="SILO build for SPARC/Linux completed."
+ endif
else
-all:
- @echo SunOS SILO not yet supported
-endif
-else
-all:
- @echo SILO install program now supported on Linux/SPARC and Solaris only
-endif
+ ifeq (SunOS,$(shell uname -s))
+ ifeq (5.,$(findstring 5.,$(shell uname -r)))
+ PROGRAMS=silo silocheck
+ MESSAGE="SILO build for SPARC/Solaris completed."
+ UFSDEPS=../second/ufs.c ufs.h
+ endif
+ endif
endif
-CFLAGS=-Wall -g -O2 -I../include
-CC=gcc
-
-silo: silo.c floppy.h headers confcheck.o prom.o
- $(CC) $(CFLAGS) -I/usr/src/linux/include -DVERSION='"$(VERSION)"' \
- -DIMGVERSION='"$(IMGVERSION)"' -o silo silo.c prom.o confcheck.o
+all: $(PROGRAMS)
+ @echo $(MESSAGE)
-silocheck: silocheck.c
- $(CC) $(CFLAGS) -I/usr/src/linux/include -o silocheck silocheck.c
+CFLAGS=-Wall -g -O2 -I../include -I/usr/src/linux/include -Werror
+LDFLAGS=
+CC=gcc
+HEADERS=../first/first.h ../first/ultra.h ../first/fd.h
+SILO_OBJS=confcheck.o prom.o silo.o
+SILOCHK_OBJS=silocheck.o
-solarissilo: silo.c floppy.h ufs.o prom.c confcheck.c headers
- $(CC) $(CFLAGS) -D__solaris__ -o solarissilo silo.c ufs.o prom.c confcheck.c
+silo: $(HEADERS) $(SILO_OBJS)
+ $(CC) $(LDFLAGS) -o $@ $(SILO_OBJS)
-solarissilocheck: silocheck.c ufs.c
- $(CC) $(CFLAGS) -D__solaris__ -o solarissilocheck silocheck.c ufs.c
+silocheck: $(SILOCHK_OBJS) $(UFSDEPS)
+ $(CC) $(LDFLAGS) -o $@ $(SILOCHK_OBJS)
floppy.h: floppy.label util
- ./util floppy.label | sed 's/cdrom/floppy/' > floppy.h
+ ./util floppy_label floppy.label > floppy.h
+
+ufs.h: ../second/ufs.h
+ ln -f ../second/ufs.h ufs.h
util: util.c
$(CC) $(CFLAGS) -o util util.c
-ufs.o: ../second/ufs.c ../second/ufs.h
- $(CC) $(CFLAGS) -D__solaris__ -c ../second/ufs.c
-
-headers:
+$(HEADERS):
$(MAKE) -C ../first first.h ultra.h fd.h
+silo.o: silo.c floppy.h $(UFSDEPS)
+ $(CC) $(CFLAGS) -DVERSION='"$(VERSION)"' -DIMGVERSION='"$(IMGVERSION)"' -c silo.c
+
clean:
- rm -f $(INSTBOOT) $(TDEV) *.o *~ silo solarissilo sunossilo floppy.h util silocheck solarissilocheck ufs.[ch]
+ rm -f *.o *~ silo floppy.h ufs.h util silocheck
diff --git a/silo/prom.c b/silo/prom.c
index 5405bda..cad4459 100644
--- a/silo/prom.c
+++ b/silo/prom.c
@@ -22,7 +22,7 @@
#include <sys/ioctl.h>
#ifdef __linux__
# include <asm/openpromio.h>
-#elif defined (__solaris__)
+#elif defined (__sun__)
# include <sys/types.h>
# include <sys/stat.h>
# include <sys/openpromio.h>
@@ -150,7 +150,7 @@ char *prom_getopt (char *name)
return 0;
}
-#ifdef __solaris__
+#ifdef __sun__
int prom_getversion()
{
int i;
diff --git a/silo/silo.c b/silo/silo.c
index 7d3a5f7..63910b2 100644
--- a/silo/silo.c
+++ b/silo/silo.c
@@ -26,6 +26,10 @@
#define DFL_PRIMARY_U "/boot/ultra.b"
#define DFL_SECONDARY "/boot/second.b"
+#ifdef __sun__
+#include "../second/ufs.c"
+#endif
+
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
@@ -59,12 +63,12 @@
# define mmakedev(major, minor) (((major) << 8) | (minor))
# endif
# include <md-int.h>
-#elif defined (__solaris__)
+#elif defined (__sun__)
# include <sys/types.h>
# include <sys/stat.h>
# include <non-linux/ext2_fs.h>
# include <ext2fs/ext2fs.h>
-# include "../second/ufs.h"
+# include "ufs.h"
# include <limits.h>
struct hwdevice;
static int ufs_blocks (struct hwdevice *, ino_t);
@@ -439,7 +443,7 @@ again:
}
gpb_cleanup(filename, movecount - 1);
}
-#elif defined(__solaris__)
+#elif defined(__sun__)
ufs_blocks (hwdev, st.st_ino);
#endif
close (fd);
@@ -788,7 +792,7 @@ int get_prom_ver(int use_prom)
}
}
return ver;
-#elif defined(__solaris__)
+#elif defined(__sun__)
int ver = -1;
if (use_prom)
@@ -1021,7 +1025,7 @@ struct hwdevice *get_device(int majno, int minno)
if (!p) fatal ("Couldn't find out what device is second stage on");
strcpy (dev, p);
strcpy (wholedev, p);
-#ifdef __solaris__
+#ifdef __sun__
if (strlen (p) == strlen ("/dev/dsk/c0t0d0s0")) {
p = strchr (p, 0) - 2;
if (*p == 's' && p[1] >= '0' && p[1] <= '7') {
@@ -1062,7 +1066,7 @@ int main(int argc,char **argv)
int use_prom = 0;
int print_prom_version = 0;
-#ifdef __solaris__
+#ifdef __sun__
if (prom_init () >= 0)
use_prom = 1;
#endif
@@ -1260,7 +1264,7 @@ int main(int argc,char **argv)
#ifdef __linux__
else if ((hwdevs->type == TYPE_SCSI && (mmajor(st2.st_dev) != mmajor(st1.st_dev) || (mminor(st2.st_dev) & (~0xf)) != (mminor(st1.st_dev) & (~0xf)))) ||
(hwdevs->type == TYPE_IDE && (mmajor(st2.st_dev) != mmajor(st1.st_dev) || (mminor(st2.st_dev) & (~0x3f)) != (mminor(st1.st_dev) & (~0x3f)))))
-#elif defined(__solaris__)
+#elif defined(__sun__)
else if (hwdevs->type == TYPE_SCSI && (st2.st_dev & (~0x7)) != (st1.st_dev & (~0x7)))
#else
# error "Unknown system"
@@ -1326,7 +1330,7 @@ int main(int argc,char **argv)
else if (hwdevs->type == TYPE_SCSI)
#ifdef __linux__
config_file_partno = (mminor(st2.st_dev) & 0x0f);
-#elif defined(__solaris__)
+#elif defined(__sun__)
config_file_partno = (st2.st_dev & 7) + 1;
#else
# error "Unknown system"
@@ -1372,7 +1376,7 @@ int main(int argc,char **argv)
exit(0);
}
-#ifdef __solaris__
+#ifdef __sun__
static errcode_t std_open (const char *name, int flags, io_channel * channel);
static errcode_t std_close (io_channel channel);
diff --git a/silo/silocheck.c b/silo/silocheck.c
index a4817d7..6bbd67e 100644
--- a/silo/silocheck.c
+++ b/silo/silocheck.c
@@ -17,6 +17,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#ifdef __sun__
+#include "../second/ufs.c"
+#endif
+
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
@@ -44,12 +48,12 @@
# define mminor(x) (int)((x) & 0xff)
# define mmakedev(major, minor) (((major) << 8) | (minor))
# endif
-#elif defined (__solaris__)
+#elif defined (__sun__)
# include <sys/types.h>
# include <sys/stat.h>
# include <non-linux/ext2_fs.h>
# include <ext2fs/ext2fs.h>
-# include "../second/ufs.h"
+# include "ufs.h"
# include <limits.h>
# include <sys/byteorder.h>
# ifdef _BIG_ENDIAN
@@ -179,7 +183,7 @@ void read_sb (char *device, char *bootdev)
doff = 0;
#ifdef __linux__
partno = (int) (*(device + strlen (device) - 1) - '0') - 1;
-#elif defined(__solaris__)
+#elif defined(__sun__)
partno = (int) (*(device + strlen (device) - 1) - '0');
#endif
sdl = (struct sun_disklabel *) &buff;
@@ -221,7 +225,7 @@ int get_partition_blocks (char *device, char *filename)
}
blocks[j] = 0;
nblocks = j;
-#elif defined(__solaris__)
+#elif defined(__sun__)
ufs_blocks (device, st.st_ino);
#endif
close (fd);
@@ -305,7 +309,7 @@ int main(int argc,char **argv)
if (!p) fatal ("Couldn't find out what device is %s on", filename);
strcpy (bootdev, p);
strcpy (bootdev2, p);
-#ifdef __solaris__
+#ifdef __sun__
if (strlen (p) == strlen ("/dev/dsk/c0t0d0s0")) {
p = strchr (p, 0) - 2;
if (*p == 's' && p[1] >= '0' && p[1] <= '7') {
@@ -348,7 +352,7 @@ int main(int argc,char **argv)
exit(0);
}
-#ifdef __solaris__
+#ifdef __sun__
static errcode_t std_open (const char *name, int flags, io_channel * channel);
static errcode_t std_close (io_channel channel);
diff --git a/silo/util.c b/silo/util.c
index 6f7e438..4240da2 100644
--- a/silo/util.c
+++ b/silo/util.c
@@ -20,13 +20,23 @@
int main (int argc, char **argv)
{
- FILE *f = fopen (argv[1], "r");
+ FILE *f;
char buffer[512];
int i, j;
- fread (buffer, 1, 512, f);
+ if (argc != 3) {
+ fprintf(stderr, "Usage: %s <array name> <file>\n", argv[0]);
+ exit (1);
+ }
+
+ if ((f = fopen(argv[2], "r")) == NULL) {
+ perror("fopen");
+ exit (1);
+ }
+
+ fread (buffer, 1, sizeof(buffer), f);
fclose (f);
- printf ("char cdrom_label[] = {\n");
+ printf ("char %s[] = {\n", argv[1]);
for (i = 0; i < 32; i++) {
for (j = 0; j < 16; j++)
printf ("0x%02X, ", (unsigned char)buffer[16 * i + j]);