Fixed typo in Makefile
[ZeXOS.git] / kernel / Makefile
blobb88fa35dfad13e44e2f76a36652327a3cc9e11e7
1 # ZeX/OS makefile
2 # Copyright (C) 2007 Alex Smith
3 # 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
4 # 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of version 2 of the GNU General Public License
8 # as published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 # This piece of code was borrowed from Exclaim
20 # Thanks for Alex Smith
22 ZEXOS_VERSION = 0
23 ZEXOS_PATCHLEVEL = 6
24 ZEXOS_SUBLEVEL = 7
25 ZEXOS_EXTRAVERSION =
26 ZEXOS_CODENAME =
28 HOSTCC := gcc
29 HOSTCXX := g++
31 src := $(shell pwd)
32 obj := $(shell pwd)/build/$(ARCH)
33 export src obj
35 ifneq ($(V),1)
36 Q := @
37 endif
39 # When ARCH is not defined, lets detect architecture
40 ifeq ($(ARCH),)
41 ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/x86_64/i386/)
42 endif
44 KERNELVERSION = $(ZEXOS_VERSION).$(ZEXOS_PATCHLEVEL).$(ZEXOS_SUBLEVEL)$(ZEXOS_EXTRAVERSION)
45 export KERNELVERSION
47 ifeq ($(strip $(wildcard .config)),)
49 all:
50 @printf "Please run make menuconfig, xconfig, gconfig or config first.\n"
51 @false
52 else
54 include $(src)/.config
56 all: prepare $(obj)/config.h $(obj)/build.h compilation drivers
57 @printf " DONE\n"
59 endif
61 include utils/kconfig/Makefile
63 include kernel.mak
65 # prepare
66 prepare:
67 $(Q)if [ ! -d "$(obj)" ]; then mkdir -p $(obj); fi
68 $(Q)if [ -e "$(src)/arch/main" ]; then rm $(src)/arch/main; fi
69 $(Q)ln -s $(src)/arch/$(ARCH) $(src)/arch/main
70 $(Q)if [ -e "$(src)/build/main" ]; then rm $(src)/build/main; fi
71 $(Q)ln -s $(src)/build/$(ARCH) $(src)/build/main
72 $(Q)if [ -e "$(src)/include/arch" ]; then rm $(src)/include/arch; fi
73 $(Q)ln -s $(src)/arch/$(ARCH)/include $(src)/include/arch
75 $(obj)/config.h: .config
76 $(Q)make --no-print-directory silentoldconfig
77 @printf " CP $(subst $(shell pwd)/,,$(obj)/config.h)\n"
78 $(Q)cp $(src)/.tmpconfig.h $(obj)/config.h
80 # This is generated to build.h header file, which is needed to compilation
81 $(obj)/build.h: Makefile
82 @printf " GEN $(subst $(shell pwd)/,,$(obj)/build.h)\n"
83 $(Q)printf "#define ZEXOS_MAJOR \"$(ZEXOS_VERSION)\"\n" > $(obj)/build.h
84 $(Q)printf "#define ZEXOS_MINOR \"$(ZEXOS_PATCHLEVEL)\"\n" >> $(obj)/build.h
85 $(Q)printf "#define ZEXOS_REVISION \"$(ZEXOS_SUBLEVEL)\"\n" >> $(obj)/build.h
86 $(Q)printf "#define ZEXOS_EXTRAVER \"$(ZEXOS_EXTRAVERSION)\"\n" >> $(obj)/build.h
87 $(Q)printf "#define ZEXOS_VERSION \"$(ZEXOS_KERNELVERSION)$(CONFIG_LOCALVERSION)\"\n" >> $(obj)/build.h
88 $(Q)printf "#define ZEXOS_CODENAME \"$(ZEXOS_CODENAME)\"\n" >> $(obj)/build.h
89 $(Q)printf "#define ZEXOS_DATE \"`LANG= date \"+%Y-%m-%d %H:%m:%S\"`\"\n" >> $(obj)/build.h
90 $(Q)printf "\n" >> $(obj)/build.h
91 $(Q)printf "#define ZEXOS_COMPILER \"$(shell LANG= $(CC) --version | head -n1)\"\n" >> $(obj)/build.h
92 $(Q)printf "#define ZEXOS_COMPILE_BY \"$(shell PATH=$$PATH:/usr/ucb whoami)\"\n" >> $(obj)/build.h
93 $(Q)printf "#define ZEXOS_COMPILE_HOST \"$(shell hostname)\"\n" >> $(obj)/build.h
94 $(Q)printf "#define ZEXOS_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname)\"\n" >> $(obj)/build.h
95 $(Q)printf "\n" >> $(obj)/build.h
96 $(Q)printf "#define ZEXOS_ARCH \"$(ARCH)\"\n" >> $(obj)/build.h
97 $(Q)printf "#define ARCH_$(ARCH)\n" >> $(obj)/build.h
99 compilation:
100 $(Q)make -C arch/main
101 $(Q)make -C lib