[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 \ |
---|
| 49 | user/display/build/display.elf \ |
---|
| 50 | user/convol/build/convol.elf \ |
---|
| 51 | user/transpose/build/transpose.elf \ |
---|
| 52 | user/kleenex/build/kleenex.elf \ |
---|
| 53 | user/tcp_server/build/tcp_server.elf \ |
---|
| 54 | user/tcp_client/build/tcp_client.elf |
---|
[647] | 55 | |
---|
[439] | 56 | # Virtual disk path |
---|
| 57 | DISK_IMAGE := hdd/virt_hdd.dmg |
---|
| 58 | |
---|
| 59 | # The Mtools used to build the FAT32 disk image perfom a few sanity checks, to |
---|
| 60 | # make sure that the disk is indeed an MS-DOS disk. However, the size of the |
---|
[440] | 61 | # disk image used by ALMOS-MKH is not MS-DOS compliant. |
---|
[439] | 62 | # Setting this variable prevents these checks. |
---|
| 63 | MTOOLS_SKIP_CHECK := 1 |
---|
| 64 | |
---|
[623] | 65 | ########################################################################################## |
---|
| 66 | # Rule to generate boot.elf, kernel.elf, all user.elf files, and update the virtual disk |
---|
| 67 | # when the corresponding sources files have been modified or destroyed. |
---|
[626] | 68 | # The "home" directory on the virtual disk is not modified |
---|
[668] | 69 | compile: dirs \ |
---|
| 70 | hard_config.h \ |
---|
| 71 | build_libs \ |
---|
| 72 | $(BOOTLOADER_PATH)/build/boot.elf \ |
---|
| 73 | kernel/build/kernel.elf \ |
---|
| 74 | user/init/build/init.elf \ |
---|
| 75 | user/ksh/build/ksh.elf \ |
---|
| 76 | user/pgcd/build/pgcd.elf \ |
---|
| 77 | user/idbg/build/idbg.elf \ |
---|
| 78 | user/sort/build/sort.elf \ |
---|
| 79 | user/fft/build/fft.elf \ |
---|
| 80 | user/display/build/display.elf \ |
---|
| 81 | user/convol/build/convol.elf \ |
---|
| 82 | user/transpose/build/transpose.elf \ |
---|
| 83 | user/kleenex/build/kleenex.elf \ |
---|
| 84 | user/tcp_server/build/tcp_server.elf \ |
---|
| 85 | user/tcp_client/build/tcp_client.elf \ |
---|
[439] | 86 | list |
---|
| 87 | |
---|
[440] | 88 | # Rule to create the hdd directory |
---|
[439] | 89 | dirs: |
---|
| 90 | @mkdir -p hdd |
---|
| 91 | |
---|
| 92 | # Rule to make a recursive list of the virtual disk content. |
---|
| 93 | list: |
---|
| 94 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 95 | |
---|
| 96 | ############################################################## |
---|
| 97 | # Rule to copy the files generated by the virtual prototype |
---|
| 98 | # from the virtual disk 'home' directory to the current directory. |
---|
| 99 | extract: |
---|
| 100 | mcopy -o -i $(DISK_IMAGE) ::/home . |
---|
| 101 | |
---|
[623] | 102 | ############################################################## |
---|
[439] | 103 | # Rules to delete all binary files from Unix File System |
---|
| 104 | # without modifying the virtual disk. |
---|
| 105 | clean: |
---|
| 106 | rm -f hard_config.h arch_info.xml arch_info.bin |
---|
| 107 | rm -rf build |
---|
| 108 | $(MAKE) -C kernel clean |
---|
| 109 | $(MAKE) -C $(BOOTLOADER_PATH) clean |
---|
| 110 | $(MAKE) -C $(LIBC_PATH) clean |
---|
| 111 | $(MAKE) -C $(LIBPTHREAD_PATH) clean |
---|
[457] | 112 | $(MAKE) -C $(LIBSEMAPHORE_PATH) clean |
---|
[444] | 113 | $(MAKE) -C $(LIBALMOSMKH_PATH) clean |
---|
[495] | 114 | $(MAKE) -C $(LIBMATH_PATH) clean |
---|
[439] | 115 | $(MAKE) -C user/init clean |
---|
| 116 | $(MAKE) -C user/ksh clean |
---|
| 117 | $(MAKE) -C user/sort clean |
---|
| 118 | $(MAKE) -C user/pgcd clean |
---|
[443] | 119 | $(MAKE) -C user/idbg clean |
---|
[459] | 120 | $(MAKE) -C user/fft clean |
---|
[647] | 121 | $(MAKE) -C user/display clean |
---|
| 122 | $(MAKE) -C user/convol clean |
---|
[656] | 123 | $(MAKE) -C user/kleenex clean |
---|
[647] | 124 | $(MAKE) -C user/transpose clean |
---|
[668] | 125 | $(MAKE) -C user/tcp_server clean |
---|
| 126 | $(MAKE) -C user/tcp_client clean |
---|
[439] | 127 | $(MAKE) -C $(HAL_ARCH) clean |
---|
| 128 | |
---|
| 129 | #################################################### |
---|
| 130 | # Rule for building a new virtual disk from scratch. |
---|
| 131 | # It creates the bin, bin/kernel, bin/user, and home directories. |
---|
| 132 | # This requires the generic Linux/MacOS 'create_dmg' script, that should be |
---|
| 133 | # placed in the same directory as this Makefile. |
---|
| 134 | build_disk: dirs |
---|
| 135 | rm -f $(DISK_IMAGE) |
---|
| 136 | ./create_dmg create $(basename $(DISK_IMAGE)) |
---|
[657] | 137 | dd if=$(DISK_IMAGE) of=temp.dmg count=131072 |
---|
[625] | 138 | mv temp.dmg $(DISK_IMAGE) |
---|
[649] | 139 | mmd -o -i $(DISK_IMAGE) ::/bin || true |
---|
| 140 | mmd -o -i $(DISK_IMAGE) ::/bin/kernel || true |
---|
| 141 | mmd -o -i $(DISK_IMAGE) ::/bin/user || true |
---|
| 142 | mmd -o -i $(DISK_IMAGE) ::/home || true |
---|
| 143 | mmd -o -i $(DISK_IMAGE) ::/misc || true |
---|
| 144 | mcopy -o -i $(DISK_IMAGE) images/lena_256.raw ::/misc || true |
---|
| 145 | mcopy -o -i $(DISK_IMAGE) images/images_128.raw ::/misc || true |
---|
[657] | 146 | mcopy -o -i $(DISK_IMAGE) images/philips_1024.raw ::/misc || true |
---|
[656] | 147 | mcopy -o -i $(DISK_IMAGE) images/couple_512.raw ::/misc || true |
---|
| 148 | mcopy -o -i $(DISK_IMAGE) images/wood_32.raw ::/misc || true |
---|
| 149 | mcopy -o -i $(DISK_IMAGE) images/door_32.raw ::/misc || true |
---|
| 150 | mcopy -o -i $(DISK_IMAGE) images/rock_32.raw ::/misc || true |
---|
| 151 | mcopy -o -i $(DISK_IMAGE) images/handle_32.raw ::/misc || true |
---|
[625] | 152 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
[610] | 153 | |
---|
[439] | 154 | ############################################################## |
---|
| 155 | # Rules to generate hardware description files (hard_config.h, |
---|
| 156 | # arch_info.bin and arch_info.xml), and update the virtual disk. |
---|
[623] | 157 | hard_config.h: $(ARCH)/arch_info.py |
---|
[649] | 158 | tools/arch_info/genarch.py --arch=$(ARCH) \ |
---|
| 159 | --x_size=$(X_SIZE) \ |
---|
| 160 | --y_size=$(Y_SIZE) \ |
---|
| 161 | --nb_cores=$(NB_PROCS) \ |
---|
| 162 | --nb_ttys=$(NB_TTYS) \ |
---|
| 163 | --ioc_type=$(IOC_TYPE) \ |
---|
| 164 | --txt_type=$(TXT_TYPE) \ |
---|
| 165 | --fbf_type=$(FBF_TYPE) \ |
---|
| 166 | --sys_clk=$(SYS_CLK) \ |
---|
| 167 | --hard=. \ |
---|
| 168 | --bin=. \ |
---|
[633] | 169 | --xml=. |
---|
[439] | 170 | mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/ || true |
---|
| 171 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 172 | |
---|
[440] | 173 | ############################################ |
---|
| 174 | # Rules to generate the user level libraries |
---|
[439] | 175 | build_libs: build_hal |
---|
[444] | 176 | $(MAKE) -C $(LIBALMOSMKH_PATH) headers |
---|
| 177 | $(MAKE) -C $(LIBPTHREAD_PATH) headers |
---|
[457] | 178 | $(MAKE) -C $(LIBSEMAPHORE_PATH) headers |
---|
[459] | 179 | $(MAKE) -C $(LIBMATH_PATH) headers |
---|
[439] | 180 | $(MAKE) -C $(LIBC_PATH) |
---|
[444] | 181 | $(MAKE) -C $(LIBALMOSMKH_PATH) |
---|
[439] | 182 | $(MAKE) -C $(LIBPTHREAD_PATH) |
---|
[457] | 183 | $(MAKE) -C $(LIBSEMAPHORE_PATH) |
---|
[459] | 184 | $(MAKE) -C $(LIBMATH_PATH) |
---|
[439] | 185 | |
---|
| 186 | ##################################################################### |
---|
| 187 | # Rule to generate boot.elf and place it in sector #2 of virtual disk |
---|
| 188 | $(BOOTLOADER_PATH)/build/boot.elf: |
---|
| 189 | $(MAKE) -C $(BOOTLOADER_PATH) |
---|
| 190 | dd if=$@ of=$(DISK_IMAGE) seek=2 conv=notrunc |
---|
| 191 | |
---|
[457] | 192 | ###################################################### |
---|
| 193 | # Rule to generate HAL objects (depending on HAL_ARCH) |
---|
[439] | 194 | build_hal: |
---|
| 195 | $(MAKE) -C $(HAL_ARCH) |
---|
| 196 | |
---|
| 197 | ############################################################# |
---|
| 198 | # Rule to generate kernel.elf and place it on virtual disk |
---|
| 199 | kernel/build/kernel.elf: build_hal |
---|
| 200 | $(MAKE) -C kernel/ |
---|
| 201 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/kernel |
---|
| 202 | |
---|
[440] | 203 | ##################################################### |
---|
| 204 | # Rules to generate user.elf and copy on virtual disk |
---|
[439] | 205 | user/init/build/init.elf: build_libs |
---|
| 206 | $(MAKE) -C user/init |
---|
| 207 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
| 208 | user/ksh/build/ksh.elf: build_libs |
---|
| 209 | $(MAKE) -C user/ksh |
---|
| 210 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[440] | 211 | user/pgcd/build/pgcd.elf: build_libs |
---|
| 212 | $(MAKE) -C user/pgcd |
---|
[439] | 213 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[443] | 214 | user/idbg/build/idbg.elf: build_libs |
---|
| 215 | $(MAKE) -C user/idbg |
---|
[440] | 216 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[439] | 217 | user/sort/build/sort.elf: build_libs |
---|
| 218 | $(MAKE) -C user/sort |
---|
| 219 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[459] | 220 | user/fft/build/fft.elf: build_libs |
---|
| 221 | $(MAKE) -C user/fft |
---|
| 222 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[647] | 223 | user/display/build/display.elf: build_libs |
---|
| 224 | $(MAKE) -C user/display |
---|
| 225 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
| 226 | user/convol/build/convol.elf: build_libs |
---|
| 227 | $(MAKE) -C user/convol |
---|
| 228 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[656] | 229 | user/kleenex/build/kleenex.elf: build_libs |
---|
| 230 | $(MAKE) -C user/kleenex |
---|
| 231 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[647] | 232 | user/transpose/build/transpose.elf: build_libs |
---|
| 233 | $(MAKE) -C user/transpose |
---|
| 234 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[668] | 235 | user/tcp_server/build/tcp_server.elf: build_libs |
---|
| 236 | $(MAKE) -C user/tcp_server |
---|
| 237 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
| 238 | user/tcp_client/build/tcp_client.elf: build_libs |
---|
| 239 | $(MAKE) -C user/tcp_client |
---|
| 240 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|