Build system overhauled to use Kbuild (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 31 May 2013 03:51:43 +0000 (20:51 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 31 May 2013 03:57:52 +0000 (20:57 -0700)
The kernel uses Kbuild, and the old userspace targets were reworked to
fit with the new system.  They are still fairly similar to their old
selves.

Users will need to set up an ARCH and config before doing anything,
including building the cross compiler.  Do something like this:

$ make ARCH=i686 config

I cleaned out a bit of old cruft (and some bugs) in the userspace
targets, though a lot of it can do with a rewrite.

Being a fairly substantial change, you're encouraged to rebuild
everything, including the cross-compiler, to make sure there aren't any
issues.

36 files changed:
.gitignore
GETTING_STARTED
GNUmakefile [deleted file]
Kconfig [new file with mode: 0644]
Makefile [new file with mode: 0644]
Makefile-KB [deleted file]
Makelocal.template
kern/Makefrag [deleted file]
kern/arch/i686/Kbuild [new file with mode: 0644]
kern/arch/i686/Makefrag [deleted file]
kern/arch/i686/boot/boot [deleted symlink]
kern/arch/riscv/Kbuild [new file with mode: 0644]
kern/arch/riscv/Makefrag [deleted file]
kern/arch/sparc/Kbuild [new file with mode: 0644]
kern/arch/sparc/Makefrag [deleted file]
kern/src/Kbuild [new file with mode: 0644]
kern/src/Makefrag [deleted file]
kern/src/net/Kbuild [new file with mode: 0644]
scripts/Makefile.build
scripts/Makefile.clean
scripts/Makefile.lib
scripts/basic/.gitignore [new file with mode: 0644]
scripts/kconfig/Makefile
scripts/mergedep.pl [deleted file]
tests/Makefile [new file with mode: 0644]
tests/Makefrag [deleted file]
tests/c3po/Makefrag
tests/openmp/Makefrag
tools/compilers/gcc-glibc/Makefile
user/benchutil/Makefile
user/c3po/Makefile
user/c3po/stack/Makefrag
user/c3po/threads/Makefrag
user/c3po/util/Makefrag
user/parlib/Makefile
user/pthread/Makefile

index 632f1da..5313847 100644 (file)
@@ -40,3 +40,6 @@ tools/syscall_server/sandbox/
 tools/syscall_server/apps/*
 tools/syscall_server/test/*
 kern/kfs/*
+*.o
+.*.cmd
+.config*
index e8d41cf..f697f46 100644 (file)
@@ -1,7 +1,7 @@
 GETTING_STARTED
 Barret Rhoden
 
-Last updated 2013-02-07
+Last thorough update: 2013-02-07
 
 
 1. Overview
@@ -30,10 +30,14 @@ usually idling in there (alone), and if I'm at my computer, I'll respond.
 ---------------------
 I'll describe how to get x86 working.  RISCV is similar.
 
+The first step is to configure the kernel.  config, menuconfig, and some of the
+other KBuild targets work.  For example, to config for 32 bit x86:
+
+$ make ARCH=i686 config
 
 3.1 Cross compiler (and glibc)
 ----------
-First step is to build the cross compiler, which lives in
+The second step is to build the cross compiler, which lives in
 tools/compilers/gcc-glibc
 
 $ cd tools/compilers/gcc-glibc
diff --git a/GNUmakefile b/GNUmakefile
deleted file mode 100644 (file)
index 7e8dbcf..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-# The ROS Top level Makefile
-# Make sure that 'all' is the first target
-
-# Keep make quiet.  Make sure you call make via $(MAKE), and not directly
-MAKE += -s 
-
-############################################################################# 
-########## Initial Setup so that we can build for different TARGETS #########
-############################################################################# 
-
-ARCH_LINK := $(shell readlink kern/include/arch)
-ifneq ($(ARCH_LINK),)
-       ARCH_LINK := $(shell basename $(ARCH_LINK))
-       TARGET_ARCH ?= $(ARCH_LINK)
-endif
-ifeq ($(TARGET_ARCH),)
-busted:
-       @echo "You must initially specify your target in the form TARGET_ARCH=<target>"
-       @echo "Current valid values for TARGET_ARCH are 'i686', 'sparc', and 'riscv'."
-       @echo "Subsequent calls for the same target can be made by simply invoking 'make'"
-endif
-
-real-$(TARGET_ARCH):
-       @if [ "$(ARCH_LINK)" != "$(TARGET_ARCH)" ];\
-       then\
-         $(MAKE) realclean;\
-         $(MAKE) realall -j $(MAKE_JOBS);\
-       else\
-         $(MAKE) all -j $(MAKE_JOBS);\
-       fi
-
-# So all recursive calls to make know what the target arch is
-MAKE += TARGET_ARCH=$(TARGET_ARCH)
-
-############################################################################# 
-########## Beginning of the guts of the real Makefile #######################
-############################################################################# 
-
-# Default values for configurable Make system variables
-COMPILER := GCC
-OBJDIR := obj
-V ?= @
-
-# Make sure that 'all' is the first target when not erroring out
-realall: symlinks
-
-# Number of make jobs to spawn.  Define it in Makelocal
-MAKE_JOBS :=
-
-# Give it a reasonable default path for initramfs to avoid build breakage
-INITRAMFS_PATHS = kern/kfs
-FIRST_INITRAMFS_PATH = $(firstword $(INITRAMFS_PATHS))
-
-# Then grab the users Makelocal file to let them override Make system variables
-# and set up other Make targets
-include Makeconfig
--include Makelocal
-
-TOP_DIR := $(shell pwd)
-ARCH_DIR := $(TOP_DIR)/kern/arch
-INCLUDE_DIR := $(TOP_DIR)/kern/include
-DOXYGEN_DIR := $(TOP_DIR)/Documentation/doxygen
-
-UNAME=$(shell uname -m)
-
-# Cross-compiler ros toolchain
-#
-# This Makefile will automatically use the cross-compiler toolchain
-# installed as '$(TARGET_ARCH)-ros-*', if one exists.  If the host tools ('gcc',
-# 'objdump', and so forth) compile for a 32-bit ELF target, that will
-# be detected as well.  If you have the right compiler toolchain installed
-# using a different name, set GCCPREFIX explicitly in your Makelocal file
-
-# Try to infer the correct GCCPREFIX
-ifneq ($(TARGET_ARCH),)
-ifndef GCCPREFIX
-TEST_PREFIX := $(TARGET_ARCH)-ros-
-else
-TEST_PREFIX := $(GCCPREFIX)
-endif
-GCC_EXISTS = $(shell which $(TEST_PREFIX)gcc)
-ifneq ($(GCC_EXISTS),)
-       GCCPREFIX := $(TEST_PREFIX)
-else
-       ERROR := "*** Error: Couldn't find $(TEST_PREFIX) version of GCC/binutils." 
-endif
-ifdef ERROR
-error: 
-       @echo $(ERROR)
-       @exit 1
-else
-error:
-endif
-endif
-
-# Default programs for compilation
-USER_CFLAGS += -O2 -std=gnu99
-USER_CXXFLAGS += -O2
-ifeq ($(COMPILER),IVY)
-KERN_CFLAGS += --deputy \
-               --no-rc-sharc \
-               --sc-dynamic-is-error \
-               --sc-ops=$(INCLUDE_DIR)/ivy/sharc.h \
-               --sc-all-in-thread \
-               --enable-precompile \
-#               --enable-error-db \
-
-USER_CFLAGS += --deputy --enable-error-db
-CC         := ivycc --gcc=$(GCCPREFIX)gcc
-else
-CC         := $(GCCPREFIX)gcc 
-endif
-
-CPP        := $(GCCPREFIX)g++
-AS         := $(GCCPREFIX)as
-AR         := $(GCCPREFIX)ar
-LD         := $(GCCPREFIX)ld
-OBJCOPY        := $(GCCPREFIX)objcopy
-OBJDUMP        := $(GCCPREFIX)objdump
-NM         := $(GCCPREFIX)nm
-STRIP   := $(GCCPREFIX)strip
-PERL    := perl
-
-EXTRAARGS ?= -std=gnu99 -Wno-attributes -fno-stack-protector -fgnu89-inline
-
-# GCC Library path
-ifneq ($(GCC_EXISTS),)
-GCC_LIB := $(shell $(CC) -print-libgcc-file-name)
-endif
-
-# Universal compiler flags
-# -fno-builtin is required to avoid refs to undefined functions in the kernel.
-# Only optimize to -O1 to discourage inlining, which complicates backtraces.
-KERN_CFLAGS += -D$(TARGET_ARCH) $(EXTRAARGS)
-KERN_CFLAGS += -O2 -pipe -MD -fno-builtin -gstabs -static
-KERN_CFLAGS += -Wall -Wno-format -Wno-unused -fno-strict-aliasing
-KERN_CFLAGS += -nostdinc -I$(dir $(GCC_LIB))/include
-# Our backtraces need the frame pointer
-KERN_CFLAGS += -fno-omit-frame-pointer
-
-# Universal loader flags
-LDFLAGS := -nostdlib
-
-# List of directories that the */Makefrag makefile fragments will add to
-OBJDIRS :=
-
-ROS_ARCH_DIR ?= $(TARGET_ARCH)
-
-arch:
-       @echo "TARGET_ARCH=$(TARGET_ARCH)"
-
-symlinks: error
-       ln -fs ../arch/$(ROS_ARCH_DIR) kern/include/arch
-       ln -fs arch/$(ROS_ARCH_DIR)/boot kern/boot
-       ln -fs $(ROS_ARCH_DIR) user/parlib/include/arch
-       @$(MAKE) -j $(MAKE_JOBS) all
-
-# Include Makefrags for subdirectories
-ifneq ($(TARGET_ARCH),)
-include tests/Makefrag
-include kern/Makefrag
-endif
-
-ifeq ($(GCCPREFIX),$(TARGET_ARCH)-ros-)
-GCC_ROOT := $(shell which $(GCCPREFIX)gcc | xargs dirname)/../
-tests/: tests
-tests: install-libs
-       @$(MAKE) -j $(MAKE_JOBS) realtests
-
-realtests: $(TESTS_EXECS_C) $(TESTS_EXECS_CPP)
-# No longer automatically copying to the FS dir (deprecated)
-#      @mkdir -p fs/$(TARGET_ARCH)/tests
-#      cp -R $(OBJDIR)/$(TESTS_DIR)/* $(TOP_DIR)/fs/$(TARGET_ARCH)/tests
-
-USER_LIBS = parlib pthread benchutil
-# for now, c3po can't be built for non-i686
-ifeq ($(TARGET_ARCH),i686)
-USER_LIBS += c3po
-endif
-install-libs: 
-       @for i in $(USER_LIBS) ; do     \
-               cd user/$$i;            \
-               $(MAKE);                \
-               $(MAKE) install;        \
-               cd ../..;               \
-       done
-
-fill-kfs: install-libs
-       @mkdir -p $(FIRST_INITRAMFS_PATH)/lib
-       @cp $(addprefix $(GCC_ROOT)/$(TARGET_ARCH)-ros/lib/, \
-         libc.so.6 ld.so.1 libm.so libgcc_s.so.1) $(FIRST_INITRAMFS_PATH)/lib
-       $(STRIP) --strip-debug $(addprefix $(FIRST_INITRAMFS_PATH)/lib/, libc.so.6 ld.so.1)
-endif
-
-userclean:
-       @for i in $(USER_LIBS) ; do \
-               cd user/$$i;            \
-               $(MAKE) clean;          \
-               cd ../..;               \
-       done
-       @rm -rf $(OBJDIR)/$(TESTS_DIR)
-.PHONY: tests
-
-# Eliminate default suffix rules
-.SUFFIXES:
-
-# Delete target files if there is an error (or make is interrupted)
-.DELETE_ON_ERROR:
-
-# This magic automatically generates makefile dependencies
-# for header files included from C source files we compile,
-# and keeps those dependencies up-to-date every time we recompile.
-# See 'mergedep.pl' for more information.
-$(OBJDIR)/.deps: $(foreach dir, $(OBJDIRS), $(wildcard $(OBJDIR)/$(dir)/*.d))
-       @mkdir -p $(@D)
-       @$(PERL) scripts/mergedep.pl $@ $^
-
-# By including this file we automatically force the target that generates it 
-# to be rerun
--include $(OBJDIR)/.deps
-
-# Use doxygen to make documentation for ROS
-docs: 
-       @DOXYGEN_DIR=$(DOXYGEN_DIR) doxygen $(DOXYGEN_DIR)/rosdoc.cfg
-       @if [ ! -d $(DOXYGEN_DIR)/rosdoc/html/img ]; \
-        then \
-               ln -s ../../img $(DOXYGEN_DIR)/rosdoc/html; \
-        fi
-
-doxyclean:
-       rm -rf $(DOXYGEN_DIR)/rosdoc
-
-clean:
-       @$(MAKE) userclean
-       @echo + clean [KERNEL/TESTS]
-       @rm -rf $(OBJDIR)
-       @echo All clean and pretty!
-
-realclean: clean
-       @rm -f kern/boot
-       @rm -f kern/include/arch
-       @rm -f user/parlib/include/arch
-
-always:
-       @:
-
-.PHONY: all always docs clean
-
diff --git a/Kconfig b/Kconfig
new file mode 100644 (file)
index 0000000..46c3313
--- /dev/null
+++ b/Kconfig
@@ -0,0 +1,11 @@
+#
+# For a description of the syntax of this configuration file,
+# see Documentation/kbuild/kconfig-language.txt.
+#
+mainmenu "Akaros/$ARCH $KERNELVERSION Kernel Configuration"
+
+config SRCARCH
+       string
+       option env="ARCH"
+
+#source "arch/$SRCARCH/Kconfig"
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..b04c12f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,525 @@
+# Top-level Makefile for Akaros
+# Barret Rhoden
+#
+#
+# Notes:
+#      - I downloaded the kbuild guts from git://github.com/lacombar/kconfig.git,
+#      and added things from a recent linux makefile.  It is from aug 2011, so
+#      some things might not match up.
+#      - There's still some mysterious bits floating around, such as compile
+#      parameters like -D"KBUILD_STR(s)=#s" (they come from Makefile.lib).  They
+#      don't hurt, so I'm not removing them.  We might need them in the future
+#      too.
+#      - Kernel output in obj/: So Linux has the ability to output into another
+#      directory, via the KBUILD_OUTPUT variable.  This induces a recursive make
+#      in the output directory.  I mucked with it for a little, but didn't get it
+#      to work quite right.  Also, there will be other Akaros issues since this
+#      makefile is also used for userspace and tests.  For now, I'm leaving things
+#      the default Linux way.
+#
+# TODO:
+#      - Connect to kconfig, have it generate our CONFIGS, instead of makelocal.
+#              - We also want to consider having changes to .config force rebuilds.
+#              Right now, a change to the CFLAGS (CONFIGS) rebuilds it all.  Ideally,
+#              we'd only rebuild files that need the change. 
+#              - CONFIG_ are getting included twice, since we have includes of KCONFIG
+#              in both Makefile.build and here.
+#              - Might involve auto.conf{,.cmd} too.
+#
+#      - Do we want some sort of default config?  Or the ability to change arches
+#      and keep common vars?
+#
+#      - Review, with an eye for being better about $(srctree).  It might only be
+#      necessary in this file, if we every do the KBUILD_OUTPUT option
+#
+#      - It's a bit crazy that we build symlinks for parlib, instead of it
+#      managing its own links based on $(ARCH)
+#
+#      - Consider using Kbuild to build userspace and tests
+#
+#      - There are a few other TODOs sprinkled throughout the makefile.
+
+# Do not:
+# o  use make's built-in rules and variables
+#    (this increases performance and avoids hard-to-debug behaviour);
+# o  print "Entering directory ...";
+MAKEFLAGS += -rR --no-print-directory
+
+# That's our default target when none is given on the command line
+# This can be overriden with a Makelocal
+PHONY := all
+all: akaros-kernel
+
+# Symlinks
+# =========================================================================
+# We have a few symlinks so that code can include <arch/whatever.h>.  This
+# section builds and maintains those, as best we can.
+#
+# When invoking make, we can pass in ARCH=some-arch.  This value gets 'saved'
+# in the symlink, so that later invocations do not need ARCH=.  If this value
+# differs from the symlink, it appears like we are changing arches, which
+# triggers a clean and symlink reconstruction.
+#
+# When the user changes from one arch to another, they ought to reconfig, since
+# many of the CONFIG_ vars will depend on the arch.  If they try anything other
+# than one of the "non-build-goals" (cleans or configs), we'll abort.
+#
+# Make targets that need these symlinks (like building userspace, the kernel,
+# configs, etc, should depend on symlinks.
+
+clean-goals := clean mrproper realclean userclean testclean doxyclean objclean
+non-build-goals := %config $(clean-goals)
+goals := $(MAKECMDGOALS)
+ifeq ($(filter $(non-build-goals), $(goals)),)
+goals-has-build-targets := 1
+endif
+
+PHONY += symlinks clean_symlinks
+clean_symlinks:
+       @-rm -f kern/include/arch kern/boot user/parlib/include/arch
+
+arch-link := $(notdir $(shell readlink kern/include/arch))
+valid-arches := $(notdir $(wildcard kern/arch/*))
+
+ifneq ($(ARCH),)
+
+ifeq ($(filter $(valid-arches), $(ARCH)),)
+$(error ARCH $(ARCH) invalid, must be one of: $(valid-arches))
+endif
+
+ifneq ($(ARCH),$(arch-link))
+
+ifeq ($(goals-has-build-targets),1)
+$(error Attempted to make [$(goals)] while changing ARCH. \
+        You need to make *config.)
+endif
+
+symlinks: clean_symlinks clean
+       @echo Making symlinks...
+       $(Q)ln -fs ../arch/$(ARCH) kern/include/arch
+       $(Q)ln -fs arch/$(ARCH)/boot kern/boot
+       $(Q)ln -fs $(ARCH) user/parlib/include/arch
+else
+symlinks:
+endif # ifneq ($(ARCH),$(arch-link))
+
+else # $(ARCH) is empty
+
+ifneq ($(arch-link),)
+
+ARCH := $(arch-link)
+symlinks:
+
+else
+
+# Allow a clean
+ifeq ($(filter $(clean-goals), $(goals)),)
+$(error No arch saved or specified.  Make *config with ARCH=arch. \
+        'arch' must be one of: $(valid-arches))
+endif
+
+endif # ifneq ($(arch-link),)
+
+endif # ifeq ($(ARCH),)
+
+export ARCH
+
+
+# Init / Include Stuff and Akaros Settings
+# =========================================================================
+
+KCONFIG_CONFIG ?= .config
+export KCONFIG_CONFIG
+$(KCONFIG_CONFIG): ;
+
+# The user can override this, though it won't apply for any of the in-tree
+# kernel build output.  Right now, it's only passed down to tests/
+OBJDIR ?= obj
+dummy-1 := $(shell mkdir -p $(OBJDIR)/kern/)
+
+KERNEL_OBJ := $(OBJDIR)/kern/akaros-kernel
+CMP_KERNEL_OBJ := $(KERNEL_OBJ).gz
+
+# TODO: have the KFS paths be determined in .config
+# Give it a reasonable default path for initramfs to avoid build breakage
+INITRAMFS_PATHS = kern/kfs
+FIRST_INITRAMFS_PATH = $(firstword $(INITRAMFS_PATHS))
+
+export OBJDIR INITRAMFS_PATHS FIRST_INITRAMFS_PATH
+
+# TODO: replace Makeconfig with .config, and slim down Makelocal
+# Using fake rules so make doesn't get confused (do not try to remake the file)
+$(srctree)Makeconfig: ;
+include $(srctree)Makeconfig
+$(srctree)Makelocal: ;
+-include $(srctree)Makelocal
+-include $(srctree)$(KCONFIG)
+
+# Some Global Settings (Kbuild stuff)
+# =========================================================================
+
+# To put more focus on warnings, be less verbose as default
+# Use 'make V=1' to see the full commands
+
+ifeq ("$(origin V)", "command line")
+  KBUILD_VERBOSE = $(V)
+endif
+ifndef KBUILD_VERBOSE
+  KBUILD_VERBOSE = 0
+endif
+
+srctree                := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
+objtree                := $(CURDIR)
+
+export srctree objtree
+
+CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
+         else if [ -x /bin/bash ]; then echo /bin/bash; \
+         else echo sh; fi ; fi)
+
+HOSTCC       = gcc
+HOSTCXX      = g++
+HOSTCFLAGS   = -Wall -Wno-char-subscripts -Wmissing-prototypes \
+               -Wstrict-prototypes -O2 -fomit-frame-pointer
+HOSTCXXFLAGS = -O2
+HOSTOBJDUMP  = objdump
+HOSTOBJCOPY  = objcopy
+
+export CONFIG_SHELL HOSTCC HOSTCXX HOSTCFLAGS HOSTCXXFLAGS
+export HOSTOBJDUMP HOSTOBJCOPY
+
+# Beautify output
+# ---------------------------------------------------------------------------
+#
+# Normally, we echo the whole command before executing it. By making
+# that echo $($(quiet)$(cmd)), we now have the possibility to set
+# $(quiet) to choose other forms of output instead, e.g.
+#
+#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
+#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
+#
+# If $(quiet) is empty, the whole command will be printed.
+# If it is set to "quiet_", only the short version will be printed. 
+# If it is set to "silent_", nothing will be printed at all, since
+# the variable $(silent_cmd_cc_o_c) doesn't exist.
+#
+# A simple variant is to prefix commands with $(Q) - that's useful
+# for commands that shall be hidden in non-verbose mode.
+#
+#      $(Q)ln $@ :<
+#
+# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
+# If KBUILD_VERBOSE equals 1 then the above command is displayed.
+
+ifeq ($(KBUILD_VERBOSE),1)
+  quiet =
+  Q =
+else
+  quiet=quiet_
+  Q = @
+endif
+export quiet Q KBUILD_VERBOSE
+
+# We need some generic definitions (do not try to remake the file).
+$(srctree)/scripts/Kbuild.include: ;
+include $(srctree)/scripts/Kbuild.include
+
+# Basic helpers built in scripts/
+PHONY += scripts_basic
+scripts_basic:
+       $(Q)$(MAKE) $(build)=scripts/basic
+       $(Q)rm -f .tmp_quiet_recordmcount
+
+config: scripts_basic symlinks FORCE
+       $(Q)$(MAKE) $(build)=scripts/kconfig $@
+
+%config: scripts_basic symlinks FORCE
+       $(Q)$(MAKE) $(build)=scripts/kconfig $@
+
+PHONY += scripts
+
+# Not sure if this needs to depend on the config.  Linux's depends on
+# include/config/auto.conf include/config/tristate.conf
+scripts: scripts_basic $(KCONFIG)
+       $(Q)$(MAKE) $(build)=$(@)
+
+
+# Akaros Build Environment
+# =========================================================================
+AKAROSINCLUDE   := \
+                               -I$(srctree)/kern/arch/ \
+                               -I$(srctree)/kern/include/
+
+CROSS_COMPILE := $(ARCH)-ros-
+
+CC         := $(CROSS_COMPILE)gcc 
+CPP        := $(CROSS_COMPILE)g++
+AS         := $(CROSS_COMPILE)as
+AR         := $(CROSS_COMPILE)ar
+LD         := $(CROSS_COMPILE)ld
+OBJCOPY        := $(CROSS_COMPILE)objcopy
+OBJDUMP        := $(CROSS_COMPILE)objdump
+NM         := $(CROSS_COMPILE)nm
+STRIP   := $(CROSS_COMPILE)strip
+
+ifeq ($(shell which $(CROSS_COMPILE)gcc 2>/dev/null ),)
+ifeq ($(goals-has-build-targets),1)
+$(error Could not find a $(CROSS_COMPILE) version of GCC/binutils. \
+        Be sure to build the cross-compiler and update your PATH)
+endif
+else
+# Computing these without a cross compiler complains loudly
+gcc-lib := $(shell $(CC) -print-libgcc-file-name)
+NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
+# Note: calling this GCC_ROOT interferes with the host tools
+XCC_ROOT := $(dir $(shell which $(CC)))../
+endif
+
+CFLAGS_KERNEL += -O2 -pipe -MD -gstabs
+CFLAGS_KERNEL += -std=gnu99 -fgnu89-inline
+CFLAGS_KERNEL += -fno-strict-aliasing -fno-omit-frame-pointer
+CFLAGS_KERNEL += -fno-stack-protector
+CFLAGS_KERNEL += -Wall -Wno-format -Wno-unused
+CFLAGS_KERNEL += -DROS_KERNEL 
+
+# TODO: do we need this, or can we rely on the compiler's defines?
+CFLAGS_KERNEL += -D$(ARCH)
+
+# TODO: this requires our own strchr (kern/src/stdio.c), which is a potential
+# source of bugs/problems.
+# note we still pull in stdbool and stddef from the compiler
+CFLAGS_KERNEL += -fno-builtin
+
+AFLAGS_KERNEL := $(CFLAGS_KERNEL)
+
+KBUILD_BUILTIN := 1
+KBUILD_CHECKSRC := 0
+
+export AKAROSINCLUDE CROSS_COMPILE
+export CC CPP AS AR LD OBJCOPY OBJDUMP NM STRIP
+export CFLAGS_KERNEL AFLAGS_KERNEL
+export NOSTDINC_FLAGS XCC_ROOT
+export KBUILD_BUILTIN KBUILD_CHECKSRC
+
+CFLAGS_USER += -O2 -std=gnu99 -fno-stack-protector -fgnu89-inline
+CXXFLAGS_USER += -O2
+
+export CFLAGS_USER CXXFLAGS_USER
+
+# Akaros Kernel Build
+# =========================================================================
+# Add top level directories, either to an existing entry (core-y) or to its
+# own. 
+#
+# From these, we determine deps and dirs.  We recursively make through the
+# dirs, generating built-in.o at each step, which are the deps from which we
+# link akaros.
+#
+# We have all-arch-dirs and all-dirs, so that we can still clean even without
+# an arch symlink.
+
+core-y += kern/src/
+arch-y += kern/arch/$(ARCH)/
+
+akaros-dirs     := $(patsubst %/,%,$(filter %/, $(core-y) $(arch-y)))
+
+all-arch-dirs   := $(patsubst %,kern/arch/%/,$(valid-arches))
+akaros-all-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(all-arch-dirs)))
+
+core-y          := $(patsubst %/, %/built-in.o, $(core-y))
+arch-y          := $(patsubst %/, %/built-in.o, $(arch-y))
+
+kbuild_akaros_main := $(core-y) $(arch-y)
+akaros-deps := $(kbuild_akaros_main)  kern/arch/$(ARCH)/kernel.ld
+
+kern_cpio := $(OBJDIR)/kern/initramfs.cpio
+kern_cpio_obj := $(kern_cpio).o
+ifneq ($(EXT2_BDEV),)
+ext2_bdev_obj := $(OBJDIR)/kern/$(shell basename $(EXT2_BDEV)).o
+endif
+
+kern_initramfs_files := $(shell mkdir -p $(INITRAMFS_PATHS); \
+                          find $(INITRAMFS_PATHS))
+
+$(kern_cpio) initramfs: $(kern_initramfs_files)
+       @echo "  Building initramfs:"
+       @if [ "$(INITRAMFS_BIN)" != "" ]; then \
+        sh $(INITRAMFS_BIN); \
+    fi
+       $(Q)for i in $(INITRAMFS_PATHS); do cd $$i; \
+        echo "    Adding $$i to initramfs..."; \
+        find -L . | cpio --quiet -oH newc > \
+                       $(CURDIR)/$(kern_cpio); \
+        cd $$OLDPWD; \
+    done;
+
+ld_emulation := $(shell $(HOSTOBJDUMP) -i | grep -v BFD | grep ^[a-z] |head -n1)
+ld_arch := $(shell $(HOSTOBJDUMP) -i | grep -v BFD | grep "^  [a-z]" | head -n1)
+
+$(kern_cpio_obj): $(kern_cpio)
+       $(Q)$(HOSTOBJCOPY) -I binary -B $(ld_arch) -O $(ld_emulation) $^ $@
+
+$(ext2_bdev_obj): $(EXT2_BDEV)
+       $(Q)$(HOSTOBJCOPY) -I binary -B $(ld_arch) -O $(ld_emulation) $^ $@
+
+quiet_cmd_link-akaros = LINK    $@
+      cmd_link-akaros = $(LD) -T kern/arch/$(ARCH)/kernel.ld -o $@ \
+                              $(akaros-deps) \
+                              $(gcc-lib) \
+                              $(kern_cpio_obj) \
+                              $(ext2_bdev_obj) ; \
+                              $(OBJDUMP) -S $@ > $@.asm
+
+# For some reason, the if_changed doesn't work with FORCE (like it does in
+# Linux).  It looks like it can't find the .cmd file or something (also
+# complaints of $(targets), so that all is probably messed up).
+$(KERNEL_OBJ): $(akaros-deps) $(kern_cpio_obj) $(ext2_bdev_obj)
+       $(call if_changed,link-akaros)
+
+akaros-kernel: $(KERNEL_OBJ)
+
+$(sort $(akaros-deps)): $(akaros-dirs) ;
+
+# Recursively Kbuild all of our directories.  If we're changing arches
+# mid-make, we might have issues ( := on akaros-dirs, etc).
+PHONY += $(akaros-dirs)
+$(akaros-dirs): scripts symlinks
+       $(Q)$(MAKE) $(build)=$@
+
+$(CMP_KERNEL_OBJ): $(KERNEL_OBJ)
+       @echo "Compressing kernel image"
+       $(Q)gzip -c $^ > $@
+
+
+# Akaros Userspace Building and Misc Helpers
+# =========================================================================
+# Recursively make user libraries and tests.
+#
+# User library makefiles are built to expect to be called from their own
+# directories.  The test code can be called from the root directory.
+
+# List all userspace directories here, and state any dependencies between them,
+# such as how pthread depends on parlib.
+
+user-dirs = parlib pthread benchutil
+pthread: parlib
+
+ifeq ($(ARCH),i686)
+user-dirs += c3po
+c3po: parlib
+endif
+
+PHONY += install-libs $(user-dirs)
+install-libs: $(user-dirs) symlinks
+
+$(user-dirs):
+       @cd user/$@ && $(MAKE) && $(MAKE) install
+
+
+PHONY += userclean $(clean-user-dirs)
+clean-user-dirs := $(addprefix _clean_user_,$(user-dirs))
+userclean: $(clean-user-dirs) testclean
+
+$(clean-user-dirs):
+       @cd user/$(patsubst _clean_user_%,%,$@) && $(MAKE) clean
+
+tests/: tests
+tests: install-libs
+       @$(MAKE) -f tests/Makefile
+
+testclean:
+       @$(MAKE) -f tests/Makefile clean
+
+install-tests:
+       @$(MAKE) -f tests/Makefile install
+
+# TODO: cp -u all of the .sos, but flush it on an arch change (same with tests)
+fill-kfs: install-libs install-tests
+       @mkdir -p $(FIRST_INITRAMFS_PATH)/lib
+       @cp $(addprefix $(XCC_ROOT)/$(ARCH)-ros/lib/, \
+         libc.so.6 ld.so.1 libm.so libgcc_s.so.1) $(FIRST_INITRAMFS_PATH)/lib
+       $(Q)$(STRIP) --strip-debug $(addprefix $(FIRST_INITRAMFS_PATH)/lib/, \
+                                              libc.so.6 ld.so.1)
+
+# Use doxygen to make documentation for ROS (Untested since 2010 or so)
+doxygen-dir := $(CUR_DIR)/Documentation/doxygen
+docs: 
+       @echo "  Making doxygen"
+       @doxygen-dir=$(doxygen-dir) doxygen $(doxygen-dir)/rosdoc.cfg
+       @if [ ! -d $(doxygen-dir)/rosdoc/html/img ]; \
+        then \
+               ln -s ../../img $(doxygen-dir)/rosdoc/html; \
+        fi
+
+doxyclean:
+       @echo + clean [ROSDOC]
+       @rm -rf $(doxygen-dir)/rosdoc
+
+objclean:
+       @echo + clean [OBJDIR]
+       @rm -rf $(OBJDIR)/*
+
+realclean: userclean mrproper doxyclean objclean
+
+# Cleaning
+# =========================================================================
+# This is mostly the Linux kernel cleaning.  We could hook in to the userspace
+# cleaning with the 'userclean' target attached to clean, though historically
+# 'clean' means the kernel.
+
+# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
+# Usage:
+# $(Q)$(MAKE) $(clean)=dir
+clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
+
+# clean - Delete all generated files
+#
+clean-dirs         := $(addprefix _clean_,$(akaros-all-dirs))
+
+PHONY += $(clean-dirs) clean
+$(clean-dirs):
+       $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
+
+RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
+                   -o -name .pc -o -name .hg -o -name .git \) -prune -o
+clean: $(clean-dirs)
+       @find $(patsubst _clean_%,%,$(clean-dirs)) $(RCS_FIND_IGNORE) \
+            \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
+            -o -name '*.ko.*' \
+            -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
+            -o -name '*.symtypes' -o -name 'modules.order' \
+            -o -name modules.builtin -o -name '.tmp_*.o.*' \
+            -o -name '*.gcno' \) -type f -print | xargs rm -f
+
+# Could add in an archclean if we need arch-specific cleanup, or a userclean if
+# we want to start cleaning that too.
+#clean: archclean
+#clean: userclean
+
+# mrproper - Delete all generated files, including .config, and reset ARCH
+#
+mrproper-dirs      := $(addprefix _mrproper_,scripts)
+
+PHONY += $(mrproper-dirs) mrproper
+$(mrproper-dirs):
+       $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
+
+mrproper: $(mrproper-dirs) clean clean_symlinks
+       @-rm -f .config
+       @find $(patsubst _mrproper_%,%,$(mrproper-dirs)) $(RCS_FIND_IGNORE) \
+            \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
+            -o -name '*.ko.*' \
+            -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
+            -o -name '*.symtypes' -o -name 'modules.order' \
+            -o -name modules.builtin -o -name '.tmp_*.o.*' \
+            -o -name '*.gcno' \) -type f -print | xargs rm -f
+
+# Epilogue
+# =========================================================================
+
+PHONY += FORCE
+FORCE:
+
+# Declare the contents of the .PHONY variable as phony.  We keep that
+# information in a variable so we can use it in if_changed and friends.
+.PHONY: $(PHONY)
diff --git a/Makefile-KB b/Makefile-KB
deleted file mode 100644 (file)
index 88f222e..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-VERSION = 2
-PATCHLEVEL = 6
-SUBLEVEL = 38
-EXTRAVERSION =
-NAME = Sheep on Meth
-
-# To put more focus on warnings, be less verbose as default
-# Use 'make V=1' to see the full commands
-
-ifeq ("$(origin V)", "command line")
-  KBUILD_VERBOSE = $(V)
-endif
-ifndef KBUILD_VERBOSE
-  KBUILD_VERBOSE = 0
-endif
-
-srctree                := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
-objtree                := $(CURDIR)
-
-export srctree objtree
-
-CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
-         else if [ -x /bin/bash ]; then echo /bin/bash; \
-         else echo sh; fi ; fi)
-
-HOSTCC       = gcc
-HOSTCXX      = g++
-HOSTCFLAGS   = -Wall -Wno-char-subscripts -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
-HOSTCXXFLAGS = -O2
-
-export CONFIG_SHELL HOSTCC HOSTCXX HOSTCFLAGS HOSTCXXFLAGS
-
-# Beautify output
-# ---------------------------------------------------------------------------
-#
-# Normally, we echo the whole command before executing it. By making
-# that echo $($(quiet)$(cmd)), we now have the possibility to set
-# $(quiet) to choose other forms of output instead, e.g.
-#
-#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
-#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
-#
-# If $(quiet) is empty, the whole command will be printed.
-# If it is set to "quiet_", only the short version will be printed. 
-# If it is set to "silent_", nothing will be printed at all, since
-# the variable $(silent_cmd_cc_o_c) doesn't exist.
-#
-# A simple variant is to prefix commands with $(Q) - that's useful
-# for commands that shall be hidden in non-verbose mode.
-#
-#      $(Q)ln $@ :<
-#
-# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
-# If KBUILD_VERBOSE equals 1 then the above command is displayed.
-
-ifeq ($(KBUILD_VERBOSE),1)
-  quiet =
-  Q =
-else
-  quiet=quiet_
-  Q = @
-endif
-export quiet Q KBUILD_VERBOSE
-
-# We need some generic definitions (do not try to remake the file).
-include $(srctree)/scripts/Kbuild.include
-
-# Basic helpers built in scripts/
-PHONY += scripts_basic
-scripts_basic:
-       $(Q)$(MAKE) $(build)=scripts/basic
-       $(Q)rm -f .tmp_quiet_recordmcount
-
-config: scripts_basic FORCE
-       $(Q)$(MAKE) $(build)=scripts/kconfig $@
-
-%config: scripts_basic FORCE
-       $(Q)$(MAKE) $(build)=scripts/kconfig $@
-
-# mrproper - Delete all generated files, including .config
-#
-mrproper-dirs      := $(addprefix _mrproper_,scripts)
-
-PHONY += $(mrproper-dirs) mrproper
-$(mrproper-dirs):
-       $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
-
-mrproper: $(mrproper-dirs)
-
-# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
-# Usage:
-# $(Q)$(MAKE) $(clean)=dir
-clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
-
-PHONY += FORCE
-FORCE:
-
-# Declare the contents of the .PHONY variable as phony.  We keep that
-# information in a variable so we can use it in if_changed and friends.
-.PHONY: $(PHONY)
index d1138b1..de5311c 100644 (file)
 # General Purpose configuration parameters
-#CFLAGS += $(CONFIG_APPSERVER)
-#CFLAGS += $(CONFIG_DEMO_SLAVE)
+#CFLAGS_KERNEL += $(CONFIG_APPSERVER)
+#CFLAGS_USER += $(CONFIG_APPSERVER)
 
 # Kernel configuration parameters
-KERN_CFLAGS += $(CONFIG_KFS)
-#KERN_CFLAGS += $(CONFIG_EXT2FS)
-#KERN_CFLAGS += $(CONFIG_SINGLE_CORE)
-#KERN_CFLAGS += $(CONFIG_NETWORKING)
-#KERN_CFLAGS += $(CONFIG_SERIAL_IO)
-#KERN_CFLAGS += $(CONFIG_BSD_ON_CORE0)
+CFLAGS_KERNEL += $(CONFIG_KFS)
+#CFLAGS_KERNEL += $(CONFIG_EXT2FS)
+#CFLAGS_KERNEL += $(CONFIG_SINGLE_CORE)
+#CFLAGS_KERNEL += $(CONFIG_NETWORKING)
+#CFLAGS_KERNEL += $(CONFIG_SERIAL_IO)
+#CFLAGS_KERNEL += $(CONFIG_BSD_ON_CORE0)
+#CFLAGS_KERNEL += $(CONFIG_SPINLOCK_DEBUG)
+#CFLAGS_KERNEL += $(CONFIG_SPINPDR_NO_CAS)
 # Enabling this can cause userspace to make the kernel panic.
-#KERN_CFLAGS += $(CONFIG_SEQLOCK_DEBUG)
-#KERN_CFLAGS += $(CONFIG_SPINLOCK_DEBUG)
-#KERN_CFLAGS += $(CONFIG_SPINPDR_NO_CAS)
-#KERN_CFLAGS += $(CONFIG_PAGE_COLORING)
-#KERN_CFLAGS += $(CONFIG_DEMAND_PAGING)
-#KERN_CFLAGS += $(CONFIG_NOMTRRS)
-#KERN_CFLAGS += $(CONFIG_E1000_MMIO_HACK)
-#KERN_CFLAGS += $(CONFIG_E1000_ON_BOXBORO)
-#KERN_CFLAGS += $(CONFIG_E1000_ON_S142)
-#KERN_CFLAGS += $(CONFIG_ENABLE_MPTABLES)
-#KERN_CFLAGS += $(CONFIG_MONITOR_ON_INT)
-#KERN_CFLAGS += $(CONFIG_DISABLE_SMT)
-#KERN_CFLAGS += $(CONFIG_BOXBORO)
-# Enable this to set up ARSC server
-#KERN_CFLAGS += $(CONFIG_ARSC_SERVER)
-# Resets stacks in smp_idle(), at the expense of backtrace
-#KERN_CFLAGS += $(CONFIG_RESET_STACKS)
-#KERN_CFLAGS += $(CONFIG_PCI_VERBOSE)
-# Rimas's Ethernet audio device
-#KERN_CFLAGS += $(CONFIG_ETH_AUDIO)
-# Avoid KB input on buggy nehalems (brho's machine)
-#KERN_CFLAGS += $(CONFIG_KB_CORE0_ONLY)
-#KERN_CFLAGS += $(CONFIG_KTHREAD_POISON)
-#KERN_CFLAGS += $(CONFIG_PRINTK_NO_BACKSPACE)
-
-#KERN_CFLAGS += -DDEVELOPER_NAME=waterman
-#KERN_CFLAGS += -DDEVELOPER_NAME=brho
-
+#CFLAGS_KERNEL += $(CONFIG_SEQLOCK_DEBUG)
+#CFLAGS_KERNEL += $(CONFIG_PAGE_COLORING)
+#CFLAGS_KERNEL += $(CONFIG_DEMAND_PAGING)
+#CFLAGS_KERNEL += $(CONFIG_NOMTRRS)
+#CFLAGS_KERNEL += $(CONFIG_E1000_MMIO_HACK)
+#CFLAGS_KERNEL += $(CONFIG_E1000_ON_BOXBORO)
+#CFLAGS_KERNEL += $(CONFIG_E1000_ON_S142)
+#CFLAGS_KERNEL += $(CONFIG_ENABLE_MPTABLES)
+#CFLAGS_KERNEL += $(CONFIG_MONITOR_ON_INT)
+#CFLAGS_KERNEL += $(CONFIG_DISABLE_SMT)
+#CFLAGS_KERNEL += $(CONFIG_BOXBORO)
+#CFLAGS_KERNEL += $(CONFIG_ARSC_SERVER)
+#CFLAGS_KERNEL += $(CONFIG_RESET_STACKS)
+#CFLAGS_KERNEL += $(CONFIG_PCI_VERBOSE)
+#CFLAGS_KERNEL += $(CONFIG_ETH_AUDIO)
+#CFLAGS_KERNEL += $(CONFIG_KB_CORE0_ONLY)
+#CFLAGS_KERNEL += $(CONFIG_KTHREAD_POISON)
+#CFLAGS_KERNEL += $(CONFIG_PRINTK_NO_BACKSPACE)
+#CFLAGS_KERNEL += $(CONFIG_DEBUG_BREAKPOINT)
 
 # Paths for the initramfs (need to be directories)
 #INITRAMFS_PATHS = kern/kfs obj/tests
 INITRAMFS_PATHS = kern/kfs
-# Program to execute before building the initramfs
-#INITRAMFS_BIN = tools/whatever.sh
-# Image for ext2 (RAM version) (only brho uses this )
+#INITRAMFS_BIN = tools/test.sh
 #EXT2_BDEV = mnt/ext2fs.img
 
 # Userspace configuration parameters
-#USER_CFLAGS += $(CONFIG_SYSCALL_TRAP)
-#USER_CFLAGS += $(CONFIG_USER_DEBUGINFO)
+#CFLAGS_USER += $(CONFIG_SYSCALL_TRAP)
+#CFLAGS_USER += $(CONFIG_USER_DEBUGINFO)
 
 # User tests configuration parameters
-#TESTS_CFLAGS += $(CONFIG_STATIC_APPS)
+#CFLAGS_TESTS += $(CONFIG_STATIC_APPS)
 
-# Number of jobs in make
-#MAKE_JOBS := 4
-#
 # Default for sparc (i.e. needs an appserver)
 ifeq ($(TARGET_ARCH),sparc)
-KERN_CFLAGS += $(CONFIG_APPSERVER)
-KERN_CFLAGS += -DDEVELOPER_NAME=waterman
+CFLAGS_KERNEL += $(CONFIG_APPSERVER)
 endif
 
-# brho's (edited) KVM, USB, PXE, ETC make targets
-#kvm: $(OBJDIR)/kern/kernel
-#      $(V)echo "+ (KVM) Copying to mnt/hdd"
-#      $(V)cp $(OBJDIR)/kern/kernel mnt/hdd/kernel
-#      $(V)sync
-#endif
+# brho's custom targets.  Customize to your system.
+#$(OBJDIR)/kern/.kvm.touch: $(KERNEL_OBJ)
+#      @echo "  (KVM) Copying to mnt/hdd"
+#      $(Q)cp $^ mnt/hdd/texas
+#      @sync
+#      @touch $@
 #
-#usb: $(OBJDIR)/kern/kernel
-#      $(V)echo "+ (USB) Copying to /dev/sdc4"
-#      $(V)mount /dev/sdc4
-#      $(V)cp $(OBJDIR)/kern/kernel /mnt/usbstick/kernel
-#      $(V)sync
-#      $(V)umount /mnt/usbstick
+#kvm: $(OBJDIR)/kern/.kvm.touch ;
 #
-#pxe: $(OBJDIR)/kern/kernel
-#      $(V)echo "+ (PXE) Compressing..."
-#      $(V)gzip -c $(OBJDIR)/kern/kernel > $(OBJDIR)/kern/akaros-kernel.gz
-#      $(V)echo "+ (PXE) Copying to Watson"
-#      $(V)scp $(OBJDIR)/kern/akaros-kernel.gz watson.millennium.berkeley.edu:/tftpboot/akaros/akaros-kernel.gz
-
-x86:
-       $(MAKE) TARGET_ARCH=i686
-
-ramp:
-       $(MAKE) TARGET_ARCH=sparc
-
-riscv:
-       $(MAKE) TARGET_ARCH=riscv
+#$(OBJDIR)/kern/.usb.touch: $(KERNEL_OBJ)
+#      @echo "  (USB) Copying to /dev/sdc4"
+#      $(Q)mount /dev/sdc4
+#      $(Q)cp $^ /mnt/pornstick/texas
+#      @sync
+#      $(Q)umount /mnt/pornstick
+#      @touch $@
+#
+#usb: $(OBJDIR)/kern/.usb.touch ;
+#
+#$(OBJDIR)/kern/.pxe.touch: $(CMP_KERNEL_OBJ)
+#      @echo "  (PXE) Copying to Watson"
+#      $(Q)scp $^ watson.millennium.berkeley.edu:/tftpboot/akaros/akaros-kernel.gz
+#      @touch $@
+#
+#pxe: $(OBJDIR)/kern/.pxe.touch ;
 
 # various sparc functional simulator configurations
 NP ?= 1
 fs: all
-       sparc_app -p$(NP) -fappserver_ros.conf fs obj/kern/kernel none
+       sparc_app -p$(NP) -fappserver_ros.conf fs $(KERNEL_OBJ) none
 fsd: all
-       sparc_app_debug -p$(NP) -fappserver_ros.conf fs obj/kern/kernel none
+       sparc_app_debug -p$(NP) -fappserver_ros.conf fs $(KERNEL_OBJ) none
 hw: all
-       sparc_app -p$(NP) -fappserver_ros.conf hw obj/kern/kernel none
+       sparc_app -p$(NP) -fappserver_ros.conf hw $(KERNEL_OBJ) none
 
 # risc-v functional simulator
 rvfs: all
-       riscv-isa-run -p$(NP) obj/kern/kernel
+       fesvr -p$(NP) -nopk $(KERNEL_OBJ)
 rvfsd: all
-       riscv-isa-run -d -p$(NP) obj/kern/kernel
+       fesvr -d -p$(NP) -nopk $(KERNEL_OBJ)
 
-.PHONY: fs fsd hw rvfs rvfsd
+PHONY += fs fsd hw rvfs rvfsd
diff --git a/kern/Makefrag b/kern/Makefrag
deleted file mode 100644 (file)
index d0d60c9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-KERN_DIR := kern
-
-KERN_CFLAGS += $(CFLAGS) -DROS_KERNEL
-KERN_CFLAGS += -I$(INCLUDE_DIR)
-KERN_LDFLAGS := $(LDFLAGS)
-
-include $(KERN_DIR)/arch/$(TARGET_ARCH)/boot/Makefrag
-include $(KERN_DIR)/ivy/Makefrag
-include $(KERN_DIR)/arch/$(TARGET_ARCH)/Makefrag
-include $(KERN_DIR)/src/Makefrag
-
-.PRECIOUS: $(OBJDIR)/$(KERN_DIR)/%.o
diff --git a/kern/arch/i686/Kbuild b/kern/arch/i686/Kbuild
new file mode 100644 (file)
index 0000000..fcdb59d
--- /dev/null
@@ -0,0 +1,26 @@
+obj-y                          += apic.o
+obj-y                          += colored_caches.o
+obj-y                          += console.o
+obj-y                          += cpuinfo.o
+obj-y                          += e1000.o
+obj-y                          += entry.o
+obj-y                          += env.o
+obj-y                          += frontend.o
+obj-y                          += init.o
+obj-y                          += ioapic.o
+obj-y                          += kclock.o
+obj-y                          += kdebug.o
+obj-y                          += mptables.o
+obj-y                          += ne2k.o
+obj-y                          += page_alloc.o
+obj-y                          += pci.o
+obj-y                          += perfmon.o
+obj-y                          += pmap.o
+obj-y                          += process.o
+obj-y                          += rdtsc_test.o
+obj-y                          += rl8168.o
+obj-y                          += smp.o
+obj-y                          += smp_boot.o
+obj-y                          += smp_entry.o
+obj-y                          += trap.o
+obj-y                          += trapentry.o
diff --git a/kern/arch/i686/Makefrag b/kern/arch/i686/Makefrag
deleted file mode 100644 (file)
index d9118c4..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-# Makefile fragment for ROS kernel.
-# This is NOT a complete makefile;
-# you must run GNU make in the top-level directory
-# where the GNUmakefile is located.
-#
-
-KERN_ARCH_SRC_DIR = $(KERN_DIR)/arch/$(TARGET_ARCH)
-OBJDIRS += $(KERN_ARCH_SRC_DIR)
-
-# entry.S must be first, so that it's the first code in the text segment!!!
-#
-# We also snatch the use of a couple handy source files
-# from the lib directory, to avoid gratuitous code duplication.
-KERN_ARCH_SRCFILES := $(KERN_ARCH_SRC_DIR)/entry.S \
-                      $(KERN_ARCH_SRC_DIR)/smp_entry.S \
-                      $(KERN_ARCH_SRC_DIR)/cpuinfo.c \
-                      $(KERN_ARCH_SRC_DIR)/console.c \
-                      $(KERN_ARCH_SRC_DIR)/smp_boot.c \
-                      $(KERN_ARCH_SRC_DIR)/colored_caches.c \
-                      $(KERN_ARCH_SRC_DIR)/page_alloc.c \
-                      $(KERN_ARCH_SRC_DIR)/pmap.c \
-                      $(KERN_ARCH_SRC_DIR)/trapentry.S \
-                      $(KERN_ARCH_SRC_DIR)/trap.c \
-                      $(KERN_ARCH_SRC_DIR)/kclock.c \
-                      $(KERN_ARCH_SRC_DIR)/smp.c \
-                      $(KERN_ARCH_SRC_DIR)/apic.c \
-                      $(KERN_ARCH_SRC_DIR)/kdebug.c \
-                      $(KERN_ARCH_SRC_DIR)/process.c \
-                      $(KERN_ARCH_SRC_DIR)/mptables.c \
-                      $(KERN_ARCH_SRC_DIR)/pci.c \
-                      $(KERN_ARCH_SRC_DIR)/ioapic.c \
-                      $(KERN_ARCH_SRC_DIR)/rl8168.c \
-                      $(KERN_ARCH_SRC_DIR)/ne2k.c \
-                      $(KERN_ARCH_SRC_DIR)/e1000.c \
-                      $(KERN_ARCH_SRC_DIR)/init.c \
-                      $(KERN_ARCH_SRC_DIR)/env.c \
-                      $(KERN_ARCH_SRC_DIR)/frontend.c \
-                      $(KERN_ARCH_SRC_DIR)/rdtsc_test.c \
-                      $(KERN_ARCH_SRC_DIR)/perfmon.c
-
diff --git a/kern/arch/i686/boot/boot b/kern/arch/i686/boot/boot
deleted file mode 120000 (symlink)
index 4ff7493..0000000
+++ /dev/null
@@ -1 +0,0 @@
-arch/riscv/boot
\ No newline at end of file
diff --git a/kern/arch/riscv/Kbuild b/kern/arch/riscv/Kbuild
new file mode 100644 (file)
index 0000000..bdb309c
--- /dev/null
@@ -0,0 +1,17 @@
+obj-y                          += boot.o
+obj-y                          += cboot.o
+obj-y                          += colored_caches.o
+obj-y                          += console.o
+obj-y                          += cpuinfo.o
+obj-y                          += entry.o
+obj-y                          += env.o
+obj-y                          += fpu.o
+obj-y                          += init.o
+obj-y                          += kdebug.o
+obj-y                          += page_alloc.o
+obj-y                          += pmap.o
+obj-y                          += process.o
+obj-y                          += smp.o
+obj-y                          += softfloat.o
+obj-y                          += time.o
+obj-y                          += trap.o
diff --git a/kern/arch/riscv/Makefrag b/kern/arch/riscv/Makefrag
deleted file mode 100644 (file)
index ce1f49f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-# Makefile fragment for ROS kernel.
-# This is NOT a complete makefile;
-# you must run GNU make in the top-level directory
-# where the GNUmakefile is located.
-#
-
-KERN_ARCH_SRC_DIR = $(KERN_DIR)/arch/$(TARGET_ARCH)
-OBJDIRS += $(KERN_ARCH_SRC_DIR)
-
-# entry.S must be first, so that it's the first code in the text segment!!!
-#
-# We also snatch the use of a couple handy source files
-# from the lib directory, to avoid gratuitous code duplication.
-KERN_ARCH_SRCFILES := $(KERN_ARCH_SRC_DIR)/boot.S \
-                      $(KERN_ARCH_SRC_DIR)/entry.S \
-                      $(KERN_ARCH_SRC_DIR)/cboot.c \
-                      $(KERN_ARCH_SRC_DIR)/trap.c \
-                      $(KERN_ARCH_SRC_DIR)/cpuinfo.c \
-                      $(KERN_ARCH_SRC_DIR)/console.c \
-                      $(KERN_ARCH_SRC_DIR)/pmap.c \
-                      $(KERN_ARCH_SRC_DIR)/time.c \
-                      $(KERN_ARCH_SRC_DIR)/smp.c \
-                      $(KERN_ARCH_SRC_DIR)/colored_caches.c \
-                      $(KERN_ARCH_SRC_DIR)/page_alloc.c \
-                      $(KERN_ARCH_SRC_DIR)/process.c \
-                      $(KERN_ARCH_SRC_DIR)/env.c \
-                      $(KERN_ARCH_SRC_DIR)/init.c \
-                      $(KERN_ARCH_SRC_DIR)/kdebug.c \
-                      $(KERN_ARCH_SRC_DIR)/fpu.c \
-                      $(KERN_ARCH_SRC_DIR)/softfloat.c \
diff --git a/kern/arch/sparc/Kbuild b/kern/arch/sparc/Kbuild
new file mode 100644 (file)
index 0000000..c364fa3
--- /dev/null
@@ -0,0 +1,23 @@
+obj-y                          += boot.o
+obj-y                          += colored_caches.o
+obj-y                          += console.o
+obj-y                          += cpuinfo.o
+obj-y                          += entry.o
+obj-y                          += env.o
+obj-y                          += fpu.o
+obj-y                          += init.o
+obj-y                          += kdebug.o
+obj-y                          += page_alloc.o
+obj-y                          += pmap.o
+obj-y                          += process.o
+obj-y                          += recip.o
+obj-y                          += smp.o
+obj-y                          += softfloat.o
+obj-y                          += sparc.h
+obj-y                          += sparcfpu.o
+obj-y                          += spillfill.o
+obj-y                          += time.o
+obj-y                          += trap.o
+obj-y                          += trap.h
+obj-y                          += trap_entry.o
+obj-y                          += trap_table.o
diff --git a/kern/arch/sparc/Makefrag b/kern/arch/sparc/Makefrag
deleted file mode 100644 (file)
index 2c373f4..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-# Makefile fragment for ROS kernel.
-# This is NOT a complete makefile;
-# you must run GNU make in the top-level directory
-# where the GNUmakefile is located.
-#
-
-KERN_ARCH_SRC_DIR = $(KERN_DIR)/arch/$(TARGET_ARCH)
-OBJDIRS += $(KERN_ARCH_SRC_DIR)
-
-# entry.S must be first, so that it's the first code in the text segment!!!
-#
-# We also snatch the use of a couple handy source files
-# from the lib directory, to avoid gratuitous code duplication.
-KERN_ARCH_SRCFILES := $(KERN_ARCH_SRC_DIR)/entry.S \
-                      $(KERN_ARCH_SRC_DIR)/trap_table.S \
-                      $(KERN_ARCH_SRC_DIR)/trap_entry.S \
-                      $(KERN_ARCH_SRC_DIR)/spillfill.S \
-                      $(KERN_ARCH_SRC_DIR)/trap.c \
-                      $(KERN_ARCH_SRC_DIR)/boot.c \
-                      $(KERN_ARCH_SRC_DIR)/cpuinfo.c \
-                      $(KERN_ARCH_SRC_DIR)/console.c \
-                      $(KERN_ARCH_SRC_DIR)/pmap.c \
-                      $(KERN_ARCH_SRC_DIR)/page_alloc.c \
-                      $(KERN_ARCH_SRC_DIR)/process.c \
-                      $(KERN_ARCH_SRC_DIR)/colored_caches.c \
-                      $(KERN_ARCH_SRC_DIR)/time.c \
-                      $(KERN_ARCH_SRC_DIR)/env.c \
-                      $(KERN_ARCH_SRC_DIR)/init.c \
-                      $(KERN_ARCH_SRC_DIR)/smp.c \
-                      $(KERN_ARCH_SRC_DIR)/fpu.c \
-                      $(KERN_ARCH_SRC_DIR)/sparcfpu.c \
-                      $(KERN_ARCH_SRC_DIR)/softfloat.c \
-                      $(KERN_ARCH_SRC_DIR)/kdebug.c \
-                      $(KERN_ARCH_SRC_DIR)/recip.S
-
diff --git a/kern/src/Kbuild b/kern/src/Kbuild
new file mode 100644 (file)
index 0000000..4559db9
--- /dev/null
@@ -0,0 +1,47 @@
+obj-y                          += alarm.o
+obj-y                          += arsc.o
+obj-y                          += atomic.o
+obj-y                          += blockdev.o
+obj-y                          += colored_caches.o
+obj-y                          += console.o
+obj-y                          += devfs.o
+obj-y                          += elf.o
+obj-y                          += env.o
+obj-y                          += eth_audio.o
+obj-y                          += event.o
+obj-y                          += ext2fs.o
+obj-y                          += frontend.o
+obj-y                          += hashtable.o
+obj-y                          += init.o
+obj-y                          += kdebug.o
+obj-y                          += kfs.o
+obj-y                          += kmalloc.o
+obj-y                          += kthread.o
+obj-y                          += manager.o
+obj-y                          += mm.o
+obj-y                          += monitor.o
+obj-y                          += multiboot.o
+obj-y                          += net/
+obj-y                          += net.o
+obj-y                          += page_alloc.o
+obj-y                          += pagemap.o
+obj-y                          += pmap.o
+obj-y                          += printf.o
+obj-y                          += printfmt.o
+obj-y                          += process.o
+obj-y                          += radix.o
+obj-y                          += readline.o
+obj-y                          += schedule.o
+obj-y                          += slab.o
+obj-y                          += smp.o
+obj-y                          += socket.o
+obj-y                          += string.o
+obj-y                          += syscall.o
+obj-y                          += sysevent.o
+obj-y                          += testing.o
+obj-y                          += time.o
+obj-y                          += trap.o
+obj-y                          += ucq.o
+obj-y                          += umem.o
+obj-y                          += vfs.o
+
diff --git a/kern/src/Makefrag b/kern/src/Makefrag
deleted file mode 100644 (file)
index a74418c..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-# Makefile fragment for ROS kernel.
-# This is NOT a complete makefile;
-# you must run GNU make in the top-level directory
-# where the GNUmakefile is located.
-#
-
-KERN_SRC_DIR = $(KERN_DIR)/src
-OBJDIRS += $(KERN_SRC_DIR)
-KERN_CPIO = initramfs.cpio
-KERN_CPIO_OBJ = $(KERN_CPIO).o
-ifneq ($(EXT2_BDEV),)
-EXT2_BDEV_OBJ_FULL = $(OBJDIR)/$(KERN_DIR)/$(shell basename $(EXT2_BDEV)).o
-endif
-
-# entry.S must be first, so that it's the first code in the text segment!!!
-#
-# We also snatch the use of a couple handy source files
-# from the lib directory, to avoid gratuitous code duplication.
-KERN_SRCFILES := $(KERN_ARCH_SRCFILES) \
-                 $(KERN_SRC_DIR)/init.c \
-                 $(KERN_SRC_DIR)/monitor.c \
-                 $(KERN_SRC_DIR)/printf.c \
-                 $(KERN_SRC_DIR)/sched.c \
-                 $(KERN_SRC_DIR)/printfmt.c \
-                 $(KERN_SRC_DIR)/smp.c \
-                 $(KERN_SRC_DIR)/multiboot.c \
-                 $(KERN_SRC_DIR)/readline.c \
-                 $(KERN_SRC_DIR)/string.c \
-                 $(KERN_SRC_DIR)/atomic.c \
-                 $(KERN_SRC_DIR)/colored_caches.c \
-                 $(KERN_SRC_DIR)/page_alloc.c \
-                 $(KERN_SRC_DIR)/pmap.c \
-                 $(KERN_SRC_DIR)/env.c \
-                 $(KERN_SRC_DIR)/manager.c \
-                 $(KERN_SRC_DIR)/syscall.c \
-                 $(KERN_SRC_DIR)/time.c \
-                 $(KERN_SRC_DIR)/kfs.c \
-                 $(KERN_SRC_DIR)/process.c \
-                 $(KERN_SRC_DIR)/kmalloc.c \
-                 $(KERN_SRC_DIR)/hashtable.c \
-                 $(KERN_SRC_DIR)/schedule.c \
-                 $(KERN_SRC_DIR)/mm.c \
-                 $(KERN_SRC_DIR)/slab.c \
-                 $(KERN_SRC_DIR)/elf.c \
-                 $(KERN_SRC_DIR)/frontend.c \
-                 $(KERN_SRC_DIR)/vfs.c \
-                 $(KERN_SRC_DIR)/radix.c \
-                 $(KERN_SRC_DIR)/umem.c \
-                 $(KERN_SRC_DIR)/devfs.c \
-                 $(KERN_SRC_DIR)/blockdev.c \
-                 $(KERN_SRC_DIR)/ext2fs.c \
-                 $(KERN_SRC_DIR)/testing.c \
-                 $(KERN_SRC_DIR)/pagemap.c \
-                 $(KERN_SRC_DIR)/kthread.c \
-                 $(KERN_SRC_DIR)/eth_audio.c \
-                 $(KERN_SRC_DIR)/net.c \
-                 $(KERN_SRC_DIR)/event.c \
-                 $(KERN_SRC_DIR)/alarm.c \
-                 $(KERN_SRC_DIR)/kdebug.c \
-                 $(KERN_SRC_DIR)/ucq.c \
-                 $(KERN_SRC_DIR)/console.c \
-                 $(KERN_SRC_DIR)/trap.c \
-                 $(KERN_SRC_DIR)/socket.c \
-                 $(KERN_SRC_DIR)/net/udp.c \
-                 $(KERN_SRC_DIR)/net/tcp.c \
-                 $(KERN_SRC_DIR)/net/ip.c \
-                 $(KERN_SRC_DIR)/net/pbuf.c \
-                 $(KERN_SRC_DIR)/net/tcp_out.c \
-                 $(KERN_SRC_DIR)/net/tcp_in.c \
-                 $(KERN_SRC_DIR)/net/timers.c \
-                 $(KERN_SRC_DIR)/net/nic_common.c \
-                 $(KERN_SRC_DIR)/arsc.c
-
-# Only build files if they exist.
-KERN_SRCFILES := $(wildcard $(KERN_SRCFILES))
-
-KERN_LDFLAGS   := $(KERN_LDFLAGS) -L$(OBJDIR)/$(KERN_DIR) \
-                  -T $(KERN_ARCH_SRC_DIR)/kernel.ld
-
-KERN_OBJFILES  := $(patsubst $(KERN_DIR)/%.c, \
-                             $(OBJDIR)/$(KERN_DIR)/%.o, \
-                             $(KERN_SRCFILES))
-KERN_OBJFILES  := $(patsubst $(KERN_DIR)/%.S, \
-                             $(OBJDIR)/$(KERN_DIR)/%.o, \
-                             $(KERN_OBJFILES))
-
-KERN_LDDEPENDS := $(KERN_OBJFILES) $(ARCH_DIR)/$(TARGET_ARCH)/kernel.ld \
-                  $(OBJDIR)/$(KERN_DIR)/libivykern.a \
-                  $(OBJDIR)/$(KERN_DIR)/$(KERN_CPIO_OBJ) \
-                  $(EXT2_BDEV_OBJ_FULL)
-
-KERN_LDLIBS    := -livykern
-
-KERN_GCC_LIB   ?= $(GCC_LIB)
-
-KERN_INITRAMFS_FILES := $(shell mkdir -p $(INITRAMFS_PATHS); find $(INITRAMFS_PATHS))
-
-$(OBJDIR)/$(KERN_DIR)/$(KERN_CPIO) initramfs: $(KERN_INITRAMFS_FILES)
-       @echo Building initramfs:
-       @if [ "$(INITRAMFS_BIN)" != "" ]; then \
-        sh $(INITRAMFS_BIN); \
-    fi
-       $(V)for i in $(INITRAMFS_PATHS); do cd $$i; \
-        echo Adding $$i to initramfs...; \
-        find -L . | cpio --quiet -oH newc > \
-             $(TOP_DIR)/$(OBJDIR)/$(KERN_DIR)/$(KERN_CPIO); \
-        cd $$OLDPWD; \
-    done;
-
-LD_EMULATION := $(shell $(OBJDUMP) -i | grep -v BFD | grep ^[a-z] | head -n1)
-LD_ARCH := $(shell $(OBJDUMP) -i | grep -v BFD | grep "^  [a-z]" | head -n1)
-
-$(OBJDIR)/$(KERN_DIR)/$(KERN_CPIO_OBJ): $(OBJDIR)/$(KERN_DIR)/$(KERN_CPIO)
-       $(V)$(OBJCOPY) -I binary -B $(LD_ARCH) -O $(LD_EMULATION) $^ $@
-
-$(EXT2_BDEV_OBJ_FULL): $(EXT2_BDEV)
-       $(V)$(OBJCOPY) -I binary -B $(LD_ARCH) -O $(LD_EMULATION) $^ $@
-
-$(OBJDIR)/$(KERN_DIR)/%.o: $(KERN_DIR)/%.c
-       @echo + cc [KERN] $<
-       @mkdir -p $(@D)
-       $(V)$(CC) $(KERN_CFLAGS) -c -o $@ $<
-
-$(OBJDIR)/$(KERN_DIR)/%.o: $(KERN_DIR)/%.S
-       @echo + as [KERN] $<
-       @mkdir -p $(@D)
-       $(V)$(CC) $(KERN_CFLAGS) -D__ASSEMBLER__ -c -o $@ $<
-
-$(OBJDIR)/$(KERN_DIR)/kernel: $(KERN_LDDEPENDS)
-       @echo + ld [KERN] $@
-       $(V)$(LD) -o $@ $(KERN_LDFLAGS) $(KERN_OBJFILES) $(KERN_LDLIBS) \
-                       $(KERN_GCC_LIB) $(OBJDIR)/$(KERN_DIR)/$(KERN_CPIO_OBJ) \
-                       $(EXT2_BDEV_OBJ_FULL)
-       $(V)$(OBJDUMP) -S $@ > $@.asm
-       $(V)$(NM) -n $@ > $@.sym
-
-all: $(OBJDIR)/$(KERN_DIR)/kernel
-
diff --git a/kern/src/net/Kbuild b/kern/src/net/Kbuild
new file mode 100644 (file)
index 0000000..cc1167a
--- /dev/null
@@ -0,0 +1,8 @@
+obj-y                          += ip.o
+obj-y                          += nic_common.o
+obj-y                          += pbuf.o
+obj-y                          += tcp.o
+obj-y                          += tcp_in.o
+obj-y                          += tcp_out.o
+obj-y                          += timers.o
+obj-y                          += udp.o
index 0b94d2f..9e06ddd 100644 (file)
@@ -33,6 +33,11 @@ subdir-ccflags-y :=
 # Read auto.conf if it exists, otherwise ignore
 -include include/config/auto.conf
 
+# TODO include .config instead of Makelocal
+include Makeconfig
+-include Makelocal
+-include $(KCONFIG)
+
 include scripts/Kbuild.include
 
 # For backward compatibility check that these variables do not change
index 6f89fbb..686cb0d 100644 (file)
@@ -45,6 +45,8 @@ __clean-files := $(extra-y) $(always)                  \
                   $(host-progs)                         \
                   $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
 
+__clean-files   := $(filter-out $(no-clean-files), $(__clean-files))
+
 # as clean-files is given relative to the current directory, this adds
 # a $(obj) prefix, except for absolute paths
 
index f9bdf26..2ce73ec 100644 (file)
@@ -150,15 +150,15 @@ __a_flags =                          $(call flags,_a_flags)
 __cpp_flags     =                          $(call flags,_cpp_flags)
 endif
 
-c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(AKAROSINCLUDE)    \
                 $(__c_flags) $(modkern_cflags)                           \
                 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \
                  $(debug_flags)
 
-a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(AKAROSINCLUDE)    \
                 $(__a_flags) $(modkern_aflags)
 
-cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(AKAROSINCLUDE)    \
                 $(__cpp_flags)
 
 ld_flags       = $(LDFLAGS) $(ldflags-y)
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
new file mode 100644 (file)
index 0000000..a776371
--- /dev/null
@@ -0,0 +1 @@
+fixdep
index 3657e1a..c13e852 100644 (file)
@@ -4,15 +4,26 @@
 
 PHONY += oldconfig xconfig gconfig menuconfig config
 
+ifdef KBUILD_KCONFIG
+Kconfig := $(KBUILD_KCONFIG)
+else
+Kconfig := Kconfig
+endif
+
 xconfig: $(obj)/qconf
+       $< $(Kconfig)
 
 gconfig: $(obj)/gconf
+       $< $(Kconfig)
 
 menuconfig: $(obj)/mconf
+       $< $(Kconfig)
 
 config: $(obj)/conf
+       $< $(Kconfig)
 
 nconfig: $(obj)/nconf
+       $< $(Kconfig)
 
 # lxdialog stuff
 check-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
diff --git a/scripts/mergedep.pl b/scripts/mergedep.pl
deleted file mode 100644 (file)
index 180b2b9..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/perl
-# Copyright 2003 Bryan Ford
-# Distributed under the GNU General Public License.
-#
-# Usage: mergedep <main-depfile> [<new-depfiles> ...]
-#
-# This script merges the contents of all <new-depfiles> specified
-# on the command line into the single file <main-depfile>,
-# which may or may not previously exist.
-# Dependencies in the <new-depfiles> will override
-# any existing dependencies for the same targets in <main-depfile>.
-# The <new-depfiles> are deleted after <main-depfile> is updated.
-#
-# The <new-depfiles> are typically generated by GCC with the -MD option,
-# and the <main-depfile> is typically included from a Makefile,
-# as shown here for GNU 'make':
-#
-#      .deps: $(wildcard *.d)
-#              perl mergedep $@ $^
-#      -include .deps
-#
-# This script properly handles multiple dependencies per <new-depfile>,
-# including dependencies having no target,
-# so it is compatible with GCC3's -MP option.
-#
-
-sub makedirname($) 
-{
-       my $file = shift; 
-       $file =~ s!/?[^/]*/*$!!; 
-       $file =~ s!^[^/]*/!!; 
-       return $file; 
-}
-
-sub readdeps {
-       my $filename = shift;
-       my $use_filename = shift;
-
-       open(DEPFILE, $filename) or return 0;
-       while (<DEPFILE>) {
-               if (/([^:]*):([^\\:]*)([\\]?)$/) {
-                       my $target = $1;
-                       my $deplines = $2;
-                       my $slash = $3;
-                       if($use_filename) {
-                               $target = $filename;
-                               $target =~ s/\.d$/\.o/;
-                       }
-                       while ($slash ne '') {
-                               $_ = <DEPFILE>;
-                               defined($_) or die
-                                       "Unterminated dependency in $filename";
-                               /(^[ \t][^\\]*)([\\]?)$/ or die
-                                       "Bad continuation line in $filename";
-                               $deplines = "$deplines\\\n$1";
-                               $slash = $2;
-                       }
-                       #print "DEPENDENCY [[$target]]: [[$deplines]]\n";
-                       my $new_deplines = $deplines;
-                       if($use_filename) {
-                               my $makelocal = "Makelocal";
-                               my $sim_makelocal = "sim/Makelocal";
-                               if (! -e $makelocal) {
-                                       $makelocal = ""
-                               }
-                               if (! -e $sim_makelocal) {
-                                       $sim_makelocal = ""
-                               }
-                               $new_deplines = 
-                                     " " . $makelocal . " " . $sim_makelocal . " " 
-                                         . makedirname($filename) . "/Makefrag" . $deplines;
-                       }
-                       $dephash{$target} = $new_deplines;
-               } elsif (/^[#]?[ \t]*$/) {
-                       # ignore blank lines and comments
-               } else {
-                       die "Bad dependency line in $filename: $_";
-               }
-       }
-       close DEPFILE;
-       return 1;
-}
-
-
-if ($#ARGV < 0) {
-       print "Usage: mergedep <main-depfile> [<new-depfiles> ..]\n";
-       exit(1);
-}
-
-%dephash = ();
-
-# Read the main dependency file
-$maindeps = $ARGV[0];
-readdeps($maindeps, 0);
-
-# Read and merge in the new dependency files
-foreach $i (1 .. $#ARGV) {
-       readdeps($ARGV[$i], 1) or die "Can't open $ARGV[$i]";
-}
-
-# Update the main dependency file
-open(DEPFILE, ">$maindeps.tmp") or die "Can't open output file $maindeps.tmp";
-foreach $target (keys %dephash) {
-       print DEPFILE "$target:$dephash{$target}";
-}
-close DEPFILE;
-rename("$maindeps.tmp", "$maindeps") or die "Can't overwrite $maindeps";
-
-# Finally, delete the new dependency files
-foreach $i (1 .. $#ARGV) {
-       unlink($ARGV[$i]) or print "Error removing $ARGV[$i]\n";
-}
-
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644 (file)
index 0000000..4282e8e
--- /dev/null
@@ -0,0 +1,57 @@
+# Default target is to just make
+PHONY += all install clean
+all:
+
+# TODO: when we clean this up, if we ditch OBJDIR, change the root makefile
+TESTS_DIR = tests
+
+CFLAGS_TESTS += $(CFLAGS_USER) -g
+TESTS_CXXFLAGS += $(CXXFLAGS_USER) -g
+
+TESTS_LDLIBS := -lpthread -lbenchutil -lm
+
+TESTS_SRCS_C = $(shell ls $(TESTS_DIR)/*.c)
+TESTS_SRCS_CPP = $(shell ls $(TESTS_DIR)/*.cc)
+
+TESTS_LDDEPENDS_C := $(TESTS_DIR)/%.c 
+TESTS_LDDEPENDS_CPP := $(TESTS_DIR)/%.cc
+
+TESTS_EXECS_C  = $(patsubst $(TESTS_DIR)/%.c, \
+                            $(OBJDIR)/$(TESTS_DIR)/%, \
+                            $(TESTS_SRCS_C))
+
+TESTS_EXECS_CPP  = $(patsubst $(TESTS_DIR)/%.cc, \
+                              $(OBJDIR)/$(TESTS_DIR)/%, \
+                              $(TESTS_SRCS_CPP))
+
+include $(TESTS_DIR)/c3po/Makefrag
+include $(TESTS_DIR)/openmp/Makefrag
+
+STATIC := $(findstring static,$(CFLAGS_TESTS))
+$(OBJDIR)/$(TESTS_DIR)/%: $(TESTS_LDDEPENDS_C)
+       @echo + cc [TESTS] $<
+       @mkdir -p $(@D)
+       $(Q)$(CC) $(CFLAGS_TESTS) -o $@ $< $(TESTS_LDLIBS)
+       @if [ "$(STATIC)" != "static" ]; then \
+               $(OBJDUMP) -S $@ > $@.asm; \
+               $(NM) -n $@ > $@.sym; \
+       fi
+
+# Note that we don't disassemble CPPs by default, even if they aren't static.
+# The files are pretty large regardless (9MB for a simple stream test asm).
+$(OBJDIR)/$(TESTS_DIR)/%: $(TESTS_LDDEPENDS_CPP)
+       @echo + cc [TESTS] $<
+       @mkdir -p $(@D)
+       $(Q)$(CPP) $(TESTS_CXXFLAGS) -o $@ $< $(TESTS_LDLIBS)
+
+all: $(TESTS_EXECS_C) $(TESTS_EXECS_CPP) 
+       @:
+
+install: $(TESTS_EXECS_C) $(TESTS_EXECS_CPP) 
+       $(Q)cp -u $^ $(FIRST_INITRAMFS_PATH)/bin
+
+clean:
+       @echo + clean [TESTS]
+       @rm -rf $(OBJDIR)/tests/
+
+.PHONY: $(PHONY)
diff --git a/tests/Makefrag b/tests/Makefrag
deleted file mode 100644 (file)
index e7b13be..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-TESTS_DIR = tests
-
-OBJDIRS += $(TESTS_DIR)
-
-TESTS_CFLAGS += $(USER_CFLAGS) -g
-TESTS_CXXFLAGS += $(USER_CXXFLAGS) -g
-TESTS_LDFLAGS += $(USER_LDFLAGS)
-
-TESTS_LDLIBS := -lpthread -lbenchutil -lm
-
-TESTS_SRCS_C = $(shell ls $(TESTS_DIR)/*.c)
-TESTS_SRCS_CPP = $(shell ls $(TESTS_DIR)/*.cc)
-
-TESTS_LDDEPENDS_C := $(TESTS_DIR)/%.c 
-TESTS_LDDEPENDS_CPP := $(TESTS_DIR)/%.cc
-
-TESTS_EXECS_C  = $(patsubst $(TESTS_DIR)/%.c, \
-                            $(OBJDIR)/$(TESTS_DIR)/%, \
-                            $(TESTS_SRCS_C))
-
-TESTS_EXECS_CPP  = $(patsubst $(TESTS_DIR)/%.cc, \
-                            $(OBJDIR)/$(TESTS_DIR)/%, \
-                            $(TESTS_SRCS_CPP))
-
-include $(TESTS_DIR)/c3po/Makefrag
-include $(TESTS_DIR)/openmp/Makefrag
-
-STATIC := $(findstring static,$(TESTS_CFLAGS))
-$(OBJDIR)/$(TESTS_DIR)/%: $(TESTS_LDDEPENDS_C)
-       @echo + cc [TESTS] $<
-       @mkdir -p $(@D)
-       $(V)$(CC) $(TESTS_CFLAGS) -o $@ $(TESTS_LDFLAGS) \
-                 $< $(TESTS_LDLIBS)
-       @if [ "$(STATIC)" != "static" ]; then \
-               $(OBJDUMP) -S $@ > $@.asm; \
-               $(NM) -n $@ > $@.sym; \
-       fi
-
-# Note that we don't disassemble CPPs by default, even if they aren't static.
-# The files are pretty large regardless (9MB for a simple stream test asm).
-$(OBJDIR)/$(TESTS_DIR)/%: $(TESTS_LDDEPENDS_CPP)
-       @echo + cc [TESTS] $<
-       @mkdir -p $(@D)
-       $(V)$(CPP) $(TESTS_CXXFLAGS) -o $@ $(TESTS_LDFLAGS) \
-                 $< $(TESTS_LDLIBS)
-
-install-tests: $(TESTS_EXECS_C) $(TESTS_EXECS_CPP) 
-       @echo + install [TESTS] $(FIRST_INITRAMFS_PATH)/bin/
-       $(V)for i in "$(TESTS_EXECS) $(TESTS_EXECS_CPP)"; \
-       do \
-         cp $$i $(FIRST_INITRAMFS_PATH)/bin/; \
-       done;
index 32478bd..1efd3b6 100644 (file)
@@ -1,7 +1,7 @@
 C3PO_TESTS_DIR = $(TESTS_DIR)/c3po
 
-C3PO_TESTS_CFLAGS += $(TESTS_CFLAGS) \
-                     -I$(GCC_ROOT)/$(TARGET_ARCH)-ros/sys-include/c3po
+C3PO_TESTS_CFLAGS += $(CFLAGS_TESTS) \
+                     -I$(XCC_ROOT)/$(ARCH)-ros/sys-include/c3po
 
 ALL_C3PO_TEST_FILES = $(shell ls $(C3PO_TESTS_DIR)/*.c)
 
@@ -11,7 +11,7 @@ C3PO_TESTS_SRCS := $(ALL_C3PO_TEST_FILES)
 
 C3PO_TESTS_LDDEPENDS := $(C3PO_TESTS_DIR)/%.c 
 
-TESTS_EXECS  += $(patsubst $(C3PO_TESTS_DIR)/%.c, \
+TESTS_EXECS_C  += $(patsubst $(C3PO_TESTS_DIR)/%.c, \
                       $(OBJDIR)/$(C3PO_TESTS_DIR)/%, \
                       $(C3PO_TESTS_SRCS))
 
@@ -19,7 +19,7 @@ STATIC := $(findstring static,$(C3PO_TESTS_CFLAGS))
 $(OBJDIR)/$(C3PO_TESTS_DIR)/%: $(C3PO_TESTS_LDDEPENDS)
        @echo + cc [C3PO_TESTS] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(C3PO_TESTS_CFLAGS) -o $@ $(C3PO_TESTS_LDFLAGS) \
+       $(Q)$(CC) $(C3PO_TESTS_CFLAGS) -o $@ $(C3PO_TESTS_LDFLAGS) \
                  $(C3PO_TESTS_LDDIRS) $< $(C3PO_TESTS_LDLIBS)
        @if [ "$(STATIC)" != "static" ]; then \
                $(OBJDUMP) -S $@ > $@.asm; \
index 35a088d..e06ddaa 100644 (file)
@@ -1,8 +1,8 @@
 OPENMP_TESTS_DIR = $(TESTS_DIR)/openmp
 
-OPENMP_TESTS_CFLAGS += $(TESTS_CFLAGS) \
+OPENMP_TESTS_CFLAGS += $(CFLAGS_TESTS) \
                      -fopenmp \
-                     -I$(GCC_ROOT)/$(TARGET_ARCH)-ros/sys-include/openmp
+                     -I$(XCC_ROOT)/$(ARCH)-ros/sys-include/openmp
 
 ALL_OPENMP_TEST_FILES = $(shell ls $(OPENMP_TESTS_DIR)/*.c)
 
@@ -12,7 +12,7 @@ OPENMP_TESTS_SRCS := $(ALL_OPENMP_TEST_FILES)
 
 OPENMP_TESTS_LDDEPENDS := $(OPENMP_TESTS_DIR)/%.c 
 
-TESTS_EXECS  += $(patsubst $(OPENMP_TESTS_DIR)/%.c, \
+TESTS_EXECS_C  += $(patsubst $(OPENMP_TESTS_DIR)/%.c, \
                       $(OBJDIR)/$(OPENMP_TESTS_DIR)/%, \
                       $(OPENMP_TESTS_SRCS))
 
@@ -20,7 +20,7 @@ STATIC := $(findstring static,$(OPENMP_TESTS_CFLAGS))
 $(OBJDIR)/$(OPENMP_TESTS_DIR)/%: $(OPENMP_TESTS_LDDEPENDS)
        @echo + cc [OPENMP_TESTS] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(OPENMP_TESTS_CFLAGS) -o $@ $(OPENMP_TESTS_LDFLAGS) \
+       $(Q)$(CC) $(OPENMP_TESTS_CFLAGS) -o $@ $(OPENMP_TESTS_LDFLAGS) \
                  $(OPENMP_TESTS_LDDIRS) $< $(OPENMP_TESTS_LDLIBS)
        @if [ "$(STATIC)" != "static" ]; then \
                $(OBJDUMP) -S $@ > $@.asm; \
index 6e6b2da..11aa5c6 100644 (file)
@@ -302,7 +302,7 @@ $(BINARY_PREFIX)gcc-stage2-builddir: gcc-$(GCC_VERSION)
 .$(BINARY_PREFIX)ros-install-libs:
        cd $(ROSDIR); \
        make userclean; \
-       make TARGET_ARCH=$(ARCH) -j $(MAKE_JOBS) install-libs
+       make ARCH=$(ARCH) -j $(MAKE_JOBS) install-libs
 
 .$(BINARY_PREFIX)gcc-stage2-configure:
        $(MAKE) $(BINARY_PREFIX)gcc-stage2-builddir
index 09efc1d..f31a705 100644 (file)
@@ -1,11 +1,6 @@
-TARGET_ARCH ?= none    # catch bugs
-CFLAGS = -O2 -std=gnu99 -static -fomit-frame-pointer -g
+ARCH ?= none   # catch bugs
+CFLAGS_USER += -static -fomit-frame-pointer -g
 LIBNAME = benchutil
-V ?= @
-
-GCCPREFIX := $(TARGET_ARCH)-ros-
-CC := $(GCCPREFIX)gcc
-GCC_ROOT := $(shell which $(CC) | xargs dirname)/../
 
 SRCDIR := 
 OBJDIR := $(SRCDIR)obj
@@ -19,36 +14,37 @@ uc = $(shell echo $(1) | tr a-z A-Z)
 LIBUCNAME := $(call uc, $(LIBNAME))
 HEADERS := $(shell find $(INCDIR) -name *.h)
 CFILES  := $(wildcard $(SRCDIR)*.c)
-CFILES  += $(wildcard $(SRCDIR)$(TARGET_ARCH)/*.c)
-SFILES  := $(wildcard $(SRCDIR)$(TARGET_ARCH)/*.S)
+CFILES  += $(wildcard $(SRCDIR)$(ARCH)/*.c)
+SFILES  := $(wildcard $(SRCDIR)$(ARCH)/*.S)
 OBJS    := $(patsubst %.c, $(OBJDIR)/%.o, $(CFILES)) \
            $(patsubst %.S, $(OBJDIR)/%.o, $(SFILES))
 
 all: $(FINALLIB)
+       @:
 
-$(OBJDIR)/$(TARGET_ARCH)/%.o: $(SRCDIR)$(TARGET_ARCH)/%.S $(HEADERS)
+$(OBJDIR)/$(ARCH)/%.o: $(SRCDIR)$(ARCH)/%.S $(HEADERS)
        @echo + as [$(LIBUCNAME)] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(CFLAGS) $(INCS) -o $@ -c $<
+       $(Q)$(CC) $(CFLAGS_USER) $(INCS) -o $@ -c $<
 
 $(OBJDIR)/%.o: $(SRCDIR)%.c $(HEADERS)
        @echo + cc [$(LIBUCNAME)] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(CFLAGS) $(INCS) -o $@ -c $<
+       $(Q)$(CC) $(CFLAGS_USER) $(INCS) -o $@ -c $<
 
 $(FINALLIB): $(OBJS)
        @echo + ar [$(LIBUCNAME)] $@
        @mkdir -p $(@D)
-       $(V)$(AR) rc $@ $(OBJS)
+       $(Q)$(AR) rc $@ $(OBJS)
 
 install: $(FINALLIB)
-       cp $(FINALLIB) $(GCC_ROOT)/$(TARGET_ARCH)-ros/lib/
-       cp -R $(INCDIR)/* $(GCC_ROOT)/$(TARGET_ARCH)-ros/sys-include/
-       rm -rf $(GCC_ROOT)/$(TARGET_ARCH)-ros/sys-include/benchutil
-       ln -fs . $(GCC_ROOT)/$(TARGET_ARCH)-ros/sys-include/benchutil
+       @cp $(FINALLIB) $(XCC_ROOT)/$(ARCH)-ros/lib/
+       @cp -R $(INCDIR)/* $(XCC_ROOT)/$(ARCH)-ros/sys-include/
+       @rm -rf $(XCC_ROOT)/$(ARCH)-ros/sys-include/benchutil
+       @ln -fs . $(XCC_ROOT)/$(ARCH)-ros/sys-include/benchutil
 
 clean: 
        @echo + clean [$(LIBUCNAME)]
-       $(V)rm -rf $(FINALLIB)
-       $(V)rm -rf $(OBJDIR)
+       $(Q)rm -rf $(FINALLIB)
+       $(Q)rm -rf $(OBJDIR)
        
index b917ee5..c868eb3 100644 (file)
@@ -1,13 +1,8 @@
-TARGET_ARCH ?= none    # catch bugs
-CFLAGS = -O2 -static -std=gnu99 -fomit-frame-pointer -DOPTIMIZE=2 -DNO_TIMING \
-         -Wno-deprecated-declarations
+ARCH ?= none   # catch bugs
+CFLAGS_USER += -static -fomit-frame-pointer -DOPTIMIZE=2 -DNO_TIMING \
+               -Wno-deprecated-declarations
 LIBNAME = c3po
 SUBDIRS = util stack threads #aio 
-V ?= @
-
-GCCPREFIX ?= $(TARGET_ARCH)-ros-
-CC := $(GCCPREFIX)gcc
-GCC_ROOT := $(shell which $(CC) | xargs dirname)/../
 
 SRCDIR := 
 OBJDIR := $(SRCDIR)obj
@@ -33,6 +28,7 @@ MAKEFRAGS := $(foreach x, $(SUBDIRS), $(call makefragname,$(x)))
 LIBUCNAME := $(call uc, $(LIBNAME))
 
 all: $(FINALLIB)
+       @:
 
 include $(MAKEFRAGS)
 ALLOBJS = $(foreach x, $(SUBDIRS), $(wildcard $(OBJDIR)/$(x)/*.o))
@@ -41,15 +37,15 @@ ALLLIBS = $(foreach x, $(SUBDIRS), $(call libname,$(x)))
 $(FINALLIB): $(ALLLIBS)
        @echo + ar [$(LIBUCNAME)] $@
        @mkdir -p $(@D)
-       $(V)$(AR) rc $@ $(ALLOBJS)
+       $(Q)$(AR) rc $@ $(ALLOBJS)
 
 install: $(FINALLIB)
-       cp $(FINALLIB) $(GCC_ROOT)/$(TARGET_ARCH)-ros/lib/
-       mkdir -p $(GCC_ROOT)/$(TARGET_ARCH)-ros/include/$(LIBNAME)
-       cp -R $(INCDIR)/* $(GCC_ROOT)/$(TARGET_ARCH)-ros/include/$(LIBNAME)
+       @cp $(FINALLIB) $(XCC_ROOT)/$(ARCH)-ros/lib/
+       @mkdir -p $(XCC_ROOT)/$(ARCH)-ros/include/$(LIBNAME)
+       @cp -R $(INCDIR)/* $(XCC_ROOT)/$(ARCH)-ros/include/$(LIBNAME)
 
 clean: $(CLEANS)
        @echo + clean [$(LIBUCNAME)]
-       $(V)rm -rf $(FINALLIB)
-       $(V)rm -rf $(OBJDIR)
+       $(Q)rm -rf $(FINALLIB)
+       $(Q)rm -rf $(OBJDIR)
        
index cbb7456..040a53d 100644 (file)
@@ -1,6 +1,6 @@
 STACK_NAME    := stack
 STACK_UCNAME  := $(call uc, $(STACK_NAME))
-STACK_CFLAGS  := $(CFLAGS)
+STACK_CFLAGS  := $(CFLAGS_USER)
 STACK_HEADERS := $(wildcard $(STACKDIR)/*.h)
 STACK_CFILES  := $(wildcard $(STACKDIR)/*.c)
 STACK_OBJDIR  := $(OBJDIR)/$(STACK_NAME)
@@ -11,15 +11,15 @@ LIBSTACK = $(STACK_OBJDIR)/lib$(STACK_NAME).a
 
 $(STACK_NAME)-clean:
        @echo + clean [$(LIBUCNAME) $(STACK_UCNAME)]
-       $(V)rm -rf $(STACK_OBJS) $(LIBSTACK)
-       $(V)rm -rf $(STACK_OBJDIR)
+       $(Q)rm -rf $(STACK_OBJS) $(LIBSTACK)
+       $(Q)rm -rf $(STACK_OBJDIR)
 
 $(LIBSTACK): $(STACK_OBJS)
        @echo + ar [$(LIBUCNAME) $(STACK_UCNAME)] $@
-       $(V)$(AR) rc $@ $^
+       $(Q)$(AR) rc $@ $^
 
 $(STACK_OBJDIR)/%.o: $(STACKDIR)/%.c $(STACK_HEADERS)
        @echo + cc [$(LIBUCNAME) $(STACK_UCNAME)] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(STACK_CFLAGS) $(INCS) -o $@ -c $<
+       $(Q)$(CC) $(STACK_CFLAGS) $(INCS) -o $@ -c $<
 
index 886de6c..f801db4 100644 (file)
@@ -1,6 +1,6 @@
 THREADS_NAME    := threads
 THREADS_UCNAME  := $(call uc, $(THREADS_NAME))
-THREADS_CFLAGS  := $(CFLAGS)
+THREADS_CFLAGS  := $(CFLAGS_USER)
 THREADS_HEADERS := $(wildcard $(THREADSDIR)/*.h)
 THREADS_CFILES  := $(wildcard $(THREADSDIR)/*.c)
 THREADS_OBJDIR  := $(OBJDIR)/$(THREADS_NAME)
@@ -11,15 +11,15 @@ LIBTHREADS = $(THREADS_OBJDIR)/lib$(THREADS_NAME).a
 
 $(THREADS_NAME)-clean:
        @echo + clean [$(LIBUCNAME) $(THREADS_UCNAME)]
-       $(V)rm -rf $(THREADS_OBJS) $(LIBTHREADS)
-       $(V)rm -rf $(THREADS_OBJDIR)
+       $(Q)rm -rf $(THREADS_OBJS) $(LIBTHREADS)
+       $(Q)rm -rf $(THREADS_OBJDIR)
 
 $(LIBTHREADS): $(THREADS_OBJS)
        @echo + ar [$(LIBUCNAME) $(THREADS_UCNAME)] $@
-       $(V)$(AR) rc $@ $^
+       $(Q)$(AR) rc $@ $^
 
 $(THREADS_OBJDIR)/%.o: $(THREADSDIR)/%.c $(THREADS_HEADERS)
        @echo + cc [$(LIBUCNAME) $(THREADS_UCNAME)] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(THREADS_CFLAGS) $(INCS) -o $@ -c $<
+       $(Q)$(CC) $(THREADS_CFLAGS) $(INCS) -o $@ -c $<
 
index d48814c..f8d1395 100644 (file)
@@ -1,6 +1,6 @@
 UTIL_NAME    := util
 UTIL_UCNAME  := $(call uc, $(UTIL_NAME))
-UTIL_CFLAGS  := $(CFLAGS)
+UTIL_CFLAGS  := $(CFLAGS_USER)
 UTIL_HEADERS := $(wildcard $(UTILDIR)/*.h)
 UTIL_CFILES  := $(wildcard $(UTILDIR)/*.c)
 UTIL_OBJDIR  := $(OBJDIR)/$(UTIL_NAME)
@@ -11,15 +11,15 @@ LIBUTIL = $(UTIL_OBJDIR)/lib$(UTIL_NAME).a
 
 $(UTIL_NAME)-clean:
        @echo + clean [$(LIBUCNAME) $(UTIL_UCNAME)]
-       $(V)rm -rf $(UTIL_OBJS) $(LIBUTIL)
-       $(V)rm -rf $(UTIL_OBJDIR)
+       $(Q)rm -rf $(UTIL_OBJS) $(LIBUTIL)
+       $(Q)rm -rf $(UTIL_OBJDIR)
 
 $(LIBUTIL): $(UTIL_OBJS)
        @echo + ar [$(LIBUCNAME) $(UTIL_UCNAME)] $@
-       $(V)$(AR) rc $@ $^
+       $(Q)$(AR) rc $@ $^
 
 $(UTIL_OBJDIR)/%.o: $(UTILDIR)/%.c $(UTIL_HEADERS)
        @echo + cc [$(LIBUCNAME) $(UTIL_UCNAME)] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(UTIL_CFLAGS) $(INCS) -o $@ -c $<
+       $(Q)$(CC) $(UTIL_CFLAGS) $(INCS) -o $@ -c $<
 
index 5abde99..15596f9 100644 (file)
@@ -1,11 +1,6 @@
-TARGET_ARCH ?= none    # catch bugs
-CFLAGS = -O2 -std=gnu99 -static -fomit-frame-pointer -g
+ARCH ?= none   # catch bugs
+CFLAGS_USER += -static -fomit-frame-pointer -g
 LIBNAME = parlib
-V ?= @
-
-GCCPREFIX := $(TARGET_ARCH)-ros-
-CC := $(GCCPREFIX)gcc
-GCC_ROOT := $(shell which $(CC) | xargs dirname)/../
 
 SRCDIR := 
 OBJDIR := $(SRCDIR)obj
@@ -19,36 +14,37 @@ uc = $(shell echo $(1) | tr a-z A-Z)
 LIBUCNAME := $(call uc, $(LIBNAME))
 HEADERS := $(shell find $(INCDIR) -name *.h)
 CFILES  := $(wildcard $(SRCDIR)*.c)
-CFILES  += $(wildcard $(SRCDIR)$(TARGET_ARCH)/*.c)
-SFILES  := $(wildcard $(SRCDIR)$(TARGET_ARCH)/*.S)
+CFILES  += $(wildcard $(SRCDIR)$(ARCH)/*.c)
+SFILES  := $(wildcard $(SRCDIR)$(ARCH)/*.S)
 OBJS    := $(patsubst %.c, $(OBJDIR)/%.o, $(CFILES)) \
            $(patsubst %.S, $(OBJDIR)/%.o, $(SFILES))
 
 all: $(FINALLIB)
+       @:
 
-$(OBJDIR)/$(TARGET_ARCH)/%.o: $(SRCDIR)$(TARGET_ARCH)/%.S $(HEADERS)
+$(OBJDIR)/$(ARCH)/%.o: $(SRCDIR)$(ARCH)/%.S $(HEADERS)
        @echo + as [$(LIBUCNAME)] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(CFLAGS) $(INCS) -o $@ -c $<
+       $(Q)$(CC) $(CFLAGS_USER) $(INCS) -o $@ -c $<
 
 $(OBJDIR)/%.o: $(SRCDIR)%.c $(HEADERS)
        @echo + cc [$(LIBUCNAME)] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(CFLAGS) $(INCS) -o $@ -c $<
+       $(Q)$(CC) $(CFLAGS_USER) $(INCS) -o $@ -c $<
 
 $(FINALLIB): $(OBJS)
        @echo + ar [$(LIBUCNAME)] $@
        @mkdir -p $(@D)
-       $(V)$(AR) rc $@ $(OBJS)
+       $(Q)$(AR) rc $@ $(OBJS)
 
 install: $(FINALLIB)
-       cp $(FINALLIB) $(GCC_ROOT)/$(TARGET_ARCH)-ros/lib/
-       cp -R $(INCDIR)/* $(GCC_ROOT)/$(TARGET_ARCH)-ros/sys-include/
-       rm -rf $(GCC_ROOT)/$(TARGET_ARCH)-ros/sys-include/parlib  
-       ln -fs . $(GCC_ROOT)/$(TARGET_ARCH)-ros/sys-include/parlib  
+       @cp $(FINALLIB) $(XCC_ROOT)/$(ARCH)-ros/lib/
+       @cp -R $(INCDIR)/* $(XCC_ROOT)/$(ARCH)-ros/sys-include/
+       @rm -rf $(XCC_ROOT)/$(ARCH)-ros/sys-include/parlib  
+       @ln -fs . $(XCC_ROOT)/$(ARCH)-ros/sys-include/parlib  
 
 clean: 
        @echo + clean [$(LIBUCNAME)]
-       $(V)rm -rf $(FINALLIB)
-       $(V)rm -rf $(OBJDIR)
+       $(Q)rm -rf $(FINALLIB)
+       $(Q)rm -rf $(OBJDIR)
        
index 72e43d0..87bdc37 100644 (file)
@@ -1,11 +1,6 @@
-TARGET_ARCH ?= i686
-CFLAGS = -O2 -std=gnu99 -static -fomit-frame-pointer -g
+ARCH ?= none # catch bugs
+CFLAGS_USER += -static -fomit-frame-pointer -g
 LIBNAME = pthread
-V ?= @
-
-GCCPREFIX := $(TARGET_ARCH)-ros-
-CC := $(GCCPREFIX)gcc
-GCC_ROOT := $(shell which $(CC) | xargs dirname)/../
 
 SRCDIR := 
 OBJDIR := $(SRCDIR)obj
@@ -22,24 +17,24 @@ CFILES  := $(wildcard $(SRCDIR)*.c)
 OBJS    := $(patsubst %.c, $(OBJDIR)/%.o, $(CFILES))
 
 all: $(FINALLIB)
-
+       @:
 
 $(OBJDIR)/%.o: $(SRCDIR)%.c $(HEADERS)
        @echo + cc [$(LIBUCNAME)] $<
        @mkdir -p $(@D)
-       $(V)$(CC) $(CFLAGS) $(INCS) -o $@ -c $<
+       $(Q)$(CC) $(CFLAGS_USER) $(INCS) -o $@ -c $<
 
 $(FINALLIB): $(OBJS)
        @echo + ar [$(LIBUCNAME)] $@
        @mkdir -p $(@D)
-       $(V)$(AR) rc $@ $(OBJS)
+       $(Q)$(AR) rc $@ $(OBJS)
 
 install: $(FINALLIB)
-       cp $(FINALLIB) $(GCC_ROOT)/$(TARGET_ARCH)-ros/lib/
-       cp -R $(INCDIR)/*.h $(GCC_ROOT)/$(TARGET_ARCH)-ros/sys-include/
+       @cp $(FINALLIB) $(XCC_ROOT)/$(ARCH)-ros/lib/
+       @cp -R $(INCDIR)/*.h $(XCC_ROOT)/$(ARCH)-ros/sys-include/
 
 clean: 
        @echo + clean [$(LIBUCNAME)]
-       $(V)rm -rf $(FINALLIB)
-       $(V)rm -rf $(OBJDIR)
+       $(Q)rm -rf $(FINALLIB)
+       $(Q)rm -rf $(OBJDIR)