1 # Top-level Makefile for Akaros
6 # - I downloaded the kbuild guts from git://github.com/lacombar/kconfig.git,
7 # and added things from a recent linux makefile. It is from aug 2011, so
8 # some things might not match up.
9 # - Kernel output in obj/: So Linux has the ability to output into another
10 # directory, via the KBUILD_OUTPUT variable. This induces a recursive make
11 # in the output directory. I mucked with it for a little, but didn't get it
12 # to work quite right. Also, there will be other Akaros issues since this
13 # makefile is also used for userspace and tests. For now, I'm leaving things
14 # the default Linux way.
15 # - Kconfig wants to use include/ in the root directory. We can change some
16 # of the default settings that silentoldconfig uses, but I'll leave it as-is
17 # for now, and just symlink that into kern/include. It'll be easier for us,
18 # and also potentially easier if we ever move kern/ up a level. Similarly,
19 # there are default Kconfigs in arch/, not in kern/arch. I just symlinked
20 # arch->kern/arch to keep everything simple.
23 # - Consider merging the two target-detection bits (Linux's config, mixed, or
24 # dot target, and the symlink handling). Also, could consider moving around
25 # the KFS and EXT2 targets. Clean doesn't need to know about them, for
28 # - Review, with an eye for being better about $(srctree). It might only be
29 # necessary in this file, if we every do the KBUILD_OUTPUT option. But we
30 # don't always want it (like for the implicit rule for Makefile)
32 # - It's a bit crazy that we build symlinks for parlib, instead of it
33 # managing its own links based on $(ARCH)
35 # - Consider using Kbuild to build userspace and tests
37 # - There are a few other TODOs sprinkled throughout the makefile.
39 # Allow people to override our setting of the --no-print-directory option in
40 # their Makelocal. This is useful, for example, to allow emacs to find the
41 # correct file when errors are encountered using its builtin 'M-x compile'
49 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
51 export KERNELVERSION VERNAME
53 NO_PRINT_DIRECTORY ?= --no-print-directory
55 # Save the ability to export the parent's original environment for future use
56 export_parent_env := $(shell export | sed 's/$$/;/')
58 # Save the ability to clear the current environment for future use
59 clear_current_env := for c in $$(env | cut -d '=' -f 1); do unset $$c; done;
61 define export_user_variables
62 CROSS_COMPILE="$(CROSS_COMPILE)"\
63 CROSS_INCLUDE="$(XCC_TARGET_INCLUDE)"\
64 ROS_CFLAGS="$(CFLAGS_USER)"\
65 ROS_LDFLAGS="$(LDFLAGS_USER)"
68 # Define a set of commands to reset the environment to the parent's environment
69 # and then run a local make target
73 $(call export_user_variables)\
74 $(MAKE) $(NO_PRINT_DIRECTORY) $(1)
78 # o use make's built-in rules and variables
79 # (this increases performance and avoids hard-to-debug behaviour);
80 # o print "Entering directory ...";
81 MAKEFLAGS += -rR $(NO_PRINT_DIRECTORY)
83 # That's our default target when none is given on the command line
84 # This can be overriden with a Makelocal
88 # Export the location of this top level directory
89 AKAROS_ROOT = $(CURDIR)
92 # Setup dumping ground for object files and any temporary files we need to
93 # generate for non-kbuild targets
96 # Don't need to export these, since the Makelocal is included.
97 KERNEL_OBJ := $(OBJDIR)/kern/akaros-kernel
98 CMP_KERNEL_OBJ := $(KERNEL_OBJ).gz
101 # =========================================================================
102 # We have a few symlinks so that code can include <arch/whatever.h>. This
103 # section builds and maintains those, as best we can.
105 # When invoking make, we can pass in ARCH=some-arch. This value gets 'saved'
106 # in the symlink, so that later invocations do not need ARCH=. If this value
107 # differs from the symlink, it appears like we are changing arches, which
108 # triggers a clean and symlink reconstruction.
110 # When the user changes from one arch to another, they ought to reconfig, since
111 # many of the CONFIG_ vars will depend on the arch. If they try anything other
112 # than one of the "non-build-goals" (cleans or configs), we'll abort.
114 # Make targets that need these symlinks (like building userspace, the kernel,
115 # configs, etc, should depend on symlinks.
117 clean-goals := clean mrproper realclean userclean testclean doxyclean objclean
118 non-build-goals := %config $(clean-goals)
119 ifeq ($(filter $(non-build-goals), $(MAKECMDGOALS)),)
120 goals-has-build-targets := 1
123 PHONY += symlinks clean_symlinks
124 clean_symlinks: objclean
125 @rm -f kern/include/arch kern/boot user/parlib/include/parlib/arch
127 arch-link := $(notdir $(shell readlink kern/include/arch))
128 valid-arches := $(notdir $(wildcard kern/arch/*))
131 ifeq ($(filter $(valid-arches), $(ARCH)),)
132 $(error ARCH $(ARCH) invalid, must be one of: $(valid-arches))
134 ifneq ($(ARCH),$(arch-link))
135 ifeq ($(goals-has-build-targets),1)
136 $(error Attempted to make [$(MAKECMDGOALS)] while changing ARCH. \
137 You need to make *config.)
139 symlinks: clean_symlinks
140 @echo Making symlinks...
141 $(Q)ln -fs ../arch/$(ARCH) kern/include/arch
142 $(Q)ln -fs arch/$(ARCH)/boot kern/boot
143 $(Q)ln -fs $(ARCH) user/parlib/include/parlib/arch
144 $(Q)$(MAKE) -f $(srctree)/Makefile clean
149 endif # ifneq ($(ARCH),$(arch-link))
150 else # $(ARCH) is empty
151 ifneq ($(arch-link),)
157 ifeq ($(filter $(clean-goals), $(MAKECMDGOALS)),)
158 $(error No arch saved or specified. Make *config with ARCH=arch. \
159 'arch' must be one of: $(valid-arches))
161 ARCH := none # catch bugs
162 endif # ifneq ($(arch-link),)
163 endif # ifeq ($(ARCH),)
168 # Generic Kbuild Environment
169 # =========================================================================
171 # To put more focus on warnings, be less verbose as default
172 # Use 'make V=1' to see the full commands
174 ifeq ("$(origin V)", "command line")
175 KBUILD_VERBOSE = $(V)
177 ifndef KBUILD_VERBOSE
181 srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
184 export srctree objtree
186 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
187 else if [ -x /bin/bash ]; then echo /bin/bash; \
188 else echo sh; fi ; fi)
192 HOSTCFLAGS = -Wall -Wno-char-subscripts -Wmissing-prototypes \
193 -Wstrict-prototypes -O2 -fomit-frame-pointer
196 export CONFIG_SHELL HOSTCC HOSTCXX HOSTCFLAGS HOSTCXXFLAGS
199 # ---------------------------------------------------------------------------
201 # Normally, we echo the whole command before executing it. By making
202 # that echo $($(quiet)$(cmd)), we now have the possibility to set
203 # $(quiet) to choose other forms of output instead, e.g.
205 # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
206 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
208 # If $(quiet) is empty, the whole command will be printed.
209 # If it is set to "quiet_", only the short version will be printed.
210 # If it is set to "silent_", nothing will be printed at all, since
211 # the variable $(silent_cmd_cc_o_c) doesn't exist.
213 # A simple variant is to prefix commands with $(Q) - that's useful
214 # for commands that shall be hidden in non-verbose mode.
218 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
219 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
221 ifeq ($(KBUILD_VERBOSE),1)
228 export quiet Q KBUILD_VERBOSE
230 # We need some generic definitions (do not try to remake the file).
231 $(srctree)/scripts/Kbuild.include: ;
232 include $(srctree)/scripts/Kbuild.include
234 # Kbuild Target/Goals Parsing
235 # =========================================================================
236 # Need to figure out if we're a config or not, and whether or not to include
237 # our .config / auto.conf. Configs are basically their own makefile, (ifeq),
238 # and cleans are allowed to proceed without worrying about the dot-config.
240 # Basic helpers built in scripts/
241 PHONY += scripts_basic
243 $(Q)$(MAKE) $(build)=scripts/basic
247 scripts: scripts_basic include/config/auto.conf include/config/tristate.conf
248 $(Q)$(MAKE) $(build)=$(@)
254 no-dot-config-targets := $(clean-goals)
256 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
257 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
262 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
264 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
269 ifeq ($(mixed-targets),1)
270 # ===========================================================================
271 # We're called with mixed targets (*config and build targets).
272 # Handle them one by one.
275 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
278 ifeq ($(config-targets),1)
279 # ===========================================================================
280 # *config targets only - make sure prerequisites are updated, and descend
281 # in scripts/kconfig to make the *config target
283 # Default config file, per arch. This path will resolve to
284 # arch/$ARCH/configs/defconfig (arch -> kern/arch). Each arch can override
285 # this if they want, or just symlink to one in the main root directory.
286 KBUILD_DEFCONFIG := defconfig
287 export KBUILD_DEFCONFIG
289 config: scripts_basic symlinks FORCE
290 $(Q)mkdir -p include/config
291 $(Q)$(MAKE) $(build)=scripts/kconfig $@
293 %config: scripts_basic symlinks FORCE
294 $(Q)mkdir -p include/config
295 $(Q)$(MAKE) $(build)=scripts/kconfig $@
298 # ===========================================================================
299 # Build targets only - this includes vmlinux, arch specific targets, clean
300 # targets and others. In general all targets except *config targets.
302 ifeq ($(dot-config),1)
303 KCONFIG_CONFIG ?= .config
304 export KCONFIG_CONFIG
307 -include include/config/auto.conf
309 # Read in dependencies to all Kconfig* files, make sure to run
310 # oldconfig if changes are detected.
311 -include include/config/auto.conf.cmd
313 # To avoid any implicit rule to kick in, define an empty command
314 $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
316 # If .config is newer than include/config/auto.conf, someone tinkered
317 # with it and forgot to run make oldconfig.
318 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
319 # we execute the config step to be sure to catch updated Kconfig files
320 include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
321 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
324 # Dummy target needed, because used as prerequisite
325 include/config/auto.conf: ;
326 endif # $(dot-config)
328 # Akaros Build Environment
329 # =========================================================================
330 AKAROSINCLUDE := -I$(srctree)/kern/include/
332 # CROSS_COMPILE is defined per-arch. Each arch can set other makeflags, kbuild
334 -include $(srctree)/kern/arch/$(ARCH)/Makefile
336 CC := $(CROSS_COMPILE)gcc
337 CPP := $(CROSS_COMPILE)g++
338 AS := $(CROSS_COMPILE)as
339 AR := $(CROSS_COMPILE)ar
340 LD := $(CROSS_COMPILE)ld
341 OBJCOPY := $(CROSS_COMPILE)objcopy
342 OBJDUMP := $(CROSS_COMPILE)objdump
343 NM := $(CROSS_COMPILE)nm
344 STRIP := $(CROSS_COMPILE)strip
345 KERNEL_LD ?= kernel.ld
347 # These may have bogus values if there is no compiler. The kernel and user
348 # build targets will check cc-exists. Hopefully no cleaning targets rely on
349 # these. Note that if you change configs, these will get computed once, before
350 # silentoldconfig kicks in to regenerate auto.conf, and these values will
351 # temporarily be stale.
352 gcc-lib := $(shell $(CC) -print-libgcc-file-name 2>/dev/null)
353 NOSTDINC_FLAGS += -nostdinc -isystem \
354 $(shell $(CC) -print-file-name=include 2>/dev/null)
355 XCC_TARGET_ROOT := $(shell $(CC) --print-sysroot 2> /dev/null)
356 XCC_TARGET_LIB := $(XCC_TARGET_ROOT)/usr/lib/
357 XCC_TARGET_INCLUDE := $(XCC_TARGET_ROOT)/usr/include/
359 CFLAGS_KERNEL += -O2 -pipe -MD
360 CFLAGS_KERNEL += -std=gnu99 -fgnu89-inline
361 CFLAGS_KERNEL += -fno-strict-aliasing -fno-omit-frame-pointer
362 CFLAGS_KERNEL += -fno-stack-protector
363 CFLAGS_KERNEL += -Wall -Wno-format -Wno-unused -Werror
364 CFLAGS_KERNEL += -DROS_KERNEL
365 CFLAGS_KERNEL += -include include/generated/autoconf.h -include include/common.h
366 CFLAGS_KERNEL += -fplan9-extensions
367 ifeq ($(CONFIG_64BIT),y)
368 CFLAGS_KERNEL += -m64 -g
370 CFLAGS_KERNEL += -m32 -gstabs
373 # TODO: do we need this, or can we rely on the compiler's defines?
374 CFLAGS_KERNEL += -D$(ARCH)
376 # TODO: this requires our own strchr (kern/src/stdio.c), which is a potential
377 # source of bugs/problems.
378 # note we still pull in stdbool and stddef from the compiler
379 CFLAGS_KERNEL += -fno-builtin
381 AFLAGS_KERNEL := $(CFLAGS_KERNEL)
386 export AKAROSINCLUDE CROSS_COMPILE
387 export CC CPP AS AR LD OBJCOPY OBJDUMP NM STRIP
388 export CFLAGS_KERNEL AFLAGS_KERNEL
389 export NOSTDINC_FLAGS XCC_TARGET_ROOT XCC_TARGET_LIB XCC_TARGET_INCLUDE
390 export KBUILD_BUILTIN KBUILD_CHECKSRC
392 CFLAGS_USER += -O2 -std=gnu99 -fno-stack-protector -fgnu89-inline \
395 CFLAGS_USER_LIBS += -fPIC -static -fno-omit-frame-pointer -g
397 export CFLAGS_USER CXXFLAGS_USER CFLAGS_USER_LIBS
399 # Akaros include stuff (includes custom make targets and user overrides)
400 # =========================================================================
402 # The user can override this, though it won't apply for any of the in-tree
403 # kernel build output. Right now, it's only passed down to tests/
404 dummy-1 := $(shell mkdir -p $(OBJDIR)/kern/)
406 # Machinery to create the kernel build info source
407 export BUILD_INFO_FILE
409 # Since we're doing this outside of the dot-config part, some targets, such as
410 # clean, won't read in our .config/auto.conf, and won't know about the
411 # KFS_PATH. Future rules related to KFS will have issues (mkdir with no
412 # argument, or a find of the entire pwd). It's also possible someone provided
413 # an empty path. To deal with both, we'll just have a sensible default.
414 kfs-paths := $(subst $\",,$(CONFIG_KFS_PATHS))
416 kfs-paths := kern/kfs
419 FIRST_KFS_PATH = $(firstword $(kfs-paths))
420 ABS_KFS_PATH = $(abspath $(FIRST_KFS_PATH))
422 export OBJDIR FIRST_KFS_PATH ABS_KFS_PATH
424 # Avoiding implicit rules
425 $(srctree)/Makelocal: ;
426 # TODO: one issue is that we import all types of targets: build, clean, etc.
427 # That makes it a bit tougher to reorganize with ifeqs.
428 -include $(srctree)/Makelocal
430 # Akaros Kernel Build
431 # =========================================================================
432 # Add top level directories, either to an existing entry (core-y) or to its
435 # From these, we determine deps and dirs. We recursively make through the
436 # dirs, generating built-in.o at each step, which are the deps from which we
439 # We have all-arch-dirs and all-dirs, so that we can still clean even without
442 core-y += kern/src/ kern/drivers/ kern/lib/ $(AKAROS_EXTERNAL_DIRS)
443 arch-y += kern/arch/$(ARCH)/
445 akaros-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(arch-y)))
447 all-arch-dirs := $(patsubst %,kern/arch/%/,$(valid-arches))
448 akaros-all-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(all-arch-dirs)))
450 core-y := $(patsubst %/, %/built-in.o, $(core-y))
451 arch-y := $(patsubst %/, %/built-in.o, $(arch-y))
453 kbuild_akaros_main := $(core-y) $(arch-y)
454 akaros-deps := $(kbuild_akaros_main) kern/arch/$(ARCH)/$(KERNEL_LD)
456 kern_cpio := $(OBJDIR)/kern/initramfs.cpio
457 kern_cpio_obj := $(kern_cpio).o
459 # ext2 will crash at runtime if we don't have a block device. try to catch the
460 # errors now. if it is a bad one, you're just out of luck.
461 ifneq ($(CONFIG_EXT2FS),)
462 ext2-bdev := $(patsubst "%",%,$(CONFIG_EXT2_BDEV))
464 $(error EXT2 selected with no block device [$(ext2-bdev)], fix your .config)
466 ext2_bdev_obj = $(OBJDIR)/kern/$(shell basename $(ext2-bdev)).o
469 # a bit hacky: we want to make sure the directories exist, and error out
470 # otherwise. we also want to error out before the initramfs target, otherwise
471 # we might not get the error (if initramfs files are all up to date). the
472 # trickiest thing here is that kfs-paths-check could be stale and require an
473 # oldconfig. running make twice should suffice.
474 kfs-paths-check := $(shell for i in $(kfs-paths); do \
475 if [ ! -d "$$i" ]; then \
476 echo "Can't find KFS directory $$i"; \
477 $(MAKE) -f $(srctree)/Makefile \
478 silentoldconfig > /dev/null; \
483 ifneq (ok,$(kfs-paths-check))
484 $(error $(kfs-paths-check), try make one more time in case of stale configs)
487 kern_initramfs_files := $(shell find $(kfs-paths))
489 # Need to make an empty cpio, then append each kfs-path's contents
490 $(kern_cpio) initramfs: $(kern_initramfs_files)
491 @echo " Building initramfs:"
492 @if [ "$(CONFIG_KFS_CPIO_BIN)" != "" ]; then \
493 sh $(CONFIG_KFS_CPIO_BIN); \
495 @cat /dev/null | cpio --quiet -oH newc -O $(kern_cpio)
496 $(Q)for i in $(kfs-paths); do cd $$i; \
497 echo " Adding $$i to initramfs..."; \
498 find -L . | cpio --quiet -oAH newc -O $(CURDIR)/$(kern_cpio); \
502 ld_emulation = $(shell $(OBJDUMP) -i 2>/dev/null | \
503 grep -v BFD | grep ^[a-z] | head -n1)
504 ld_arch = $(shell $(OBJDUMP) -i 2>/dev/null |\
505 grep -v BFD | grep "^ [a-z]" | head -n1)
507 # Our makefile doesn't detect a change in subarch, and old binary objects that
508 # don't need to be updated won't get rebuilt, but they also can't link with the
509 # new subarch (32 bit vs 64 bit). If we detect the wrong type, we'll force a
511 existing-cpio-emul := $(shell objdump -f $(kern_cpio_obj) 2> /dev/null | \
512 grep format | sed 's/.*format //g')
513 ifneq ($(existing-cpio-emul),)
514 ifneq ($(existing-cpio-emul),$(ld_emulation))
515 $(kern_cpio_obj): cpio-rebuild
517 $(Q)rm $(kern_cpio_obj)
521 $(kern_cpio_obj): $(kern_cpio)
522 $(Q)$(OBJCOPY) -I binary -B $(ld_arch) -O $(ld_emulation) $< $@
524 existing-ext2b-emul := $(shell objdump -f $(kern_cpio_obj) 2> /dev/null | \
525 grep format | sed 's/.*format //g')
526 ifneq ($(existing-ext2b-emul),)
527 ifneq ($(existing-ext2b-emul),$(ld_emulation))
528 $(ext2_bdev_obj): ext2b-rebuild
530 $(Q)rm $(ext2_bdev_obj)
534 $(ext2_bdev_obj): $(ext2-bdev)
535 $(Q)$(OBJCOPY) -I binary -B $(ld_arch) -O $(ld_emulation) $< $@
537 # Not the worlds most elegant link command. link-kernel takes the obj output
538 # name, then the linker script, then everything else you'd dump on the ld
539 # command line, including linker options and objects to link together.
541 # After the script is done, we run the arch-specific command directly.
542 quiet_cmd_link-akaros = LINK $@
543 cmd_link-akaros = $(CONFIG_SHELL) scripts/link-kernel.sh $@ \
544 kern/arch/$(ARCH)/$(KERNEL_LD) $(LDFLAGS_KERNEL) \
545 $(akaros-deps) $(gcc-lib) $(kern_cpio_obj) \
547 $(ARCH_POST_LINK_CMD)
549 # For some reason, the if_changed doesn't work with FORCE (like it does in
550 # Linux). It looks like it can't find the .cmd file or something (also
551 # complaints of $(targets), so that all is probably messed up).
552 $(KERNEL_OBJ): $(akaros-deps) $(kern_cpio_obj) $(ext2_bdev_obj)
553 $(call if_changed,link-akaros)
555 akaros-kernel: $(KERNEL_OBJ)
557 $(sort $(akaros-deps)): $(akaros-dirs) ;
559 # Recursively Kbuild all of our directories. If we're changing arches
560 # mid-make, we might have issues ( := on akaros-dirs, etc).
561 PHONY += $(akaros-dirs) cc_exists
562 $(akaros-dirs): scripts symlinks cc-exists
563 $(Q)$(MAKE) $(build)=$@
566 @if [ "`which $(CROSS_COMPILE)gcc`" = "" ]; then echo \
567 Could not find a $(CROSS_COMPILE) version of GCC/binutils. \
568 Be sure to build the cross-compiler and update your PATH; exit 1; fi
570 $(CMP_KERNEL_OBJ): $(KERNEL_OBJ)
571 @echo "Compressing kernel image"
574 # TODO: not sure what all we want to have available for config targets
575 # (anything after this is allowed. We currently need clean targets available
576 # (config->symlinks->clean).
577 endif #ifeq ($(config-targets),1)
578 endif #ifeq ($(mixed-targets),1)
580 # Akaros Userspace Building and Misc Helpers
581 # =========================================================================
582 # Recursively make user libraries and tests.
584 # User library makefiles are built to expect to be called from their own
585 # directories. The test code can be called from the root directory.
587 # List all userspace directories here, and state any dependencies between them,
588 # such as how pthread depends on parlib.
590 user-dirs = parlib pthread benchutil iplib ndblib vmm perfmon
592 pthread: parlib benchutil
597 PHONY += install-libs $(user-dirs)
598 install-libs: $(user-dirs) symlinks cc-exists
601 @$(MAKE) -C user/$@ DEPLIBS="$^" && $(MAKE) -C user/$@ install
605 PHONY += userclean $(clean-user-dirs)
606 clean-user-dirs := $(addprefix _clean_user_,$(user-dirs))
607 userclean: $(clean-user-dirs) testclean utestclean
610 @$(MAKE) -C user/$(patsubst _clean_user_%,%,$@) clean
614 @$(MAKE) -f tests/Makefile
621 @$(MAKE) -f tests/Makefile clean
624 @$(MAKE) -C user/utest clean
627 PHONY += fill-kfs unfill-kfs
628 xcc-gcc-libs = $(XCC_TARGET_ROOT)/../lib/
629 xcc-so-files = $(addprefix $(XCC_TARGET_LIB), *.so*) \
630 $(addprefix $(xcc-gcc-libs), *.so*)
632 $(OBJDIR)/.dont-force-fill-kfs:
633 $(Q)rm -rf $(addprefix $(FIRST_KFS_PATH)/lib/, $(notdir $(xcc-so-files)))
634 @echo "Cross Compiler 'so' files removed from KFS"
635 @$(MAKE) -f tests/Makefile uninstall
636 @echo "Apps from /test removed from KFS"
637 @$(MAKE) -C user/utest uninstall
638 @echo "User space tests removed from KFS"
639 @touch $(OBJDIR)/.dont-force-fill-kfs
641 fill-kfs: $(OBJDIR)/.dont-force-fill-kfs install-libs tests
642 @mkdir -p $(FIRST_KFS_PATH)/lib
643 $(Q)cp -uP $(xcc-so-files) $(FIRST_KFS_PATH)/lib
644 @echo "Cross Compiler 'so' files installed to KFS"
645 @$(MAKE) -f tests/Makefile install
646 @echo "Apps from /test installed to KFS"
647 @$(MAKE) -C user/utest install
648 @echo "User space tests installed to KFS"
650 # Use doxygen to make documentation for ROS (Untested since 2010 or so)
651 doxygen-dir := $(CUR_DIR)/Documentation/doxygen
653 @echo " Making doxygen"
654 @doxygen-dir=$(doxygen-dir) doxygen $(doxygen-dir)/rosdoc.cfg
655 @if [ ! -d $(doxygen-dir)/rosdoc/html/img ]; \
657 ln -s ../../img $(doxygen-dir)/rosdoc/html; \
661 @echo + clean [ROSDOC]
662 @rm -rf $(doxygen-dir)/rosdoc
665 @echo + clean [OBJDIR]
668 realclean: userclean mrproper doxyclean objclean
671 # =========================================================================
673 app-dirs = tools/apps/snc
674 tagged-app-dirs := $(subst /,__,$(app-dirs))
675 app-dirs-install := $(addprefix _install_,$(tagged-app-dirs))
676 app-dirs-clean := $(addprefix _clean_,$(tagged-app-dirs))
678 PHONY += $(app-dirs-install) $(app-dirs-clean)
681 @$(MAKE) -C $(patsubst _install_%,%,$(subst __,/,$@)) install
684 @$(MAKE) -C $(patsubst _clean_%,%,$(subst __,/,$@)) clean
686 PHONY += apps-install
687 apps-install: $(app-dirs-install)
688 @$(call make_as_parent, -C tools/apps/busybox)
689 @$(call make_as_parent, -C tools/profile/perf install)
692 apps-clean: $(app-dirs-clean)
693 @$(call make_as_parent, -C tools/apps/busybox clean)
694 @$(call make_as_parent, -C tools/profile/perf clean)
697 # =========================================================================
699 xcc_build_dir := tools/compilers/gcc-glibc
700 xcc_target := $(ARCH)
701 ifeq ($(xcc_target),x86)
702 xcc_target := $(xcc_target)_64
704 xcc_cleans := $(shell $(MAKE) -C $(xcc_build_dir) -pn |\
705 grep "VALID_CLEANS := " |\
706 sed -e 's/VALID_CLEANS := //')
707 xcc_subcmds := $(shell $(MAKE) -C $(xcc_build_dir) -pn |\
708 grep "VALID_SUBCMDS := " |\
709 sed -e 's/VALID_SUBCMDS := //')
710 xcc_clean_goals := $(patsubst %, xcc-%, $(xcc_cleans))
711 xcc_subcmd_goals := $(patsubst %, xcc-%, $(xcc_subcmds))
716 PHONY += $(xcc_clean_goals)
718 @target="$(patsubst xcc-%,%,$(@))";\
719 $(call make_as_parent, -C $(xcc_build_dir) $${target})
721 PHONY += $(xcc_subcmd_goals)
723 @subcmd="$(patsubst xcc-%,%,$(@))";\
724 target="$(xcc_target) $${subcmd}";\
725 $(call make_as_parent, -C $(xcc_build_dir) $${target})
730 @$(MAKE) install-libs
731 @$(MAKE) testclean utestclean
733 @$(call make_as_parent, apps-clean)
734 @$(call make_as_parent, apps-install)
736 @$(MAKE) akaros-kernel
738 PHONY += xcc-upgrade-from-scratch
739 xcc-upgrade-from-scratch: xcc-clean xcc-uninstall
740 @$(call make_as_parent, xcc-upgrade)
743 # =========================================================================
744 # This is mostly the Linux kernel cleaning. We could hook in to the userspace
745 # cleaning with the 'userclean' target attached to clean, though historically
746 # 'clean' means the kernel.
748 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
750 # $(Q)$(MAKE) $(clean)=dir
751 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
753 # clean - Delete all generated files
755 clean-dirs := $(addprefix _clean_,$(akaros-all-dirs))
757 PHONY += $(clean-dirs) clean
759 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
761 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
762 -o -name .pc -o -name .hg -o -name .git \) -prune -o
764 @find $(patsubst _clean_%,%,$(clean-dirs)) $(RCS_FIND_IGNORE) \
765 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
767 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
768 -o -name '*.symtypes' -o -name 'modules.order' \
769 -o -name modules.builtin -o -name '.tmp_*.o.*' \
770 -o -name '*.gcno' \) -type f -print | xargs rm -f
772 # Could add in an archclean if we need arch-specific cleanup, or a userclean if
773 # we want to start cleaning that too.
777 # mrproper - Delete all generated files, including .config, and reset ARCH
779 mrproper-dirs := $(addprefix _mrproper_,scripts)
781 PHONY += $(mrproper-dirs) mrproper
783 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
785 mrproper: $(mrproper-dirs) clean clean_symlinks
787 @find $(patsubst _mrproper_%,%,$(mrproper-dirs)) $(RCS_FIND_IGNORE) \
788 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
790 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
791 -o -name '*.symtypes' -o -name 'modules.order' \
792 -o -name modules.builtin -o -name '.tmp_*.o.*' \
793 -o -name '*.gcno' \) -type f -print | xargs rm -f
796 # =========================================================================
801 # Don't put the srctree on this, make is looking for Makefile, not
802 # /full/path/to/Makefile.
803 Makefile: ; # avoid implicit rule on Makefile
805 # Declare the contents of the .PHONY variable as phony. We keep that
806 # information in a variable so we can use it in if_changed and friends.