root/Whitix/trunk/Makefile

Revision 1847, 3.5 KB (checked in by mwhitworth, 3 years ago)

Add post build commands for extracting or stripping debug info.

Line 
1#===============================#
2#=   CONFIGURATION OPTIONS     =#
3#===============================#
4
5# Change this to build for a different arch
6ARCH = i386
7
8#Change to N to produce a smaller kernel if debug functionality is not required
9CONFIG_ALLSYMS = Y
10DEBUG_FILE = N
11
12ifeq ($(DEBUG_FILE), Y)
13        POST_BUILD = objcopy --only-keep-debug kern kern.debug; strip kern; objcopy --add-gnu-debuglink=kern.debug kern
14else
15        POST_BUILD = strip -g kern;
16endif
17
18PWD = $(shell pwd)
19INCLUDE_DIR := $(PWD)/include
20override CFLAGS += -I$(INCLUDE_DIR)
21CC = gcc
22TAGS = ctags -I SYMBOL_EXPORT -I PACKED
23override GENISO_FLAGS += -c Boot/boot.catalog -R -input-charset iso8859-1 -b Boot/Grub/stage2_eltorito -m'.svn' -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 2 -l CdRoot
24
25#Make sure all makefiles can see everything
26export ARCH
27
28# All directories that are to be built or cleaned.
29KERNEL_SUBDIRS = arch/$(ARCH) devices fs kernel lib memory net video
30SUBDIRS = $(KERNEL_SUBDIRS) user
31
32DIRMODULES = CdRoot/System/Modules CdRoot/System/Modules/Core CdRoot/System/Modules/Input CdRoot/System/Modules/Network CdRoot/System/Modules/Storage CdRoot/System/Modules/Filesystems CdRoot/System/Modules/Video
33DIRLIST = CdRoot CdRoot/Boot CdRoot/Boot/Grub CdRoot/Applications CdRoot/Mount CdRoot/System/Devices CdRoot/System/Include CdRoot/System/Runtime CdRoot/System/Runtime/C CdRoot/System/Startup/ CdRoot/System/Config
34
35all: cd
36        mkdir -p $(DIRLIST)
37        $(MAKE) -C user install
38        genisoimage -o cd.iso $(GENISO_FLAGS)
39        @echo "====================================="
40        @echo "|     Whitix built successfully.    |"
41        @echo "| You can now run Whitix by using   |"
42        @echo "| 'cd.iso' as your CD image. Enjoy! |"
43        @echo "====================================="
44
45floppy: kern
46       
47ifneq ($(CONFIG_ALLSYMS),Y)
48        strip -s kern
49endif
50
51cd: kern
52        mkdir -p CdRoot/Boot
53        cp kern CdRoot/Boot/Kernel
54        mv CdRoot/System/Modules/Filesystems/cdfs.sys CdRoot/System/Modules/Core/cdfs.sys
55        mv CdRoot/System/Modules/Storage/ata_ide.sys CdRoot/System/Modules/Core/ata_ide.sys
56        mv CdRoot/System/Modules/Video/console.sys CdRoot/System/Modules/Core/
57       
58        nm kern | sort -u > kernel.txt
59
60ifneq ($(CONFIG_ALLSYMS),Y)
61        strip -s kern -R .comment
62endif
63
64kern: subdirs
65        ld -M -T link.ld arch/$(ARCH)/boot/*.o arch/$(ARCH)/acpi/*.o arch/$(ARCH)/lib/*.o arch/$(ARCH)/kernel/*.o \
66         arch/$(ARCH)/mm/*.o fs/icfs/*.o fs/kfs/*.o fs/vfs/*.o fs/devfs/*.o \
67         devices/kedev/*.o devices/acpi/*.o devices/misc/*.o kernel/*.o lib/*.o memory/*.o video/*.o \
68          -o kern > kernel.txt
69        $(POST_BUILD)
70        mkdir -p $(DIRMODULES)
71        $(MAKE) -C net modules_install
72        $(MAKE) -C fs modules_install
73        $(MAKE) -C devices modules_install
74        $(MAKE) -C memory modules_install
75        $(MAKE) -C video modules_install
76
77subdirs:
78        for dir in $(SUBDIRS); do \
79                $(MAKE) -C $$dir || exit 1; \
80        done;
81
82$(SUBDIRS):
83        $(MAKE) -C $@
84
85.PHONY: subdirs $(SUBDIRS)
86
87clean:
88        $(MAKE) -C arch/$(ARCH) clean
89        $(MAKE) -C devices clean
90        $(MAKE) -C fs clean
91        $(MAKE) -C kernel clean
92        $(MAKE) -C lib clean
93        $(MAKE) -C net clean
94        $(MAKE) -C video clean
95        $(MAKE) -C memory clean
96        $(MAKE) -C user clean
97        rm -f cd.iso kern out.txt kernel.txt
98        rm -rf CdRoot
99
100#TODO: Update
101help:
102        @echo =====================
103        @echo = Whitix build help =
104        @echo =====================
105        @echo -
106        @echo "all - build the kernel and userspace"
107        @echo "floppy - build the kernel and construct a floppy image"
108        @echo "clean - remove all intermediate files"
109        @echo "See the readme file for more help"
110
111tags:
112        find $(KERNEL_SUBDIRS) include -name "*.[ch]" | $(TAGS) -L -
113
114# Phony targets.
115.PHONY: clean help cd tags
Note: See TracBrowser for help on using the browser.