1#
2# Copyright 2016, Data61
3# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4# ABN 41 687 119 230.
5#
6# This software may be distributed and modified according to the terms of
7# the BSD 2-Clause license. Note that NO WARRANTY is provided.
8# See "LICENSE_BSD2.txt" for details.
9#
10# @TAG(D61_BSD)
11#
12
13VERSION = 2
14PATCHLEVEL = 0
15SUBLEVEL = 0
16EXTRAVERSION = 1
17
18lib-dirs:=libs
19
20# The main target we want to generate
21all: generate-rpc refos
22
23-include .config
24export CONFIG_ELF_LOADER_USE_SEL4C
25export CONFIG_ELF_LOADER_USE_MUSLC
26include tools/common/project.mk
27
28# Build CPIO Archives.
29$(BUILD_BASE)/process_server/archive.o: export TOOLPREFIX=$(CONFIG_CROSS_COMPILER_PREFIX:"%"=%)
30$(BUILD_BASE)/process_server/archive.o: file_server test_os selfloader console_server
31	$(Q)mkdir -p $(dir $@)
32	@echo "[CPIO] $@"
33	$(Q)${COMMON_PATH}/files_to_obj.sh $@ _cpio_archive \
34		$(patsubst %, ${STAGE_BASE}/bin/%,$^)
35	@echo "[CPIO] done."
36
37$(BUILD_BASE)/file_server/archive.o: export TOOLPREFIX=$(CONFIG_CROSS_COMPILER_PREFIX:"%"=%)
38$(BUILD_BASE)/file_server/archive.o: $(filter-out selfloader process_server file_server test_os \
39							           console_server,$(apps))
40	$(Q)mkdir -p $(dir $@)
41	@echo "[CPIO] $@"
42	$(Q)${COMMON_PATH}/files_to_obj.sh $@ _cpio_archive \
43		$(patsubst %, ${STAGE_BASE}/bin/%,$^) \
44		$(wildcard apps/file_server/files/*)
45	@echo "[CPIO] done."
46
47# RefOS ARM build command.
48ifeq (${CONFIG_ARCH_ARM},y)
49refos: export TOOLPREFIX=$(CONFIG_CROSS_COMPILER_PREFIX:"%"=%)
50refos: $(BUILD_BASE)/file_server/archive.o $(BUILD_BASE)/process_server/archive.o process_server \
51        common elfloader kernel_elf
52	@echo "Generating boot image: ${IMAGE_ROOT}/refos-image"
53	@${SEL4_COMMON}/elfloader/gen_boot_image.sh \
54		${STAGE_BASE}/kernel.elf \
55		${STAGE_BASE}/bin/process_server \
56		${IMAGE_ROOT}/refos-image
57endif
58
59# RefOS IA32 build command.
60ifeq (${CONFIG_ARCH_IA32},y)
61refos: export PATH := $(STAGE_ROOT)/dite:$(PATH)
62refos: $(BUILD_BASE)/file_server/archive.o $(BUILD_BASE)/process_server/archive.o process_server\
63		common app-images
64	@echo "[STAGE] ${IMAGE_ROOT}/refos-image"
65	cp -f ${STAGE_BASE}/bin/process_server ${IMAGE_ROOT}/refos-image
66endif
67
68# Generate RPC stubs.
69generate-rpc:
70	./refos_cidl_compile make proc
71	./refos_cidl_compile make name
72	./refos_cidl_compile make serv
73	./refos_cidl_compile make data
74
75# Clean RPC stubs.
76clean-rpc:
77	./refos_cidl_compile clean proc
78	./refos_cidl_compile clean name
79	./refos_cidl_compile clean serv
80	./refos_cidl_compile clean data
81
82# Misc helper targets.
83cscope: clean
84	@echo "[CSCOPE] cscope.out"
85	@cscope -b -R -k
86
87docs: generate-rpc clean
88	@echo "[DOXYGEN] Generating docs..."
89	cd docs/; make
90	@echo "[DOXYGEN] OK. Please open file '$(PWD)/docs/html/index.html' in a web browser"
91
92design:
93	@echo "[DESIGN] Generating RefOS procotol design document..."
94	cd projects/refos/design/; make clean; make
95	@echo "[DESIGN] OK. Please open file '$(PWD)/projects/refos/design/paper.pdf'"
96
97# QEMU simulation helpers.
98simulate-kzm:
99	qemu-system-arm -nographic -M kzm \
100		-kernel images/refos-image
101
102simulate-ia32:
103	qemu-system-i386 \
104		-m 512 -nographic -kernel images/kernel-ia32-pc99 \
105		-initrd images/refos-image
106
107simulate-ia32-graphics:
108	qemu-system-i386 \
109		-m 512 -kernel images/kernel-ia32-pc99 \
110		-initrd images/refos-image
111
112# Help
113.PHONY: help
114help:
115	@echo "RefOS - Reference Design For A Microkernel Based Operating System"
116	@echo ""
117	@echo " make help                   - Show this help menu."
118	@echo " make menuconfig             - Select build configuration via menus."
119	@echo " make <defconfig>            - Apply one of the default configurations. See"
120	@echo "                               below for valid configurations."
121	@echo " make silentoldconfig        - Update configuration with the defaults of any"
122	@echo "                               newly introduced settings."
123	@echo " make                        - Build everything with the current configuration."
124	@echo " make generate-rpc           - Generate RPC stubs from XML specifications."
125	@echo " make clean-rpc              - Delete generated RPC stubs."
126	@echo " make refos                  - Build RefOS without re-generating RPC stub code."
127	@echo " make cscope                 - Build cscope.out index file using cscope."
128	@echo " make docs                   - Build docs/html/ Doxygen code documentation."
129	@echo " make design                 - Build protocol design document."
130	@echo " make simulate-kzm           - Boot kzm configured system image."
131	@echo " make simulate-ia32          - Boot ia32 configured system image."
132	@echo " make simulate-ia32-graphics - Boot ia32 configured system image in new console."
133	@echo ""
134	@echo ""
135	@echo "Valid default configurations are:"
136	@ls -1 configs | sed -e 's/\(.*\)/\t\1/g'
137	@echo ""
138
139