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