1 | ############################################################################# |
---|
2 | # ALMOS-MKH Global Makefile # |
---|
3 | ############################################################################# |
---|
4 | |
---|
5 | -include params-soft.mk |
---|
6 | |
---|
7 | ifeq ($(ARCH_NAME),) |
---|
8 | $(error Please define ARCH_NAME parameter in params-soft.mk!) |
---|
9 | endif |
---|
10 | |
---|
11 | -include params-hard.mk |
---|
12 | |
---|
13 | # Default values for hardware parameters. |
---|
14 | # These parameters should be defined in the 'params-hard.mk' file. |
---|
15 | ARCH ?= /users/alain/soc/tsar-trunk-svn-2013/platforms/tsar_generic_iob |
---|
16 | X_SIZE ?= 2 |
---|
17 | Y_SIZE ?= 2 |
---|
18 | NB_PROCS ?= 2 |
---|
19 | NB_TTYS ?= 3 |
---|
20 | IOC_TYPE ?= IOC_BDV |
---|
21 | TXT_TYPE ?= TXT_TTY |
---|
22 | FBF_TYPE ?= FBF_SCL |
---|
23 | SYS_CLK ?= 50000 |
---|
24 | |
---|
25 | # Checking hardware platform definition. |
---|
26 | ifeq ($(wildcard $(ARCH)),) |
---|
27 | $(error Please define in ARCH parameter the path to the hardware platform!) |
---|
28 | endif |
---|
29 | |
---|
30 | # Rules that don't build target files |
---|
31 | # always out-of-date, need to be regenerated everytime they are called |
---|
32 | .PHONY: compile \ |
---|
33 | hard_config.h \ |
---|
34 | dirs \ |
---|
35 | list \ |
---|
36 | extract \ |
---|
37 | fsck \ |
---|
38 | clean \ |
---|
39 | build_libs \ |
---|
40 | build-disk \ |
---|
41 | $(BOOTLOADER_PATH)/build/boot.elf \ |
---|
42 | kernel/build/kernel.elf \ |
---|
43 | user/init/build/init.elf \ |
---|
44 | user/ksh/build/ksh.elf \ |
---|
45 | user/pgdc/build/pgcd.elf \ |
---|
46 | user/idbg/build/idbg.elf \ |
---|
47 | user/sort/build/sort.elf \ |
---|
48 | user/fft/build/fft.elf \ |
---|
49 | user/windows/build/windows.elf \ |
---|
50 | user/convol/build/convol.elf \ |
---|
51 | user/transpose/build/transpose.elf \ |
---|
52 | user/kleenex/build/kleenex.elf \ |
---|
53 | user/udp_chat/build/udp_chat.elf \ |
---|
54 | user/tcp_chat/build/tcp_chat.elf \ |
---|
55 | user/chat/build/chat.elf |
---|
56 | |
---|
57 | # Virtual disk path |
---|
58 | DISK_IMAGE := hdd/virt_hdd.dmg |
---|
59 | |
---|
60 | # The Mtools used to build the FAT32 disk image perfom a few sanity checks, to |
---|
61 | # make sure that the disk is indeed an MS-DOS disk. However, the size of the |
---|
62 | # disk image used by ALMOS-MKH is not MS-DOS compliant. |
---|
63 | # Setting this variable prevents these checks. |
---|
64 | MTOOLS_SKIP_CHECK := 1 |
---|
65 | |
---|
66 | ########################################################################################## |
---|
67 | # Rule to generate boot.elf, kernel.elf, all user.elf files, and update the virtual disk |
---|
68 | # when the corresponding sources files have been modified or destroyed. |
---|
69 | # The "home" directory on the virtual disk is not modified |
---|
70 | compile: dirs \ |
---|
71 | hard_config.h \ |
---|
72 | build_libs \ |
---|
73 | $(BOOTLOADER_PATH)/build/boot.elf \ |
---|
74 | kernel/build/kernel.elf \ |
---|
75 | user/init/build/init.elf \ |
---|
76 | user/ksh/build/ksh.elf \ |
---|
77 | user/pgcd/build/pgcd.elf \ |
---|
78 | user/idbg/build/idbg.elf \ |
---|
79 | user/sort/build/sort.elf \ |
---|
80 | user/fft/build/fft.elf \ |
---|
81 | user/windows/build/windows.elf \ |
---|
82 | user/convol/build/convol.elf \ |
---|
83 | user/transpose/build/transpose.elf \ |
---|
84 | user/kleenex/build/kleenex.elf \ |
---|
85 | user/udp_chat/build/udp_chat.elf \ |
---|
86 | user/tcp_chat/build/tcp_chat.elf \ |
---|
87 | user/chat/build/chat.elf \ |
---|
88 | list |
---|
89 | |
---|
90 | # Rule to create the hdd directory |
---|
91 | dirs: |
---|
92 | @mkdir -p hdd |
---|
93 | |
---|
94 | # Rule to make a recursive list of the virtual disk content. |
---|
95 | list: |
---|
96 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
97 | |
---|
98 | ############################################################## |
---|
99 | # Rule to copy the files generated by the virtual prototype |
---|
100 | # from the virtual disk 'home' directory to the current directory. |
---|
101 | extract: |
---|
102 | mcopy -o -i $(DISK_IMAGE) ::/home . |
---|
103 | |
---|
104 | ############################################################## |
---|
105 | # Rules to delete all binary files from Unix File System |
---|
106 | # without modifying the virtual disk. |
---|
107 | clean: |
---|
108 | rm -f hard_config.h arch_info.xml arch_info.bin |
---|
109 | rm -rf build |
---|
110 | $(MAKE) -C kernel clean |
---|
111 | $(MAKE) -C $(BOOTLOADER_PATH) clean |
---|
112 | $(MAKE) -C $(LIBC_PATH) clean |
---|
113 | $(MAKE) -C $(LIBPTHREAD_PATH) clean |
---|
114 | $(MAKE) -C $(LIBSEMAPHORE_PATH) clean |
---|
115 | $(MAKE) -C $(LIBALMOSMKH_PATH) clean |
---|
116 | $(MAKE) -C $(LIBMATH_PATH) clean |
---|
117 | $(MAKE) -C user/init clean |
---|
118 | $(MAKE) -C user/ksh clean |
---|
119 | $(MAKE) -C user/sort clean |
---|
120 | $(MAKE) -C user/pgcd clean |
---|
121 | $(MAKE) -C user/idbg clean |
---|
122 | $(MAKE) -C user/fft clean |
---|
123 | $(MAKE) -C user/windows clean |
---|
124 | $(MAKE) -C user/convol clean |
---|
125 | $(MAKE) -C user/kleenex clean |
---|
126 | $(MAKE) -C user/transpose clean |
---|
127 | $(MAKE) -C user/udp_chat clean |
---|
128 | $(MAKE) -C user/tcp_chat clean |
---|
129 | $(MAKE) -C user/chat clean |
---|
130 | $(MAKE) -C $(HAL_ARCH) clean |
---|
131 | |
---|
132 | #################################################### |
---|
133 | # Rule for building a new virtual disk from scratch. |
---|
134 | # It creates the bin, bin/kernel, bin/user, and home directories. |
---|
135 | # This requires the generic Linux/MacOS 'create_dmg' script, that should be |
---|
136 | # placed in the same directory as this Makefile. |
---|
137 | build_disk: dirs |
---|
138 | rm -f $(DISK_IMAGE) |
---|
139 | ./create_dmg create $(basename $(DISK_IMAGE)) |
---|
140 | dd if=$(DISK_IMAGE) of=temp.dmg count=131072 |
---|
141 | mv temp.dmg $(DISK_IMAGE) |
---|
142 | mmd -o -i $(DISK_IMAGE) ::/bin || true |
---|
143 | mmd -o -i $(DISK_IMAGE) ::/bin/kernel || true |
---|
144 | mmd -o -i $(DISK_IMAGE) ::/bin/user || true |
---|
145 | mmd -o -i $(DISK_IMAGE) ::/home || true |
---|
146 | mmd -o -i $(DISK_IMAGE) ::/home/convol || true |
---|
147 | mmd -o -i $(DISK_IMAGE) ::/home/transpose || true |
---|
148 | mmd -o -i $(DISK_IMAGE) ::/home/fft || true |
---|
149 | mmd -o -i $(DISK_IMAGE) ::/misc || true |
---|
150 | mcopy -o -i $(DISK_IMAGE) images/lena_256.raw ::/misc || true |
---|
151 | mcopy -o -i $(DISK_IMAGE) images/images_128.raw ::/misc || true |
---|
152 | mcopy -o -i $(DISK_IMAGE) images/philips_1024.raw ::/misc || true |
---|
153 | mcopy -o -i $(DISK_IMAGE) images/couple_512.raw ::/misc || true |
---|
154 | mcopy -o -i $(DISK_IMAGE) images/wood_32.raw ::/misc || true |
---|
155 | mcopy -o -i $(DISK_IMAGE) images/door_32.raw ::/misc || true |
---|
156 | mcopy -o -i $(DISK_IMAGE) images/rock_32.raw ::/misc || true |
---|
157 | mcopy -o -i $(DISK_IMAGE) images/handle_32.raw ::/misc || true |
---|
158 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
159 | |
---|
160 | ############################################################## |
---|
161 | # Rules to generate hardware description files (hard_config.h, |
---|
162 | # arch_info.bin and arch_info.xml), and update the virtual disk. |
---|
163 | hard_config.h: $(ARCH)/arch_info.py |
---|
164 | tools/arch_info/genarch.py --arch=$(ARCH) \ |
---|
165 | --x_size=$(X_SIZE) \ |
---|
166 | --y_size=$(Y_SIZE) \ |
---|
167 | --nb_cores=$(NB_PROCS) \ |
---|
168 | --nb_ttys=$(NB_TTYS) \ |
---|
169 | --ioc_type=$(IOC_TYPE) \ |
---|
170 | --txt_type=$(TXT_TYPE) \ |
---|
171 | --fbf_type=$(FBF_TYPE) \ |
---|
172 | --sys_clk=$(SYS_CLK) \ |
---|
173 | --hard=. \ |
---|
174 | --bin=. \ |
---|
175 | --xml=. |
---|
176 | mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/ || true |
---|
177 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
178 | |
---|
179 | ############################################ |
---|
180 | # Rules to generate the user level libraries |
---|
181 | build_libs: build_hal |
---|
182 | $(MAKE) -C $(LIBALMOSMKH_PATH) headers |
---|
183 | $(MAKE) -C $(LIBPTHREAD_PATH) headers |
---|
184 | $(MAKE) -C $(LIBSEMAPHORE_PATH) headers |
---|
185 | $(MAKE) -C $(LIBMATH_PATH) headers |
---|
186 | $(MAKE) -C $(LIBC_PATH) |
---|
187 | $(MAKE) -C $(LIBALMOSMKH_PATH) |
---|
188 | $(MAKE) -C $(LIBPTHREAD_PATH) |
---|
189 | $(MAKE) -C $(LIBSEMAPHORE_PATH) |
---|
190 | $(MAKE) -C $(LIBMATH_PATH) |
---|
191 | |
---|
192 | ##################################################################### |
---|
193 | # Rule to generate boot.elf and place it in sector #2 of virtual disk |
---|
194 | $(BOOTLOADER_PATH)/build/boot.elf: |
---|
195 | $(MAKE) -C $(BOOTLOADER_PATH) |
---|
196 | dd if=$@ of=$(DISK_IMAGE) seek=2 conv=notrunc |
---|
197 | |
---|
198 | ###################################################### |
---|
199 | # Rule to generate HAL objects (depending on HAL_ARCH) |
---|
200 | build_hal: |
---|
201 | $(MAKE) -C $(HAL_ARCH) |
---|
202 | |
---|
203 | ############################################################# |
---|
204 | # Rule to generate kernel.elf and place it on virtual disk |
---|
205 | kernel/build/kernel.elf: build_hal |
---|
206 | $(MAKE) -C kernel/ |
---|
207 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/kernel |
---|
208 | |
---|
209 | ##################################################### |
---|
210 | # Rules to generate user.elf and copy on virtual disk |
---|
211 | user/init/build/init.elf: build_libs |
---|
212 | $(MAKE) -C user/init |
---|
213 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
214 | user/ksh/build/ksh.elf: build_libs |
---|
215 | $(MAKE) -C user/ksh |
---|
216 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
217 | user/pgcd/build/pgcd.elf: build_libs |
---|
218 | $(MAKE) -C user/pgcd |
---|
219 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
220 | user/idbg/build/idbg.elf: build_libs |
---|
221 | $(MAKE) -C user/idbg |
---|
222 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
223 | user/sort/build/sort.elf: build_libs |
---|
224 | $(MAKE) -C user/sort |
---|
225 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
226 | user/fft/build/fft.elf: build_libs |
---|
227 | $(MAKE) -C user/fft |
---|
228 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
229 | user/windows/build/windows.elf: build_libs |
---|
230 | $(MAKE) -C user/windows |
---|
231 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
232 | user/convol/build/convol.elf: build_libs |
---|
233 | $(MAKE) -C user/convol |
---|
234 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
235 | user/kleenex/build/kleenex.elf: build_libs |
---|
236 | $(MAKE) -C user/kleenex |
---|
237 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
238 | user/transpose/build/transpose.elf: build_libs |
---|
239 | $(MAKE) -C user/transpose |
---|
240 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
241 | user/udp_chat/build/udp_chat.elf: build_libs |
---|
242 | $(MAKE) -C user/udp_chat |
---|
243 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
244 | user/tcp_chat/build/tcp_chat.elf: build_libs |
---|
245 | $(MAKE) -C user/tcp_chat |
---|
246 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
247 | user/chat/build/chat.elf: build_libs |
---|
248 | $(MAKE) -C user/chat |
---|
249 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|