Pthread: stop accessing memory after it was freed
[akaros.git] / GNUmakefile
index 8009111..7dfd0bb 100644 (file)
@@ -1,6 +1,9 @@
 # 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 #########
 ############################################################################# 
@@ -33,20 +36,24 @@ $(TARGET_ARCH):
 # Default values for configurable Make system variables
 COMPILER := GCC
 OBJDIR := obj
-V := @
+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 := 
+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 := .
+TOP_DIR := $(shell pwd)
 ARCH_DIR := $(TOP_DIR)/kern/arch
 INCLUDE_DIR := $(TOP_DIR)/kern/include
 DOXYGEN_DIR := $(TOP_DIR)/Documentation/doxygen
@@ -84,7 +91,7 @@ endif
 endif
 
 # Default programs for compilation
-USER_CFLAGS += -O2
+USER_CFLAGS += -O2 -std=gnu99
 ifeq ($(COMPILER),IVY)
 KERN_CFLAGS += --deputy \
                --no-rc-sharc \
@@ -130,9 +137,6 @@ 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:
@@ -141,12 +145,11 @@ 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/include/arch
+       ln -fs $(ROS_ARCH_DIR) user/parlib/include/arch
        @$(MAKE) -j $(MAKE_JOBS) all
 
 # Include Makefrags for subdirectories
 ifneq ($(TARGET_ARCH),)
-include user/Makefrag
 include tests/Makefrag
 include kern/Makefrag
 endif
@@ -154,16 +157,33 @@ endif
 ifeq ($(GCCPREFIX),$(TARGET_ARCH)-ros-)
 GCC_ROOT := $(shell which $(GCCPREFIX)gcc | xargs dirname)/../
 tests/: tests
-tests:
+tests: install-libs
        @$(MAKE) -j $(MAKE_JOBS) realtests
 realtests: $(TESTS_EXECS)
-       @mkdir -p fs/$(TARGET_ARCH)/tests
-       cp -R $(OBJDIR)/$(TESTS_DIR)/* $(TOP_DIR)/fs/$(TARGET_ARCH)/tests
+# 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 c3po
+install-libs: 
+       @for i in $(USER_LIBS) ; do \
+               cd user/$$i;            \
+               $(MAKE);                \
+               $(MAKE) install;        \
+               cd ../..;               \
+       done
+
+fill-kfs: install-libs
+       @rm -rf $(FIRST_INITRAMFS_PATH)/lib
+       @cp -R $(GCC_ROOT)/$(TARGET_ARCH)-ros/lib $(FIRST_INITRAMFS_PATH)
 
-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
+userclean:
+       @for i in $(USER_LIBS) ; do \
+               cd user/$$i;            \
+               $(MAKE) clean;          \
+               cd ../..;               \
+       done
+       @rm -rf $(OBJDIR)/$(TESTS_DIR)
 .PHONY: tests
 endif
 
@@ -196,10 +216,6 @@ docs:
 doxyclean:
        rm -rf $(DOXYGEN_DIR)/rosdoc
 
-# For deleting the build
-userclean:
-       @rm -rf $(OBJDIR)/user
-       
 clean:
        @rm -rf $(OBJDIR)
        @echo All clean and pretty!
@@ -207,7 +223,7 @@ clean:
 realclean: clean
        @rm -f kern/boot
        @rm -f kern/include/arch
-       @rm -f user/include/arch
+       @rm -f user/parlib/include/arch
 
 always:
        @: