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