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