summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-01-11 11:42:17 +0000
committerEric Andersen <andersen@codepoet.org>2001-01-11 11:42:17 +0000
commitae97a89e1a1a9833080dccc81f6cd26784e1b964 (patch)
tree6ff1ddc7e3980591c7fd0bbd5d9b8ac82da12886 /extra
parentabdc3e4d06db2b9d93c509774fc7c4fde918ec8e (diff)
A large update from Manuel Novoa III <mnovoa3@bellsouth.net>.
Diffstat (limited to 'extra')
-rw-r--r--extra/Makefile48
-rw-r--r--extra/gcc-uClibc/Makefile40
-rw-r--r--extra/gcc-uClibc/gcc-uClibc.c129
3 files changed, 217 insertions, 0 deletions
diff --git a/extra/Makefile b/extra/Makefile
new file mode 100644
index 000000000..fa4b50b44
--- /dev/null
+++ b/extra/Makefile
@@ -0,0 +1,48 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000 by Lineo, inc.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Derived in part from the Linux-8086 C library, the GNU C Library, and several
+# other sundry sources. Files within this library are copyright by their
+# respective copyright holders.
+
+TOPDIR=../
+include $(TOPDIR)Rules.mak
+LIBC=$(TOPDIR)libc.a
+
+
+DIRS = gcc-uClibc
+
+all: subdirs
+
+tags:
+ ctags -R
+
+clean: subdirs_clean
+ rm -f *.[oa] *~ core
+
+subdirs: $(patsubst %, _dir_%, $(DIRS))
+subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS))
+
+$(patsubst %, _dir_%, $(DIRS)) : dummy
+ $(MAKE) -C $(patsubst _dir_%, %, $@)
+
+$(patsubst %, _dirclean_%, $(DIRS)) : dummy
+ $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
+
+.PHONY: dummy
+
diff --git a/extra/gcc-uClibc/Makefile b/extra/gcc-uClibc/Makefile
new file mode 100644
index 000000000..af9f836a1
--- /dev/null
+++ b/extra/gcc-uClibc/Makefile
@@ -0,0 +1,40 @@
+
+TOPDIR = ../../
+include $(TOPDIR)Rules.mak
+
+UCLIBC_DIR = $(shell (cd ../.. ; /bin/pwd))
+GCC_BIN = $(CC)
+GCC_LIB = $(shell $(CC) -print-libgcc-file-name )
+#GCCINCDIR inherited from Rules.mak
+
+NATIVE_ARCH = $(shell uname -m | sed -e 's/i.86/i386/' -e 's/sparc.*/sparc/' -e 's/arm.*/arm/g')
+GCC_UCLIBC = gcc-uClibc-cross
+ifeq ($(TARGET_ARCH), $(NATIVE_ARCH))
+ GCC_UCLIBC = gcc-uClibc-native
+endif
+
+all: $(GCC_UCLIBC)
+
+clean:
+ rm -f gcc-uClibc.h gcc-uClibc-*
+
+gcc-uClibc.h: clean
+ echo "/* this file is created by make */" > gcc-uClibc.h
+ echo "#define UCLIBC_DIR " \"$(UCLIBC_DIR)/\" >> gcc-uClibc.h
+ echo "#define GCC_BIN " \"$(GCC_BIN)\" >> gcc-uClibc.h
+ echo "#define GCC_LIB " \"$(GCC_LIB)\" >> gcc-uClibc.h
+ echo "#define GCC_INCDIR " \"-I$(GCCINCDIR)/\" >> gcc-uClibc.h
+ echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> gcc-uClibc.h
+
+gcc-uClibc-native: gcc-uClibc.h gcc-uClibc.c
+ # uClibc built for native environment, so why not use it ;-)
+ $(CC) $(CFLAGS) -nostdinc -I$(UCLIBC_DIR)/include -I$(GCC_INC) \
+ -Wl,-static gcc-uClibc.c \
+ $(UCLIBC_DIR)/sysdeps/linux/$(TARGET_ARCH)/_start.o \
+ -nostdlib $(GCC_LIB) $(UCLIBC_DIR)/libc.a \
+ -s -o gcc-uClibc-$(TARGET_ARCH) #-DDEBUG
+
+gcc-uClibc-cross: gcc-uClibc.h gcc-uClibc.c
+ # don't use CFLAGS since may not be appropriate
+ gcc -s gcc-uClibc.c -o gcc-uClibc-$(TARGET_ARCH)
+
diff --git a/extra/gcc-uClibc/gcc-uClibc.c b/extra/gcc-uClibc/gcc-uClibc.c
new file mode 100644
index 000000000..f783cd7bd
--- /dev/null
+++ b/extra/gcc-uClibc/gcc-uClibc.c
@@ -0,0 +1,129 @@
+
+/*
+ * Copyright (C) 2000 Manuel Novoa III
+ *
+ * This is a crude wrapper to use uClibc with gcc.
+ * It was originally written to work around ./configure for ext2fs-utils.
+ * It certainly can be improved, but it works for me in the normal cases.
+ *
+ * TODO:
+ * Check/modify gcc-specific environment variables?
+ */
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "gcc-uClibc.h"
+
+#define UCLIBC_START UCLIBC_DIR"sysdeps/linux/"TARGET_ARCH"/_start.o"
+#define UCLIBC_START_G UCLIBC_START
+#define UCLIBC_LIB UCLIBC_DIR"libc.a"
+#if 1
+#define UCLIBC_LIB_G UCLIBC_LIB
+#else
+#define UCLIBC_LIB_G UCLIBC_DIR"libc.a-debug"
+#endif
+#define UCLIBC_INC "-I"UCLIBC_DIR"include/"
+
+static char nostdinc[] = "-nostdinc";
+static char nostartfiles[] = "-nostartfiles";
+static char nodefaultlibs[] = "-nodefaultlibs";
+static char nostdlib[] = "-nostdlib";
+
+int main(int argc, char **argv)
+{
+ int debugging = 0, linking = 1;
+ int use_stdinc = 1, use_start = 1, use_stdlib = 1;
+ int i, j;
+ int source_count;
+ char ** gcc_argv;
+
+ source_count = 0;
+
+ for ( i = 1 ; i < argc ; i++ ) {
+ if (argv[i][0] == '-') { /* option */
+ switch (argv[i][1]) {
+ case 'c':
+ case 'S':
+ case 'E':
+ case 'r':
+ if (argv[i][2] == 0) linking = 0;
+ break;
+ case 'g':
+ if (argv[i][2] == 0) debugging = 1;
+ break;
+ case 'n':
+ if (strcmp(nostdinc,argv[i]) == 0) {
+ use_stdinc = 0;
+ } else if (strcmp(nostartfiles,argv[i]) == 0) {
+ use_start = 0;
+ } else if (strcmp(nodefaultlibs,argv[i]) == 0) {
+ use_stdlib = 0;
+ } else if (strcmp(nostdlib,argv[i]) == 0) {
+ use_start = 0;
+ use_stdlib = 0;
+ }
+
+ }
+ } else { /* assume it is an existing source file */
+ ++source_count;
+ }
+ }
+
+#if 1
+ gcc_argv = __builtin_alloca(sizeof(char*) * (argc + 20));
+#else
+ if (!(gcc_argv = malloc(sizeof(char) * (argc + 20)))) {
+ return EXIT_FAILURE;
+ }
+#endif
+
+ i = 0;
+ gcc_argv[i++] = GCC_BIN;
+ for ( j = 1 ; j < argc ; j++ ) {
+ gcc_argv[i++] = argv[j];
+ }
+ if (use_stdinc) {
+ gcc_argv[i++] = nostdinc;
+ gcc_argv[i++] = UCLIBC_INC;
+ gcc_argv[i++] = GCC_INCDIR;
+ }
+ if (linking && source_count) {
+ gcc_argv[i++] = "-static";
+ if (use_start) {
+ if (debugging) {
+ gcc_argv[i++] = UCLIBC_START_G;
+ } else {
+ gcc_argv[i++] = UCLIBC_START;
+ }
+ }
+ if (use_stdlib) {
+ gcc_argv[i++] = "-nostdlib";
+ if (debugging) {
+ gcc_argv[i++] = UCLIBC_LIB_G;
+ } else {
+ gcc_argv[i++] = UCLIBC_LIB;
+ }
+ gcc_argv[i++] = GCC_LIB;
+ }
+ }
+ gcc_argv[i++] = NULL;
+
+#ifdef DEBUG
+ for ( j = 0 ; gcc_argv[j] ; j++ ) {
+ printf("arg[%2i] = %s\n", j, gcc_argv[j]);
+ }
+ return EXIT_SUCCESS;
+#else
+ return execvp(GCC_BIN, gcc_argv);
+#endif
+}
+
+
+
+