[439] | 1 | ############################################################################# |
---|
| 2 | # ALMOS-MKH Global Makefile # |
---|
| 3 | ############################################################################# |
---|
| 4 | |
---|
| 5 | -include params-soft.mk |
---|
[623] | 6 | |
---|
[439] | 7 | ifeq ($(ARCH_NAME),) |
---|
[623] | 8 | $(error Please define ARCH_NAME parameter in params-soft.mk!) |
---|
[439] | 9 | endif |
---|
| 10 | |
---|
| 11 | -include params-hard.mk |
---|
| 12 | |
---|
| 13 | # Default values for hardware parameters. |
---|
[440] | 14 | # These parameters should be defined in the 'params-hard.mk' file. |
---|
[625] | 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 |
---|
[590] | 21 | TXT_TYPE ?= TXT_TTY |
---|
| 22 | FBF_TYPE ?= FBF_SCL |
---|
| 23 | SYS_CLK ?= 50000 |
---|
[440] | 24 | |
---|
[439] | 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 |
---|
[668] | 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 \ |
---|
[681] | 49 | user/windows/build/windows.elf \ |
---|
[668] | 50 | user/convol/build/convol.elf \ |
---|
| 51 | user/transpose/build/transpose.elf \ |
---|
| 52 | user/kleenex/build/kleenex.elf \ |
---|
[689] | 53 | user/udp_chat/build/udp_chat.elf \ |
---|
| 54 | user/tcp_chat/build/tcp_chat.elf \ |
---|
[681] | 55 | user/chat/build/chat.elf |
---|
[647] | 56 | |
---|
[439] | 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 |
---|
[440] | 62 | # disk image used by ALMOS-MKH is not MS-DOS compliant. |
---|
[439] | 63 | # Setting this variable prevents these checks. |
---|
| 64 | MTOOLS_SKIP_CHECK := 1 |
---|
| 65 | |
---|
[623] | 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. |
---|
[626] | 69 | # The "home" directory on the virtual disk is not modified |
---|
[668] | 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 \ |
---|
[681] | 81 | user/windows/build/windows.elf \ |
---|
[668] | 82 | user/convol/build/convol.elf \ |
---|
| 83 | user/transpose/build/transpose.elf \ |
---|
| 84 | user/kleenex/build/kleenex.elf \ |
---|
[689] | 85 | user/udp_chat/build/udp_chat.elf \ |
---|
| 86 | user/tcp_chat/build/tcp_chat.elf \ |
---|
[681] | 87 | user/chat/build/chat.elf \ |
---|
[439] | 88 | list |
---|
| 89 | |
---|
[440] | 90 | # Rule to create the hdd directory |
---|
[439] | 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 | |
---|
[623] | 104 | ############################################################## |
---|
[439] | 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 |
---|
[457] | 114 | $(MAKE) -C $(LIBSEMAPHORE_PATH) clean |
---|
[444] | 115 | $(MAKE) -C $(LIBALMOSMKH_PATH) clean |
---|
[495] | 116 | $(MAKE) -C $(LIBMATH_PATH) clean |
---|
[439] | 117 | $(MAKE) -C user/init clean |
---|
| 118 | $(MAKE) -C user/ksh clean |
---|
| 119 | $(MAKE) -C user/sort clean |
---|
| 120 | $(MAKE) -C user/pgcd clean |
---|
[443] | 121 | $(MAKE) -C user/idbg clean |
---|
[459] | 122 | $(MAKE) -C user/fft clean |
---|
[681] | 123 | $(MAKE) -C user/windows clean |
---|
[647] | 124 | $(MAKE) -C user/convol clean |
---|
[656] | 125 | $(MAKE) -C user/kleenex clean |
---|
[647] | 126 | $(MAKE) -C user/transpose clean |
---|
[689] | 127 | $(MAKE) -C user/udp_chat clean |
---|
| 128 | $(MAKE) -C user/tcp_chat clean |
---|
[681] | 129 | $(MAKE) -C user/chat clean |
---|
[439] | 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)) |
---|
[657] | 140 | dd if=$(DISK_IMAGE) of=temp.dmg count=131072 |
---|
[625] | 141 | mv temp.dmg $(DISK_IMAGE) |
---|
[649] | 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 |
---|
[681] | 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 |
---|
[649] | 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 |
---|
[657] | 152 | mcopy -o -i $(DISK_IMAGE) images/philips_1024.raw ::/misc || true |
---|
[656] | 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 |
---|
[625] | 158 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
[610] | 159 | |
---|
[439] | 160 | ############################################################## |
---|
| 161 | # Rules to generate hardware description files (hard_config.h, |
---|
| 162 | # arch_info.bin and arch_info.xml), and update the virtual disk. |
---|
[623] | 163 | hard_config.h: $(ARCH)/arch_info.py |
---|
[649] | 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=. \ |
---|
[633] | 175 | --xml=. |
---|
[439] | 176 | mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/ || true |
---|
| 177 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 178 | |
---|
[440] | 179 | ############################################ |
---|
| 180 | # Rules to generate the user level libraries |
---|
[439] | 181 | build_libs: build_hal |
---|
[444] | 182 | $(MAKE) -C $(LIBALMOSMKH_PATH) headers |
---|
| 183 | $(MAKE) -C $(LIBPTHREAD_PATH) headers |
---|
[457] | 184 | $(MAKE) -C $(LIBSEMAPHORE_PATH) headers |
---|
[459] | 185 | $(MAKE) -C $(LIBMATH_PATH) headers |
---|
[439] | 186 | $(MAKE) -C $(LIBC_PATH) |
---|
[444] | 187 | $(MAKE) -C $(LIBALMOSMKH_PATH) |
---|
[439] | 188 | $(MAKE) -C $(LIBPTHREAD_PATH) |
---|
[457] | 189 | $(MAKE) -C $(LIBSEMAPHORE_PATH) |
---|
[459] | 190 | $(MAKE) -C $(LIBMATH_PATH) |
---|
[439] | 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 | |
---|
[457] | 198 | ###################################################### |
---|
| 199 | # Rule to generate HAL objects (depending on HAL_ARCH) |
---|
[439] | 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 | |
---|
[440] | 209 | ##################################################### |
---|
| 210 | # Rules to generate user.elf and copy on virtual disk |
---|
[439] | 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 |
---|
[440] | 217 | user/pgcd/build/pgcd.elf: build_libs |
---|
| 218 | $(MAKE) -C user/pgcd |
---|
[439] | 219 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[443] | 220 | user/idbg/build/idbg.elf: build_libs |
---|
| 221 | $(MAKE) -C user/idbg |
---|
[440] | 222 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[439] | 223 | user/sort/build/sort.elf: build_libs |
---|
| 224 | $(MAKE) -C user/sort |
---|
| 225 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[459] | 226 | user/fft/build/fft.elf: build_libs |
---|
| 227 | $(MAKE) -C user/fft |
---|
| 228 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[681] | 229 | user/windows/build/windows.elf: build_libs |
---|
| 230 | $(MAKE) -C user/windows |
---|
[647] | 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 |
---|
[656] | 235 | user/kleenex/build/kleenex.elf: build_libs |
---|
| 236 | $(MAKE) -C user/kleenex |
---|
| 237 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[647] | 238 | user/transpose/build/transpose.elf: build_libs |
---|
| 239 | $(MAKE) -C user/transpose |
---|
| 240 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[689] | 241 | user/udp_chat/build/udp_chat.elf: build_libs |
---|
| 242 | $(MAKE) -C user/udp_chat |
---|
[668] | 243 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[689] | 244 | user/tcp_chat/build/tcp_chat.elf: build_libs |
---|
| 245 | $(MAKE) -C user/tcp_chat |
---|
[668] | 246 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[681] | 247 | user/chat/build/chat.elf: build_libs |
---|
| 248 | $(MAKE) -C user/chat |
---|
| 249 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|