[439] | 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. |
---|
[440] | 13 | # These parameters should be defined in the 'params-hard.mk' file. |
---|
[439] | 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 |
---|
[590] | 20 | TXT_TYPE ?= TXT_TTY |
---|
| 21 | FBF_TYPE ?= FBF_SCL |
---|
| 22 | SYS_CLK ?= 50000 |
---|
[440] | 23 | |
---|
[439] | 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 |
---|
[440] | 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 \ |
---|
[443] | 45 | user/idbg/build/idbg.elf \ |
---|
[459] | 46 | user/sort/build/sort.elf \ |
---|
| 47 | user/fft/build/fft.elf |
---|
[439] | 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 |
---|
[440] | 54 | # disk image used by ALMOS-MKH is not MS-DOS compliant. |
---|
[439] | 55 | # Setting this variable prevents these checks. |
---|
| 56 | MTOOLS_SKIP_CHECK := 1 |
---|
| 57 | |
---|
[440] | 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 \ |
---|
[439] | 63 | $(BOOTLOADER_PATH)/build/boot.elf \ |
---|
[440] | 64 | kernel/build/kernel.elf \ |
---|
| 65 | user/init/build/init.elf \ |
---|
| 66 | user/ksh/build/ksh.elf \ |
---|
| 67 | user/pgcd/build/pgcd.elf \ |
---|
[443] | 68 | user/idbg/build/idbg.elf \ |
---|
[440] | 69 | user/sort/build/sort.elf \ |
---|
[459] | 70 | user/fft/build/fft.elf \ |
---|
[439] | 71 | list |
---|
| 72 | |
---|
[440] | 73 | # Rule to create the hdd directory |
---|
[439] | 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 |
---|
[457] | 96 | $(MAKE) -C $(LIBSEMAPHORE_PATH) clean |
---|
[444] | 97 | $(MAKE) -C $(LIBALMOSMKH_PATH) clean |
---|
[495] | 98 | $(MAKE) -C $(LIBMATH_PATH) clean |
---|
[439] | 99 | $(MAKE) -C user/init clean |
---|
| 100 | $(MAKE) -C user/ksh clean |
---|
| 101 | $(MAKE) -C user/sort clean |
---|
| 102 | $(MAKE) -C user/pgcd clean |
---|
[443] | 103 | $(MAKE) -C user/idbg clean |
---|
[459] | 104 | $(MAKE) -C user/fft clean |
---|
[439] | 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 |
---|
[610] | 121 | mcopy -o -i $(DISK_IMAGE) Makefile ::/home |
---|
[439] | 122 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
[610] | 123 | |
---|
[439] | 124 | ############################################################## |
---|
| 125 | # Rules to generate hardware description files (hard_config.h, |
---|
| 126 | # arch_info.bin and arch_info.xml), and update the virtual disk. |
---|
| 127 | hard_config.h: build_disk $(ARCH)/arch_info.py |
---|
| 128 | tools/arch_info/genarch.py --arch=$(ARCH) \ |
---|
| 129 | --x_size=$(X_SIZE) \ |
---|
| 130 | --y_size=$(Y_SIZE) \ |
---|
| 131 | --nb_cores=$(NB_PROCS) \ |
---|
| 132 | --nb_ttys=$(NB_TTYS) \ |
---|
| 133 | --ioc_type=$(IOC_TYPE) \ |
---|
[590] | 134 | --txt_type=$(TXT_TYPE) \ |
---|
| 135 | --fbf_type=$(FBF_TYPE) \ |
---|
| 136 | --sys_clk=$(SYS_CLK) \ |
---|
[439] | 137 | --hard=. \ |
---|
| 138 | --bin=. \ |
---|
| 139 | --xml=. |
---|
| 140 | mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/ || true |
---|
| 141 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 142 | |
---|
[440] | 143 | ############################################ |
---|
| 144 | # Rules to generate the user level libraries |
---|
[439] | 145 | build_libs: build_hal |
---|
[444] | 146 | $(MAKE) -C $(LIBALMOSMKH_PATH) headers |
---|
| 147 | $(MAKE) -C $(LIBPTHREAD_PATH) headers |
---|
[457] | 148 | $(MAKE) -C $(LIBSEMAPHORE_PATH) headers |
---|
[459] | 149 | $(MAKE) -C $(LIBMATH_PATH) headers |
---|
[439] | 150 | $(MAKE) -C $(LIBC_PATH) |
---|
[444] | 151 | $(MAKE) -C $(LIBALMOSMKH_PATH) |
---|
[439] | 152 | $(MAKE) -C $(LIBPTHREAD_PATH) |
---|
[457] | 153 | $(MAKE) -C $(LIBSEMAPHORE_PATH) |
---|
[459] | 154 | $(MAKE) -C $(LIBMATH_PATH) |
---|
[439] | 155 | |
---|
| 156 | ##################################################################### |
---|
| 157 | # Rule to generate boot.elf and place it in sector #2 of virtual disk |
---|
| 158 | $(BOOTLOADER_PATH)/build/boot.elf: |
---|
| 159 | $(MAKE) -C $(BOOTLOADER_PATH) |
---|
| 160 | dd if=$@ of=$(DISK_IMAGE) seek=2 conv=notrunc |
---|
| 161 | |
---|
[457] | 162 | ###################################################### |
---|
| 163 | # Rule to generate HAL objects (depending on HAL_ARCH) |
---|
[439] | 164 | build_hal: |
---|
| 165 | $(MAKE) -C $(HAL_ARCH) |
---|
| 166 | |
---|
| 167 | ############################################################# |
---|
| 168 | # Rule to generate kernel.elf and place it on virtual disk |
---|
| 169 | kernel/build/kernel.elf: build_hal |
---|
| 170 | $(MAKE) -C kernel/ |
---|
| 171 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/kernel |
---|
| 172 | |
---|
[440] | 173 | ##################################################### |
---|
| 174 | # Rules to generate user.elf and copy on virtual disk |
---|
[439] | 175 | user/init/build/init.elf: build_libs |
---|
| 176 | $(MAKE) -C user/init |
---|
| 177 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
| 178 | user/ksh/build/ksh.elf: build_libs |
---|
| 179 | $(MAKE) -C user/ksh |
---|
| 180 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[440] | 181 | user/pgcd/build/pgcd.elf: build_libs |
---|
| 182 | $(MAKE) -C user/pgcd |
---|
[439] | 183 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[443] | 184 | user/idbg/build/idbg.elf: build_libs |
---|
| 185 | $(MAKE) -C user/idbg |
---|
[440] | 186 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[439] | 187 | user/sort/build/sort.elf: build_libs |
---|
| 188 | $(MAKE) -C user/sort |
---|
| 189 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[459] | 190 | user/fft/build/fft.elf: build_libs |
---|
| 191 | $(MAKE) -C user/fft |
---|
| 192 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|