Dentry cache
[akaros.git] / GNUmakefile
index f523406..716c468 100644 (file)
@@ -21,9 +21,9 @@ $(TARGET_ARCH):
        @if [ "$(ARCH_LINK)" != "$@" ];\
        then\
          $(MAKE) realclean;\
-         $(MAKE) realall -j;\
+         $(MAKE) realall -j $(MAKE_JOBS);\
        else\
-         $(MAKE) all -j;\
+         $(MAKE) all -j $(MAKE_JOBS);\
        fi
 
 ############################################################################# 
@@ -38,11 +38,18 @@ 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
+
 # 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 := .
+TOP_DIR := $(shell pwd)
 ARCH_DIR := $(TOP_DIR)/kern/arch
 INCLUDE_DIR := $(TOP_DIR)/kern/include
 DOXYGEN_DIR := $(TOP_DIR)/Documentation/doxygen
@@ -80,16 +87,17 @@ endif
 endif
 
 # Default programs for compilation
+USER_CFLAGS += -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
+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 
@@ -101,6 +109,7 @@ 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
@@ -113,10 +122,10 @@ 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.
-CFLAGS := $(CFLAGS) -D$(TARGET_ARCH) $(EXTRAARGS)
-CFLAGS += -O2 -pipe -MD -fno-builtin -gstabs
-CFLAGS += -Wall -Wno-format -Wno-unused -fno-strict-aliasing
-CFLAGS += -nostdinc -I$(dir $(GCC_LIB))/include
+KERN_CFLAGS += -D$(TARGET_ARCH) $(EXTRAARGS)
+KERN_CFLAGS += -O2 -pipe -MD -fno-builtin -gstabs
+KERN_CFLAGS += -Wall -Wno-format -Wno-unused -fno-strict-aliasing
+KERN_CFLAGS += -nostdinc -I$(dir $(GCC_LIB))/include
 
 # Universal loader flags
 LDFLAGS := -nostdlib
@@ -124,6 +133,9 @@ LDFLAGS := -nostdlib
 # List of directories that the */Makefrag makefile fragments will add to
 OBJDIRS :=
 
+# List of directories that the */Makefrag makefile fragments will add to
+ROS_USER_LIBS :=
+
 ROS_ARCH_DIR ?= $(TARGET_ARCH)
 
 arch:
@@ -132,18 +144,32 @@ arch:
 symlinks: error
        ln -fs ../arch/$(ROS_ARCH_DIR) kern/include/arch
        ln -fs arch/$(ROS_ARCH_DIR)/boot kern/boot
-       @$(MAKE) -j all
+       ln -fs $(ROS_ARCH_DIR) user/include/arch
+       @$(MAKE) -j $(MAKE_JOBS) all
 
 # Include Makefrags for subdirectories
 ifneq ($(TARGET_ARCH),)
-include kern/Makefrag
 include user/Makefrag
 include tests/Makefrag
+include kern/Makefrag
 endif
 
-tests: $(TESTS_EXECS)
-       @mkdir -p fs/$(TARGET_ARCH)/tests
-       cp -R $(OBJDIR)/$(TESTS_DIR)/* fs/$(TARGET_ARCH)/tests
+ifeq ($(GCCPREFIX),$(TARGET_ARCH)-ros-)
+GCC_ROOT := $(shell which $(GCCPREFIX)gcc | xargs dirname)/../
+tests/: tests
+tests:
+       @$(MAKE) -j $(MAKE_JOBS) realtests
+realtests: $(TESTS_EXECS)
+# 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
+
+install-libs: $(ROS_USER_LIBS)
+       cp $(ROS_USER_LIBS) $(GCC_ROOT)/$(TARGET_ARCH)-ros/lib
+       cp $(ROS_USER_LIBS) $(TOP_DIR)/fs/$(TARGET_ARCH)/lib
+       cp -R $(USER_DIR)/include/* $(GCC_ROOT)/$(TARGET_ARCH)-ros/include
+.PHONY: tests
+endif
 
 # Eliminate default suffix rules
 .SUFFIXES:
@@ -175,6 +201,9 @@ doxyclean:
        rm -rf $(DOXYGEN_DIR)/rosdoc
 
 # For deleting the build
+userclean:
+       @rm -rf $(OBJDIR)/user
+       
 clean:
        @rm -rf $(OBJDIR)
        @echo All clean and pretty!
@@ -182,6 +211,7 @@ clean:
 realclean: clean
        @rm -f kern/boot
        @rm -f kern/include/arch
+       @rm -f user/include/arch
 
 always:
        @: