summaryrefslogtreecommitdiff
path: root/usr.bin/pcc
diff options
context:
space:
mode:
authorTodd T. Fries <todd@cvs.openbsd.org>2007-09-19 15:21:08 +0000
committerTodd T. Fries <todd@cvs.openbsd.org>2007-09-19 15:21:08 +0000
commit0911f99e268a08e31d0bf8de3b8cd4f52b5232e9 (patch)
treeb3b36ea763898fa5f422c2a7e2baa97716be8e35 /usr.bin/pcc
parentc448585ec7be178206d55fdd19fc85c2b94f5ae7 (diff)
add '-b machine' to cc for multiarch support
ok otto@
Diffstat (limited to 'usr.bin/pcc')
-rw-r--r--usr.bin/pcc/cc/cc/Makefile4
-rw-r--r--usr.bin/pcc/cc/cc/cc.c35
-rw-r--r--usr.bin/pcc/cc/ccom/Makefile50
-rw-r--r--usr.bin/pcc/cc/ccom/Makefile.inc45
-rw-r--r--usr.bin/pcc/cc/ccom/vax/Makefile3
-rw-r--r--usr.bin/pcc/cc/ccom/x86/Makefile3
-rw-r--r--usr.bin/pcc/os/dragonfly/ccconfig.h13
-rw-r--r--usr.bin/pcc/os/linux/ccconfig.h13
-rw-r--r--usr.bin/pcc/os/netbsd/ccconfig.h11
-rw-r--r--usr.bin/pcc/os/none/ccconfig.h14
-rw-r--r--usr.bin/pcc/os/openbsd/ccconfig.h33
11 files changed, 141 insertions, 83 deletions
diff --git a/usr.bin/pcc/cc/cc/Makefile b/usr.bin/pcc/cc/cc/Makefile
index be17cf8fc85..5d708a88b80 100644
--- a/usr.bin/pcc/cc/cc/Makefile
+++ b/usr.bin/pcc/cc/cc/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.4 2007/09/17 07:20:49 todd Exp $
+# $OpenBSD: Makefile,v 1.5 2007/09/19 15:21:07 todd Exp $
#
# Makefile for the cc part of pcc.
#
@@ -11,6 +11,6 @@ TARGMACH= x86
CFLAGS+= -DLIBEXECDIR=\"${PREFIX}/libexec\"
CPPFLAGS+= -I${.CURDIR}/../.. -I${.CURDIR}/../../os/${TARGOS}
-CPPFLAGS+= -Dmach_${TARGMACH}
+CPPFLAGS+= -DDEFMACH=\"${TARGMACH}\"
.include <bsd.prog.mk>
diff --git a/usr.bin/pcc/cc/cc/cc.c b/usr.bin/pcc/cc/cc/cc.c
index 40ea4766d68..6abb82c7ad4 100644
--- a/usr.bin/pcc/cc/cc/cc.c
+++ b/usr.bin/pcc/cc/cc/cc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cc.c,v 1.7 2007/09/19 15:00:01 todd Exp $ */
+/* $OpenBSD: cc.c,v 1.8 2007/09/19 15:21:07 todd Exp $ */
/*
* Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
*
@@ -129,7 +129,13 @@ char *dynlinker[] = DYNLINKER;
char *crt0file = CRT0FILE;
char *startfiles[] = STARTFILES;
char *endfiles[] = ENDFILES;
-char *cppmdadd[] = CPPMDADD;
+char *mach = DEFMACH;
+struct cppmd {
+ char *mach;
+ char *cppmdadd[MAXCPPMDARGS];
+};
+
+struct cppmd cppmds[] = CPPMDADDS;
#ifdef LIBCLIBS
char *libclibs[] = LIBCLIBS;
#else
@@ -145,7 +151,7 @@ main(int argc, char *argv[])
char *t, *u;
char *assource;
char **pv, *ptemp[MAXOPT], **pvt;
- int nc, nl, i, j, c, nxo, na;
+ int nc, nl, i, j, k, c, nxo, na;
i = nc = nl = nxo = 0;
pv = ptemp;
@@ -159,6 +165,20 @@ main(int argc, char *argv[])
Bflag = &argv[i][2];
break;
+ case 'b':
+ if (strncmp(argv[i+1], "?", 1) == 0) {
+ /* show machine targets */
+ printf("Available machine targets:");
+ for (j=0; cppmds[j].mach; j++)
+ printf(" %s",cppmds[j].mach);
+ printf("\n");
+ exit(0);
+ }
+ for (j=0; cppmds[j].mach; j++)
+ if (strcmp(argv[i+1],cppmds[j].mach) == 0)
+ mach = cppmds[j].mach;
+ break;
+
case 'X':
Xflag++;
break;
@@ -377,8 +397,13 @@ main(int argc, char *argv[])
av[na++] = alist;
for (j = 0; cppadd[j]; j++)
av[na++] = cppadd[j];
- for (j = 0; cppmdadd[j]; j++)
- av[na++] = cppmdadd[j];
+ for (k = 0; cppmds[k].mach; k++) {
+ if (strcmp(cppmds[k].mach, mach) != 0)
+ continue;
+ for (j = 0; cppmds[k].cppmdadd[j]; j++)
+ av[na++] = cppmds[k].cppmdadd[j];
+ break;
+ }
if (tflag)
av[na++] = "-t";
for(pv=ptemp; pv <pvt; pv++)
diff --git a/usr.bin/pcc/cc/ccom/Makefile b/usr.bin/pcc/cc/ccom/Makefile
index 82da4e0c238..d5dd831b8ff 100644
--- a/usr.bin/pcc/cc/ccom/Makefile
+++ b/usr.bin/pcc/cc/ccom/Makefile
@@ -1,49 +1,9 @@
-# $OpenBSD: Makefile,v 1.8 2007/09/19 13:35:53 otto Exp $
+# $OpenBSD: Makefile,v 1.9 2007/09/19 15:21:07 todd Exp $
#
-# Makefile for the cpp part of pcc.
+# Makefile for the ccom part of pcc.
#
-PROG= ccom
-PREFIX= /usr/local
-BINDIR= ${PREFIX}/libexec
-MANDIR= ${PREFIX}/man/man
-TARGOS= openbsd
-.if ${MACHINE_ARCH} == "i386"
-TARGMACH= x86
-.else
-TARGMACH= ${MACHINE_ARCH}
-.endif
-CLEANFILES= external.h external.c mkext
-CFLAGS+= -DPCC_DEBUG -DGCC_COMPAT
-CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Werror
-CFLAGS+= -DLIBEXECDIR=\"${PREFIX}/libexec\"
-CPPFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/../../mip
-CPPFLAGS+= -I${.CURDIR}/../../arch/${TARGMACH}
-CPPFLAGS+= -I${.CURDIR}/../../os/${TARGOS}
-CPPFLAGS+= -Dmach_${TARGMACH}
+SUBDIR+= x86
+#SUBDIR+= vax
-.PATH: ${.CURDIR}/../../arch/${TARGMACH}
-.PATH: ${.CURDIR}/../../mip
-
-SRCS=optim.c pftn.c scan.l trees.c cgram.y inline.c symtabs.c \
- gcc_compat.c init.c local.c code.c stabs.c match.c reader.c optim2.c \
- regs.c local2.c order.c table.c common.c main.c external.c
-
-cgram.c: cgram.y
- $(YACC) $(YFLAGS) -d $<
- mv y.tab.c cgram.c
- mv y.tab.h cgram.h
-
-mkext: mkext.c table.c common.c
- $(CC) $(CPPFLAGS) $(CFLAGS) -DMKEXT -o mkext \
- ${.CURDIR}/../../mip/mkext.c \
- ${.CURDIR}/../../arch/${TARGMACH}/table.c \
- ${.CURDIR}/../../mip/common.c
-
-external.h external.c: mkext
- ./mkext
-
-cleandepend:
- rm -f .depend ${.CURDIR}/tags cgram.h
-
-.include <bsd.prog.mk>
+.include <bsd.subdir.mk>
diff --git a/usr.bin/pcc/cc/ccom/Makefile.inc b/usr.bin/pcc/cc/ccom/Makefile.inc
new file mode 100644
index 00000000000..6d329262345
--- /dev/null
+++ b/usr.bin/pcc/cc/ccom/Makefile.inc
@@ -0,0 +1,45 @@
+# $OpenBSD: Makefile.inc,v 1.1 2007/09/19 15:21:07 todd Exp $
+#
+# Makefile for the ccom part of pcc.
+#
+
+PROG= ccom_${TARGMACH}
+MAN= ccom.1
+
+PREFIX= /usr/local
+BINDIR= ${PREFIX}/libexec
+MANDIR= ${PREFIX}/man/man
+TARGOS= openbsd
+CLEANFILES= external.h external.c mkext
+
+CFLAGS+= -DPCC_DEBUG -DGCC_COMPAT
+CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Werror
+CFLAGS+= -DLIBEXECDIR=\"${PREFIX}/libexec\"
+CPPFLAGS+= -I. -I${.CURDIR}/.. -I${.CURDIR} -I${.CURDIR}/../../../mip
+CPPFLAGS+= -I${.CURDIR}/../../../arch/${TARGMACH}
+CPPFLAGS+= -I${.CURDIR}/../../../os/${TARGOS}
+
+.PATH: ${.CURDIR}/../../../arch/${TARGMACH}
+.PATH: ${.CURDIR}/../../../mip
+.PATH: ${.CURDIR}/..
+
+SRCS=optim.c pftn.c scan.l trees.c cgram.y inline.c symtabs.c \
+ gcc_compat.c init.c local.c code.c stabs.c match.c reader.c optim2.c \
+ regs.c local2.c order.c table.c common.c main.c external.c
+
+cgram.c: cgram.y
+ $(YACC) $(YFLAGS) -d $<
+ mv y.tab.c cgram.c
+ mv y.tab.h cgram.h
+
+mkext: mkext.c table.c common.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -DMKEXT -o mkext \
+ ${.CURDIR}/../../../mip/mkext.c \
+ ${.CURDIR}/../../../arch/${TARGMACH}/table.c \
+ ${.CURDIR}/../../../mip/common.c
+
+external.h external.c: mkext
+ ./mkext
+
+cleandepend:
+ rm -f .depend ${.CURDIR}/tags cgram.h
diff --git a/usr.bin/pcc/cc/ccom/vax/Makefile b/usr.bin/pcc/cc/ccom/vax/Makefile
new file mode 100644
index 00000000000..5b10f3f479d
--- /dev/null
+++ b/usr.bin/pcc/cc/ccom/vax/Makefile
@@ -0,0 +1,3 @@
+TARGMACH= vax
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/pcc/cc/ccom/x86/Makefile b/usr.bin/pcc/cc/ccom/x86/Makefile
new file mode 100644
index 00000000000..2049d325ec4
--- /dev/null
+++ b/usr.bin/pcc/cc/ccom/x86/Makefile
@@ -0,0 +1,3 @@
+TARGMACH= x86
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/pcc/os/dragonfly/ccconfig.h b/usr.bin/pcc/os/dragonfly/ccconfig.h
index 754825320c3..317a4f5e903 100644
--- a/usr.bin/pcc/os/dragonfly/ccconfig.h
+++ b/usr.bin/pcc/os/dragonfly/ccconfig.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccconfig.h,v 1.2 2007/09/15 22:04:39 ray Exp $ */
+/* $OpenBSD: ccconfig.h,v 1.3 2007/09/19 15:21:07 todd Exp $ */
/*
* Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
@@ -38,10 +38,11 @@
#define STARTFILES { "/usr/lib/crti.o", "/usr/lib/crtbegin.o", NULL }
#define ENDFILES { "/usr/lib/crtend.o", "/usr/lib/crtn.o", NULL }
-#if defined(mach_x86)
-#define CPPMDADD { "-D__i386__", NULL, }
-#else
-#error defines for arch missing
-#endif
+#define CPPMDADDS { \
+ { "x86", { "_D__i386__", NULL, } }, \
+ { NULL }, \
+}
+
+#define MAXCPPMDARGS 2
#define STABS
diff --git a/usr.bin/pcc/os/linux/ccconfig.h b/usr.bin/pcc/os/linux/ccconfig.h
index 73db9210a66..d055342da35 100644
--- a/usr.bin/pcc/os/linux/ccconfig.h
+++ b/usr.bin/pcc/os/linux/ccconfig.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccconfig.h,v 1.2 2007/09/15 22:04:39 ray Exp $ */
+/* $OpenBSD: ccconfig.h,v 1.3 2007/09/19 15:21:07 todd Exp $ */
/*
* Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
@@ -40,10 +40,11 @@
#define ENDFILES { "/usr/lib/gcc/i586-suse-linux/4.1.0/crtend.o", "/usr/lib/crtn.o", NULL }
#define STARTLABEL "_start"
-#if defined(mach_x86)
-#define CPPMDADD { "-D__i386__", NULL, }
-#else
-#error defines for arch missing
-#endif
+#define CPPMDADDS { \
+ { "x86", { "-D__i386__", NULL, } }, \
+ { NULL }, \
+}
+
+#define MAXCPPMDARGS 2
#define STABS
diff --git a/usr.bin/pcc/os/netbsd/ccconfig.h b/usr.bin/pcc/os/netbsd/ccconfig.h
index 63edddfc0ce..d60af1e31a0 100644
--- a/usr.bin/pcc/os/netbsd/ccconfig.h
+++ b/usr.bin/pcc/os/netbsd/ccconfig.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccconfig.h,v 1.2 2007/09/15 22:04:39 ray Exp $ */
+/* $OpenBSD: ccconfig.h,v 1.3 2007/09/19 15:21:07 todd Exp $ */
/*
* Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
@@ -38,10 +38,9 @@
#define STARTFILES { "/usr/lib/crti.o", "/usr/lib/crtbegin.o", NULL }
#define ENDFILES { "/usr/lib/crtend.o", "/usr/lib/crtn.o", NULL }
-#if defined(mach_x86)
-#define CPPMDADD { "-D__i386__", NULL, }
-#else
-#error defines for arch missing
-#endif
+#define CPPMDADDS { \
+ { "x86", { "-D__i386__", NULL, } }, \
+ { NULL }, \
+}
#define STABS
diff --git a/usr.bin/pcc/os/none/ccconfig.h b/usr.bin/pcc/os/none/ccconfig.h
index d6a88920982..8db552d5c03 100644
--- a/usr.bin/pcc/os/none/ccconfig.h
+++ b/usr.bin/pcc/os/none/ccconfig.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccconfig.h,v 1.2 2007/09/15 22:04:39 ray Exp $ */
+/* $OpenBSD: ccconfig.h,v 1.3 2007/09/19 15:21:07 todd Exp $ */
/*
* Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
@@ -42,9 +42,11 @@
#define STARTFILES { NULL }
#define ENDFILES { NULL }
-#if defined(mach_m16c)
-#define CPPMDADD { "-D__m16c__", NULL, }
-#elif defined(mach_nova)
-#define CPPMDADD { "-D__nova__", NULL, }
-#endif
+#define CPPMDADDS { \
+ { "m16c", { "-D__m16c__", NULL, } }, \
+ { "nova", { "-D__nova__", NULL, } }, \
+ { NULL },
+}
+
+#define MAXCPPMDARGS 2
diff --git a/usr.bin/pcc/os/openbsd/ccconfig.h b/usr.bin/pcc/os/openbsd/ccconfig.h
index 48b11f69b0a..cb45c11bfe5 100644
--- a/usr.bin/pcc/os/openbsd/ccconfig.h
+++ b/usr.bin/pcc/os/openbsd/ccconfig.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccconfig.h,v 1.2 2007/09/15 22:04:39 ray Exp $ */
+/* $OpenBSD: ccconfig.h,v 1.3 2007/09/19 15:21:07 todd Exp $ */
/*
* Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
@@ -32,16 +32,35 @@
*/
/* common cpp predefines */
-#define CPPADD { "-D__OpenBSD__", "-D__ELF__", NULL, }
+#define CPPADD { "-D__OpenBSD__", "-D__unix__", "-D__inline__=inline", NULL }
#define DYNLINKER { "-dynamic-linker", "/usr/libexec/ld.so", NULL }
#define CRT0FILE "/usr/lib/crt0.o"
#define STARTFILES { "/usr/lib/crtbegin.o", NULL }
#define ENDFILES { "/usr/lib/crtend.o", NULL }
-#if defined(mach_x86)
-#define CPPMDADD { "-D__i386__", NULL, }
-#else
-#error defines for arch missing
-#endif
+#define CPPMDADDS { \
+ { "x86", { "-D__i386__", "-D__i386", "-D__ELF__", \
+ NULL } }, \
+ { "alpha", { "-D__alpha", "-D__alpha_ev4__", "-D__alpha__", \
+ "-D__ELF__", NULL } }, \
+ { "amd64", { "-D__x86_64", "-D__athlon", "-D__amd64__", \
+ "-D__athlon__", "-D__ELF__", NULL } }, \
+ { "arm", { "-D__arm__", "-D__ELF__", NULL } }, \
+ { "hppa", { "-D__hppa", "-D__hppa__", "-D_PA_RISC_1", "-D__ELF__", \
+ NULL } }, \
+ { "m68k", { "-D__m68k__", "-D__mc68000__", "-D__mc68020__", \
+ NULL } }, \
+ { "powerpc", { "-D__powerpc__", "-D_ARCH_PPC", "-D__PPC", \
+ "-D__powerpc", "-D__PPC__", "-D__ELF__", NULL } }, \
+ { "mips64", { "-D__mips64", "-D__mips64__", "-D_R4000", "-D_mips", \
+ "-D_mips_r64", "-D__mips__", "-D__ELF__", NULL } }, \
+ { "sh", { "-D__SH4__", "-D__sh__", NULL } }, \
+ { "sparc", { "-D__sparc__", "-D__ELF__", NULL } }, \
+ { "sparc64", { "-D__sparc", "-D__sparc__", "-D__sparc64__", \
+ "-D__sparcv9__", "-D__sparc_v9__", "-D__ELF__", NULL } }, \
+ { "vax", { "-D__vax__", NULL } }, \
+ { NULL }, \
+}
+#define MAXCPPMDARGS 8
#define STABS