-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmakefile
220 lines (196 loc) · 7.49 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# Primary make-file for building and preparing the OS image
# Required tools for building
# - make gcc g++ nasm mono-complete libelf1 libelf-dev libffi6 libffi-dev flex bison python
# - cmake 3.8+
# - llvm/lld/clang toolchain and cross-compiler
# - clang cross-compiler
# - python + (sudo apt-get install python-pip libyaml-dev) + (sudo pip install prettytable Mako pyaml dateutils --upgrade)
# Required environmental stuff:
# - CROSS=/path/to/cross/home
include config/common.mk
# When building the SDK/DDK we need to have VALI_SDK_PATH defined so we
# know where it needs to be installed. By default we install in /userspace directory
ifndef VALI_SDK_PATH
VALI_SDK_PATH=$(userspace_path)
endif
ifndef VALI_DDK_PATH
VALI_DDK_PATH=$(userspace_path)
endif
.PHONY: build
build: build_tools gen_revision build_bootloader build_libraries build_kernel build_drivers build_tests
#############################################
##### UTILITY TARGETS #####
#############################################
.PHONY: gen_revision_minor
@printf "%b" "\033[1;35mUpdating revision version (minor)\033[m\n"
@./revision minor clang
.PHONY: gen_revision
gen_revision:
@printf "%b" "\033[1;35mUpdating revision file\033[m\n"
@./revision build clang
@cp revision.h kernel/include/revision.h
.PHONY: run_bochs
run_bochs:
bochs -q -f tools/setup.bochsrc
#############################################
##### BUILD TARGETS (Boot, Lib, Kernel) #####
#############################################
.PHONY: build_kernel
build_kernel:
@$(MAKE) -s -C kernel -f makefile
.PHONY: build_drivers
build_drivers:
@$(MAKE) -s -C services -f makefile
@$(MAKE) -s -C modules -f makefile
.PHONY: build_libraries
build_libraries:
@$(MAKE) -s -C librt -f makefile
.PHONY: build_bootloader
build_bootloader:
@$(MAKE) -s -C boot -f makefile
.PHONY: build_tests
build_tests:
@$(MAKE) -s -C tests -f makefile
.PHONY: build_tools
build_tools:
@$(MAKE) -s -C tools/lzss -f makefile
@$(MAKE) -s -C tools/rd -f makefile
@$(MAKE) -s -C tools/diskutility -f makefile
@$(MAKE) -s -C tools/revision -f makefile
@$(MAKE) -s -C tools/file2c -f makefile
#############################################
##### PACKAGING TARGETS (OS, SDK, DDK) #####
#############################################
.PHONY: copy_initrd_files
copy_initrd_files:
@printf "%b" "\033[1;35mPackaging initrd files\033[m\n"
@mkdir -p initrd
@cp librt/build/*.dll initrd/
@cp services/build/*.dll initrd/
@cp services/build/*.mdrv initrd/
@cp modules/build/*.dll initrd/
@cp modules/build/*.mdrv initrd/
#@cp resources/initrd/* initrd/
.PHONY: package_os
package_os: copy_initrd_files
$(eval VALI_VERSION = $(shell ./revision print all))
@mkdir -p os_package
@cp -a boot/build/. os_package/
@./rd --arch $(VALI_ARCH) --initrd initrd --out initrd.mos
@./lzss c initrd.mos os_package/initrd.mos
@./lzss c kernel/build/syskrnl.mos os_package/syskrnl.mos
@cp -r resources os_package/
@cp diskutility os_package/
@cp DiscUtils* os_package/
@cd os_package; zip -r vali-$(VALI_VERSION)-$(VALI_ARCH).zip .
@mv os_package/vali-$(VALI_VERSION)-$(VALI_ARCH).zip .
@rm -rf os_package
@rm initrd.mos
.PHONY: package_sdk
package_sdk: package_sdk_headers package_sdk_libraries
$(eval VALI_VERSION = $(shell ./revision print all))
@cd $(VALI_SDK_PATH); zip -r vali-sdk-$(VALI_VERSION)-$(VALI_ARCH).zip .
@mv $(VALI_SDK_PATH)/vali-sdk-$(VALI_VERSION)-$(VALI_ARCH).zip .
@rm -rf $(VALI_SDK_PATH)
.PHONY: package_sdk_headers
package_sdk_headers:
@mkdir -p $(VALI_SDK_PATH)/include
@mkdir -p $(VALI_SDK_PATH)/include/ds
@mkdir -p $(VALI_SDK_PATH)/include/os
@mkdir -p $(VALI_SDK_PATH)/include/inet
@mkdir -p $(VALI_SDK_PATH)/include/sys
@mkdir -p $(VALI_SDK_PATH)/include/cxx
@cp librt/include/*.h $(VALI_SDK_PATH)/include/
@cp librt/libc/include/*.h $(VALI_SDK_PATH)/include/
@cp -r librt/libc/include/os/ $(VALI_SDK_PATH)/include/
@cp librt/libc/include/inet/*.h $(VALI_SDK_PATH)/include/inet/
@cp librt/libc/include/sys/*.h $(VALI_SDK_PATH)/include/sys/
@cp librt/libm/include/*.h $(VALI_SDK_PATH)/include/
@cp librt/libds/include/ds/*.h $(VALI_SDK_PATH)/include/ds/
@cp -r librt/libcxx/libcxx/include/* $(VALI_SDK_PATH)/include/cxx/
.PHONY: package_sdk_libraries
package_sdk_libraries:
@mkdir -p $(VALI_SDK_PATH)/bin
@mkdir -p $(VALI_SDK_PATH)/lib
@cp librt/build/*.dll $(VALI_SDK_PATH)/bin/
@cp librt/build/*.lib $(VALI_SDK_PATH)/lib/
@cp librt/deploy/*.dll $(VALI_SDK_PATH)/bin/
@cp librt/deploy/*.lib $(VALI_SDK_PATH)/lib/
.PHONY: package_ddk
package_ddk: package_ddk_headers
$(eval VALI_VERSION = $(shell ./revision print all))
@cd $(VALI_DDK_PATH); zip -r vali-ddk-$(VALI_VERSION)-$(VALI_ARCH).zip .
@mv $(VALI_DDK_PATH)/vali-ddk-$(VALI_VERSION)-$(VALI_ARCH).zip .
@rm -rf $(VALI_DDK_PATH)
.PHONY: package_ddk_headers
package_ddk_headers:
@mkdir -p $(VALI_DDK_PATH)/include
@mkdir -p $(VALI_DDK_PATH)/include/ddk
@mkdir -p $(VALI_DDK_PATH)/include/gracht
@mkdir -p $(VALI_DDK_PATH)/protocols
@mkdir -p $(VALI_DDK_PATH)/protocols/languages
@cp -r librt/libddk/include/ddk/* $(VALI_DDK_PATH)/include/ddk/
@cp -r librt/libgracht/include/gracht/* $(VALI_DDK_PATH)/include/gracht/
@cp -r protocols/* $(VALI_DDK_PATH)/protocols/
@cp -r librt/libgracht/generator/*.py $(VALI_DDK_PATH)/protocols/
@cp -r librt/libgracht/generator/languages/*.py $(VALI_DDK_PATH)/protocols/languages/
#############################################
##### INSTALL/IMAGE TARGETS #####
#############################################
.PHONY: install_sdk
install_sdk: package_sdk_headers package_sdk_libraries
.PHONY: install_ddk
install_ddk: package_ddk_headers
# Build the deploy directory, which contains the primary (system) drive
# structure, system folder, default binaries etc
.PHONY: install_shared
install_shared: copy_initrd_files
mkdir -p deploy/hdd
mkdir -p deploy/hdd/shared
mkdir -p deploy/hdd/shared/bin
mkdir -p deploy/hdd/system
cp -a resources/system/. deploy/hdd/system/
cp -a resources/shared/. deploy/hdd/shared/
cp -a boot/build/. deploy/
./rd --arch $(VALI_ARCH) --initrd initrd --out initrd.mos
./lzss c initrd.mos deploy/hdd/system/initrd.mos
./lzss c kernel/build/syskrnl.mos deploy/hdd/system/syskrnl.mos
cp librt/build/*.lib deploy/hdd/shared/lib/
cp librt/build/*.dll deploy/hdd/shared/bin/
cp librt/deploy/*.lib deploy/hdd/shared/lib/
cp librt/deploy/*.dll deploy/hdd/shared/bin/
if [ -d $(VALI_APPLICATION_PATH) ]; then \
cp $(VALI_APPLICATION_PATH)/bin/*.app deploy/hdd/shared/bin/ 2>/dev/null || :; \
cp $(VALI_APPLICATION_PATH)/bin/*.dll deploy/hdd/shared/bin/ 2>/dev/null || :; \
else \
cp tests/bin/*.app deploy/hdd/shared/bin/ 2>/dev/null || :; \
cp tests/bin/*.dll deploy/hdd/shared/bin/ 2>/dev/null || :; \
fi
.PHONY: install_img
install_img: install_shared
mono diskutility -auto -target img -scheme mbr
cp mollenos.img mollenos_usb.img
.PHONY: install_vmdk
install_vmdk: install_shared
mono diskutility -auto -target vmdk -scheme mbr
.PHONY: clean
clean:
@$(MAKE) -s -C boot -f makefile clean
@$(MAKE) -s -C librt -f makefile clean
@$(MAKE) -s -C services -f makefile clean
@$(MAKE) -s -C modules -f makefile clean
@$(MAKE) -s -C kernel -f makefile clean
@$(MAKE) -s -C tools/lzss -f makefile clean
@$(MAKE) -s -C tools/rd -f makefile clean
@$(MAKE) -s -C tools/diskutility -f makefile clean
@$(MAKE) -s -C tools/revision -f makefile clean
@$(MAKE) -s -C tools/file2c -f makefile clean
@$(MAKE) -s -C tests -f makefile clean
@rm -f kernel/include/revision.h
@rm -f initrd.mos
@rm -rf deploy
@rm -rf initrd
@rm -f *.vmdk
@rm -f *.img
@rm -f *.lock
@rm -f *.zip