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