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 # Save the ability to export the parent's original environment for future use
40 export_parent_env := $(shell export | sed 's/$$/;/')
42 # Save the ability to clear the current environment for future use
43 clear_current_env := for c in $$(env | cut -d '=' -f 1); do unset $$c; done;
45 # Define a set of commands to reset the environment to the parent's environment
46 # and then run a local make target
50 $(MAKE) --no-print-directory $(1)
54 # o use make's built-in rules and variables
55 # (this increases performance and avoids hard-to-debug behaviour);
56 # o print "Entering directory ...";
57 MAKEFLAGS += -rR --no-print-directory
59 # That's our default target when none is given on the command line
60 # This can be overriden with a Makelocal
64 # Export the location of this top level directory
65 AKAROS_ROOT = $(CURDIR)
68 # Setup dumping ground for object files and any temporary files we need to
69 # generate for non-kbuild targets
73 # =========================================================================
74 # We have a few symlinks so that code can include <arch/whatever.h>. This
75 # section builds and maintains those, as best we can.
77 # When invoking make, we can pass in ARCH=some-arch. This value gets 'saved'
78 # in the symlink, so that later invocations do not need ARCH=. If this value
79 # differs from the symlink, it appears like we are changing arches, which
80 # triggers a clean and symlink reconstruction.
82 # When the user changes from one arch to another, they ought to reconfig, since
83 # many of the CONFIG_ vars will depend on the arch. If they try anything other
84 # than one of the "non-build-goals" (cleans or configs), we'll abort.
86 # Make targets that need these symlinks (like building userspace, the kernel,
87 # configs, etc, should depend on symlinks.
89 clean-goals := clean mrproper realclean userclean testclean doxyclean objclean
90 non-build-goals := %config $(clean-goals)
91 ifeq ($(filter $(non-build-goals), $(MAKECMDGOALS)),)
92 goals-has-build-targets := 1
95 PHONY += symlinks clean_symlinks
96 clean_symlinks: objclean
97 @rm -f kern/include/arch kern/boot user/parlib/include/arch
99 arch-link := $(notdir $(shell readlink kern/include/arch))
100 valid-arches := $(notdir $(wildcard kern/arch/*))
103 ifeq ($(filter $(valid-arches), $(ARCH)),)
104 $(error ARCH $(ARCH) invalid, must be one of: $(valid-arches))
106 ifneq ($(ARCH),$(arch-link))
107 ifeq ($(goals-has-build-targets),1)
108 $(error Attempted to make [$(MAKECMDGOALS)] while changing ARCH. \
109 You need to make *config.)
111 symlinks: clean_symlinks
112 @echo Making symlinks...
113 $(Q)ln -fs ../arch/$(ARCH) kern/include/arch
114 $(Q)ln -fs arch/$(ARCH)/boot kern/boot
115 $(Q)ln -fs $(ARCH) user/parlib/include/arch
116 $(Q)$(MAKE) -f $(srctree)/Makefile clean
121 endif # ifneq ($(ARCH),$(arch-link))
122 else # $(ARCH) is empty
123 ifneq ($(arch-link),)
129 ifeq ($(filter $(clean-goals), $(MAKECMDGOALS)),)
130 $(error No arch saved or specified. Make *config with ARCH=arch. \
131 'arch' must be one of: $(valid-arches))
133 ARCH := none # catch bugs
134 endif # ifneq ($(arch-link),)
135 endif # ifeq ($(ARCH),)
140 # Generic Kbuild Environment
141 # =========================================================================
143 # To put more focus on warnings, be less verbose as default
144 # Use 'make V=1' to see the full commands
146 ifeq ("$(origin V)", "command line")
147 KBUILD_VERBOSE = $(V)
149 ifndef KBUILD_VERBOSE
153 srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
156 export srctree objtree
158 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
159 else if [ -x /bin/bash ]; then echo /bin/bash; \
160 else echo sh; fi ; fi)
164 HOSTCFLAGS = -Wall -Wno-char-subscripts -Wmissing-prototypes \
165 -Wstrict-prototypes -O2 -fomit-frame-pointer
168 export CONFIG_SHELL HOSTCC HOSTCXX HOSTCFLAGS HOSTCXXFLAGS
171 # ---------------------------------------------------------------------------
173 # Normally, we echo the whole command before executing it. By making
174 # that echo $($(quiet)$(cmd)), we now have the possibility to set
175 # $(quiet) to choose other forms of output instead, e.g.
177 # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
178 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
180 # If $(quiet) is empty, the whole command will be printed.
181 # If it is set to "quiet_", only the short version will be printed.
182 # If it is set to "silent_", nothing will be printed at all, since
183 # the variable $(silent_cmd_cc_o_c) doesn't exist.
185 # A simple variant is to prefix commands with $(Q) - that's useful
186 # for commands that shall be hidden in non-verbose mode.
190 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
191 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
193 ifeq ($(KBUILD_VERBOSE),1)
200 export quiet Q KBUILD_VERBOSE
202 # We need some generic definitions (do not try to remake the file).
203 $(srctree)/scripts/Kbuild.include: ;
204 include $(srctree)/scripts/Kbuild.include
206 # Kbuild Target/Goals Parsing
207 # =========================================================================
208 # Need to figure out if we're a config or not, and whether or not to include
209 # our .config / auto.conf. Configs are basically their own makefile, (ifeq),
210 # and cleans are allowed to proceed without worrying about the dot-config.
212 # Basic helpers built in scripts/
213 PHONY += scripts_basic
215 $(Q)$(MAKE) $(build)=scripts/basic
219 scripts: scripts_basic include/config/auto.conf include/config/tristate.conf
220 $(Q)$(MAKE) $(build)=$(@)
226 no-dot-config-targets := $(clean-goals)
228 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
229 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
234 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
236 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
241 ifeq ($(mixed-targets),1)
242 # ===========================================================================
243 # We're called with mixed targets (*config and build targets).
244 # Handle them one by one.
247 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
250 ifeq ($(config-targets),1)
251 # ===========================================================================
252 # *config targets only - make sure prerequisites are updated, and descend
253 # in scripts/kconfig to make the *config target
255 # Default config file, per arch. This path will resolve to
256 # arch/$ARCH/configs/defconfig (arch -> kern/arch). Each arch can override
257 # this if they want, or just symlink to one in the main root directory.
258 KBUILD_DEFCONFIG := defconfig
259 export KBUILD_DEFCONFIG
261 config: scripts_basic symlinks FORCE
262 $(Q)mkdir -p include/config
263 $(Q)$(MAKE) $(build)=scripts/kconfig $@
265 %config: scripts_basic symlinks FORCE
266 $(Q)mkdir -p include/config
267 $(Q)$(MAKE) $(build)=scripts/kconfig $@
270 # ===========================================================================
271 # Build targets only - this includes vmlinux, arch specific targets, clean
272 # targets and others. In general all targets except *config targets.
274 ifeq ($(dot-config),1)
275 KCONFIG_CONFIG ?= .config
276 export KCONFIG_CONFIG
279 -include include/config/auto.conf
281 # Read in dependencies to all Kconfig* files, make sure to run
282 # oldconfig if changes are detected.
283 -include include/config/auto.conf.cmd
285 # To avoid any implicit rule to kick in, define an empty command
286 $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
288 # If .config is newer than include/config/auto.conf, someone tinkered
289 # with it and forgot to run make oldconfig.
290 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
291 # we execute the config step to be sure to catch updated Kconfig files
292 include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
293 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
296 # Dummy target needed, because used as prerequisite
297 include/config/auto.conf: ;
298 endif # $(dot-config)
300 # Akaros Build Environment
301 # =========================================================================
302 AKAROSINCLUDE := -I$(srctree)/kern/include/
304 # CROSS_COMPILE is defined per-arch. Each arch can set other makeflags, kbuild
306 -include $(srctree)/kern/arch/$(ARCH)/Makefile
308 CC := $(CROSS_COMPILE)gcc
309 CPP := $(CROSS_COMPILE)g++
310 AS := $(CROSS_COMPILE)as
311 AR := $(CROSS_COMPILE)ar
312 LD := $(CROSS_COMPILE)ld
313 OBJCOPY := $(CROSS_COMPILE)objcopy
314 OBJDUMP := $(CROSS_COMPILE)objdump
315 NM := $(CROSS_COMPILE)nm
316 STRIP := $(CROSS_COMPILE)strip
317 KERNEL_LD ?= kernel.ld
319 # These may have bogus values if there is no compiler. The kernel and user
320 # build targets will check cc-exists. Hopefully no cleaning targets rely on
321 # these. Note that if you change configs, these will get computed once, before
322 # silentoldconfig kicks in to regenerate auto.conf, and these values will
323 # temporarily be stale.
324 gcc-lib := $(shell $(CC) -print-libgcc-file-name 2>/dev/null)
325 NOSTDINC_FLAGS += -nostdinc -isystem \
326 $(shell $(CC) -print-file-name=include 2>/dev/null)
327 XCC_TARGET_ROOT := $(shell $(CC) --print-sysroot 2> /dev/null)
328 XCC_TARGET_LIB := $(XCC_TARGET_ROOT)/usr/lib/
329 XCC_TARGET_INCLUDE := $(XCC_TARGET_ROOT)/usr/include/
331 CFLAGS_KERNEL += -O2 -pipe -MD
332 CFLAGS_KERNEL += -std=gnu99 -fgnu89-inline
333 CFLAGS_KERNEL += -fno-strict-aliasing -fno-omit-frame-pointer
334 CFLAGS_KERNEL += -fno-stack-protector
335 CFLAGS_KERNEL += -Wall -Wno-format -Wno-unused
336 CFLAGS_KERNEL += -DROS_KERNEL
337 CFLAGS_KERNEL += -include include/generated/autoconf.h -include include/common.h
338 CFLAGS_KERNEL += -fplan9-extensions
339 ifeq ($(CONFIG_64BIT),y)
340 CFLAGS_KERNEL += -m64 -g
342 CFLAGS_KERNEL += -m32 -gstabs
345 # TODO: do we need this, or can we rely on the compiler's defines?
346 CFLAGS_KERNEL += -D$(ARCH)
348 # TODO: this requires our own strchr (kern/src/stdio.c), which is a potential
349 # source of bugs/problems.
350 # note we still pull in stdbool and stddef from the compiler
351 CFLAGS_KERNEL += -fno-builtin
353 AFLAGS_KERNEL := $(CFLAGS_KERNEL)
358 export AKAROSINCLUDE CROSS_COMPILE
359 export CC CPP AS AR LD OBJCOPY OBJDUMP NM STRIP
360 export CFLAGS_KERNEL AFLAGS_KERNEL
361 export NOSTDINC_FLAGS XCC_TARGET_ROOT XCC_TARGET_LIB XCC_TARGET_INCLUDE
362 export KBUILD_BUILTIN KBUILD_CHECKSRC
364 CFLAGS_USER += -O2 -std=gnu99 -fno-stack-protector -fgnu89-inline
366 CFLAGS_USER_LIBS += -fPIC -static -fno-omit-frame-pointer -g
368 export CFLAGS_USER CXXFLAGS_USER CFLAGS_USER_LIBS
370 # Akaros include stuff (includes custom make targets and user overrides)
371 # =========================================================================
373 # The user can override this, though it won't apply for any of the in-tree
374 # kernel build output. Right now, it's only passed down to tests/
375 dummy-1 := $(shell mkdir -p $(OBJDIR)/kern/)
377 # Don't need to export these, since the Makelocal is included.
378 KERNEL_OBJ := $(OBJDIR)/kern/akaros-kernel
379 CMP_KERNEL_OBJ := $(KERNEL_OBJ).gz
381 # Since we're doing this outside of the dot-config part, some targets, such as
382 # clean, won't read in our .config/auto.conf, and won't know about the
383 # KFS_PATH. Future rules related to KFS will have issues (mkdir with no
384 # argument, or a find of the entire pwd). It's also possible someone provided
385 # an empty path. To deal with both, we'll just have a sensible default.
386 kfs-paths := $(subst $\",,$(CONFIG_KFS_PATHS))
388 kfs-paths := kern/kfs
391 FIRST_KFS_PATH = $(firstword $(kfs-paths))
393 export OBJDIR FIRST_KFS_PATH
395 # Avoiding implicit rules
396 $(srctree)/Makelocal: ;
397 # TODO: one issue is that we import all types of targets: build, clean, etc.
398 # That makes it a bit tougher to reorganize with ifeqs.
399 -include $(srctree)/Makelocal
401 # Akaros Kernel Build
402 # =========================================================================
403 # Add top level directories, either to an existing entry (core-y) or to its
406 # From these, we determine deps and dirs. We recursively make through the
407 # dirs, generating built-in.o at each step, which are the deps from which we
410 # We have all-arch-dirs and all-dirs, so that we can still clean even without
413 core-y += kern/src/ kern/drivers/ kern/lib/ $(AKAROS_EXTERNAL_DIRS)
414 arch-y += kern/arch/$(ARCH)/
416 akaros-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(arch-y)))
418 all-arch-dirs := $(patsubst %,kern/arch/%/,$(valid-arches))
419 akaros-all-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(all-arch-dirs)))
421 core-y := $(patsubst %/, %/built-in.o, $(core-y))
422 arch-y := $(patsubst %/, %/built-in.o, $(arch-y))
424 kbuild_akaros_main := $(core-y) $(arch-y)
425 akaros-deps := $(kbuild_akaros_main) kern/arch/$(ARCH)/$(KERNEL_LD)
427 kern_cpio := $(OBJDIR)/kern/initramfs.cpio
428 kern_cpio_obj := $(kern_cpio).o
430 # ext2 will crash at runtime if we don't have a block device. try to catch the
431 # errors now. if it is a bad one, you're just out of luck.
432 ifneq ($(CONFIG_EXT2FS),)
433 ext2-bdev := $(patsubst "%",%,$(CONFIG_EXT2_BDEV))
435 $(error EXT2 selected with no block device [$(ext2-bdev)], fix your .config)
437 ext2_bdev_obj = $(OBJDIR)/kern/$(shell basename $(ext2-bdev)).o
440 # a bit hacky: we want to make sure the directories exist, and error out
441 # otherwise. we also want to error out before the initramfs target, otherwise
442 # we might not get the error (if initramfs files are all up to date). the
443 # trickiest thing here is that kfs-paths-check could be stale and require an
444 # oldconfig. running make twice should suffice.
445 kfs-paths-check := $(shell for i in $(kfs-paths); do \
446 if [ ! -d "$$i" ]; then \
447 echo "Can't find KFS directory $$i"; \
448 $(MAKE) -f $(srctree)/Makefile \
449 silentoldconfig > /dev/null; \
454 ifneq (ok,$(kfs-paths-check))
455 $(error $(kfs-paths-check), try make one more time in case of stale configs)
458 kern_initramfs_files := $(shell find $(kfs-paths))
460 # Need to make an empty cpio, then append each kfs-path's contents
461 $(kern_cpio) initramfs: $(kern_initramfs_files)
462 @echo " Building initramfs:"
463 @if [ "$(CONFIG_KFS_CPIO_BIN)" != "" ]; then \
464 sh $(CONFIG_KFS_CPIO_BIN); \
466 @cat /dev/null | cpio --quiet -oH newc -O $(kern_cpio)
467 $(Q)for i in $(kfs-paths); do cd $$i; \
468 echo " Adding $$i to initramfs..."; \
469 find -L . | cpio --quiet -oAH newc -O $(CURDIR)/$(kern_cpio); \
473 ld_emulation = $(shell $(OBJDUMP) -i 2>/dev/null | \
474 grep -v BFD | grep ^[a-z] | head -n1)
475 ld_arch = $(shell $(OBJDUMP) -i 2>/dev/null |\
476 grep -v BFD | grep "^ [a-z]" | head -n1)
478 # Our makefile doesn't detect a change in subarch, and old binary objects that
479 # don't need to be updated won't get rebuilt, but they also can't link with the
480 # new subarch (32 bit vs 64 bit). If we detect the wrong type, we'll force a
482 existing-cpio-emul := $(shell objdump -f $(kern_cpio_obj) 2> /dev/null | \
483 grep format | sed 's/.*format //g')
484 ifneq ($(existing-cpio-emul),)
485 ifneq ($(existing-cpio-emul),$(ld_emulation))
486 $(kern_cpio_obj): cpio-rebuild
488 $(Q)rm $(kern_cpio_obj)
492 $(kern_cpio_obj): $(kern_cpio)
493 $(Q)$(OBJCOPY) -I binary -B $(ld_arch) -O $(ld_emulation) $< $@
495 existing-ext2b-emul := $(shell objdump -f $(kern_cpio_obj) 2> /dev/null | \
496 grep format | sed 's/.*format //g')
497 ifneq ($(existing-ext2b-emul),)
498 ifneq ($(existing-ext2b-emul),$(ld_emulation))
499 $(ext2_bdev_obj): ext2b-rebuild
501 $(Q)rm $(ext2_bdev_obj)
505 $(ext2_bdev_obj): $(ext2-bdev)
506 $(Q)$(OBJCOPY) -I binary -B $(ld_arch) -O $(ld_emulation) $< $@
508 # Not the worlds most elegant link command. link-kernel takes the obj output
509 # name, then the linker script, then everything else you'd dump on the ld
510 # command line, including linker options and objects to link together.
512 # After the script is done, we run the arch-specific command directly.
513 quiet_cmd_link-akaros = LINK $@
514 cmd_link-akaros = $(CONFIG_SHELL) scripts/link-kernel.sh $@ \
515 kern/arch/$(ARCH)/$(KERNEL_LD) $(LDFLAGS_KERNEL) \
516 $(akaros-deps) $(gcc-lib) $(kern_cpio_obj) \
518 $(ARCH_POST_LINK_CMD)
520 # For some reason, the if_changed doesn't work with FORCE (like it does in
521 # Linux). It looks like it can't find the .cmd file or something (also
522 # complaints of $(targets), so that all is probably messed up).
523 $(KERNEL_OBJ): $(akaros-deps) $(kern_cpio_obj) $(ext2_bdev_obj)
524 $(call if_changed,link-akaros)
526 akaros-kernel: $(KERNEL_OBJ)
528 $(sort $(akaros-deps)): $(akaros-dirs) ;
530 # Recursively Kbuild all of our directories. If we're changing arches
531 # mid-make, we might have issues ( := on akaros-dirs, etc).
532 PHONY += $(akaros-dirs) cc_exists
533 $(akaros-dirs): scripts symlinks cc-exists
534 $(Q)$(MAKE) $(build)=$@
537 @if [ "`which $(CROSS_COMPILE)gcc`" = "" ]; then echo \
538 Could not find a $(CROSS_COMPILE) version of GCC/binutils. \
539 Be sure to build the cross-compiler and update your PATH; exit 1; fi
541 $(CMP_KERNEL_OBJ): $(KERNEL_OBJ)
542 @echo "Compressing kernel image"
545 # TODO: not sure what all we want to have available for config targets
546 # (anything after this is allowed. We currently need clean targets available
547 # (config->symlinks->clean).
548 endif #ifeq ($(config-targets),1)
549 endif #ifeq ($(mixed-targets),1)
551 # Akaros Userspace Building and Misc Helpers
552 # =========================================================================
553 # Recursively make user libraries and tests.
555 # User library makefiles are built to expect to be called from their own
556 # directories. The test code can be called from the root directory.
558 # List all userspace directories here, and state any dependencies between them,
559 # such as how pthread depends on parlib.
561 user-dirs = parlib pthread benchutil iplib ndblib vmm
563 pthread: parlib benchutil
568 PHONY += install-libs $(user-dirs)
569 install-libs: $(user-dirs) symlinks cc-exists
572 @cd user/$@ && $(MAKE) DEPLIBS="$^" && $(MAKE) install
575 PHONY += userclean $(clean-user-dirs)
576 clean-user-dirs := $(addprefix _clean_user_,$(user-dirs))
577 userclean: $(clean-user-dirs) testclean utestclean
580 @cd user/$(patsubst _clean_user_%,%,$@) && $(MAKE) clean
584 @$(MAKE) -f tests/Makefile
588 @cd user/$@ && $(MAKE)
591 @$(MAKE) -f tests/Makefile clean
594 @cd user/utest && $(MAKE) clean
597 PHONY += fill-kfs unfill-kfs
598 xcc-gcc-libs = $(XCC_TARGET_ROOT)/../lib/
599 xcc-so-files = $(addprefix $(XCC_TARGET_LIB), *.so*) \
600 $(addprefix $(xcc-gcc-libs), *.so*)
602 $(OBJDIR)/.dont-force-fill-kfs:
603 $(Q)rm -rf $(addprefix $(FIRST_KFS_PATH)/lib/, $(notdir $(xcc-so-files)))
604 @echo "Cross Compiler 'so' files removed from KFS"
605 @$(MAKE) -f tests/Makefile uninstall
606 @echo "Apps from /test removed from KFS"
607 @cd user/utest && $(MAKE) uninstall
608 @echo "User space tests removed from KFS"
609 @touch $(OBJDIR)/.dont-force-fill-kfs
611 fill-kfs: $(OBJDIR)/.dont-force-fill-kfs install-libs tests
612 @mkdir -p $(FIRST_KFS_PATH)/lib
613 $(Q)cp -uP $(xcc-so-files) $(FIRST_KFS_PATH)/lib
614 @echo "Cross Compiler 'so' files installed to KFS"
615 @$(MAKE) -f tests/Makefile install
616 @echo "Apps from /test installed to KFS"
617 @cd user/utest && $(MAKE) install
618 @echo "User space tests installed to KFS"
620 # Use doxygen to make documentation for ROS (Untested since 2010 or so)
621 doxygen-dir := $(CUR_DIR)/Documentation/doxygen
623 @echo " Making doxygen"
624 @doxygen-dir=$(doxygen-dir) doxygen $(doxygen-dir)/rosdoc.cfg
625 @if [ ! -d $(doxygen-dir)/rosdoc/html/img ]; \
627 ln -s ../../img $(doxygen-dir)/rosdoc/html; \
631 @echo + clean [ROSDOC]
632 @rm -rf $(doxygen-dir)/rosdoc
635 @echo + clean [OBJDIR]
638 realclean: userclean mrproper doxyclean objclean
641 # =========================================================================
643 PHONY += apps-install
645 @$(call make_as_parent, -C tools/apps/busybox)
649 @$(call make_as_parent, -C tools/apps/busybox clean)
652 # =========================================================================
654 xcc_build_dir := tools/compilers/gcc-glibc
655 xcc_target := $(ARCH)
656 ifeq ($(xcc_target),x86)
657 xcc_target := $(xcc_target)_64
659 xcc_cleans := $(shell $(MAKE) -C $(xcc_build_dir) -pn |\
660 grep "VALID_CLEANS := " |\
661 sed -e 's/VALID_CLEANS := //')
662 xcc_subcmds := $(shell $(MAKE) -C $(xcc_build_dir) -pn |\
663 grep "VALID_SUBCMDS := " |\
664 sed -e 's/VALID_SUBCMDS := //')
665 xcc_clean_goals := $(patsubst %, xcc-%, $(xcc_cleans))
666 xcc_subcmd_goals := $(patsubst %, xcc-%, $(xcc_subcmds))
671 PHONY += $(xcc_clean_goals)
673 @target="$(patsubst xcc-%,%,$(@))";\
674 $(call make_as_parent, -C $(xcc_build_dir) $${target})
676 PHONY += $(xcc_subcmd_goals)
678 @subcmd="$(patsubst xcc-%,%,$(@))";\
679 target="$(xcc_target) $${subcmd}";\
680 $(call make_as_parent, -C $(xcc_build_dir) $${target})
685 @$(MAKE) install-libs
686 @$(MAKE) testclean utestclean
688 @$(call make_as_parent, apps-clean)
689 @$(call make_as_parent, apps-install)
691 @$(MAKE) akaros-kernel
693 PHONY += xcc-upgrade-from-scratch
694 xcc-upgrade-from-scratch: xcc-clean xcc-uninstall
695 @$(call make_as_parent, xcc-upgrade)
698 # =========================================================================
699 # This is mostly the Linux kernel cleaning. We could hook in to the userspace
700 # cleaning with the 'userclean' target attached to clean, though historically
701 # 'clean' means the kernel.
703 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
705 # $(Q)$(MAKE) $(clean)=dir
706 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
708 # clean - Delete all generated files
710 clean-dirs := $(addprefix _clean_,$(akaros-all-dirs))
712 PHONY += $(clean-dirs) clean
714 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
716 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
717 -o -name .pc -o -name .hg -o -name .git \) -prune -o
719 @find $(patsubst _clean_%,%,$(clean-dirs)) $(RCS_FIND_IGNORE) \
720 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
722 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
723 -o -name '*.symtypes' -o -name 'modules.order' \
724 -o -name modules.builtin -o -name '.tmp_*.o.*' \
725 -o -name '*.gcno' \) -type f -print | xargs rm -f
727 # Could add in an archclean if we need arch-specific cleanup, or a userclean if
728 # we want to start cleaning that too.
732 # mrproper - Delete all generated files, including .config, and reset ARCH
734 mrproper-dirs := $(addprefix _mrproper_,scripts)
736 PHONY += $(mrproper-dirs) mrproper
738 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
740 mrproper: $(mrproper-dirs) clean clean_symlinks
742 @find $(patsubst _mrproper_%,%,$(mrproper-dirs)) $(RCS_FIND_IGNORE) \
743 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
745 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
746 -o -name '*.symtypes' -o -name 'modules.order' \
747 -o -name modules.builtin -o -name '.tmp_*.o.*' \
748 -o -name '*.gcno' \) -type f -print | xargs rm -f
751 # =========================================================================
756 # Don't put the srctree on this, make is looking for Makefile, not
757 # /full/path/to/Makefile.
758 Makefile: ; # avoid implicit rule on Makefile
760 # Declare the contents of the .PHONY variable as phony. We keep that
761 # information in a variable so we can use it in if_changed and friends.