[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 | FBF_WIDTH ?= 256 |
---|
| 20 | IOC_TYPE ?= IOC_BDV |
---|
[440] | 21 | |
---|
[439] | 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 |
---|
[440] | 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 \ |
---|
[443] | 43 | user/idbg/build/idbg.elf \ |
---|
[459] | 44 | user/sort/build/sort.elf \ |
---|
| 45 | user/fft/build/fft.elf |
---|
[439] | 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 |
---|
[440] | 52 | # disk image used by ALMOS-MKH is not MS-DOS compliant. |
---|
[439] | 53 | # Setting this variable prevents these checks. |
---|
| 54 | MTOOLS_SKIP_CHECK := 1 |
---|
| 55 | |
---|
[440] | 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 \ |
---|
[439] | 61 | $(BOOTLOADER_PATH)/build/boot.elf \ |
---|
[440] | 62 | kernel/build/kernel.elf \ |
---|
| 63 | user/init/build/init.elf \ |
---|
| 64 | user/ksh/build/ksh.elf \ |
---|
| 65 | user/pgcd/build/pgcd.elf \ |
---|
[443] | 66 | user/idbg/build/idbg.elf \ |
---|
[440] | 67 | user/sort/build/sort.elf \ |
---|
[459] | 68 | user/fft/build/fft.elf \ |
---|
[439] | 69 | list |
---|
| 70 | |
---|
[440] | 71 | # Rule to create the hdd directory |
---|
[439] | 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 |
---|
[457] | 94 | $(MAKE) -C $(LIBSEMAPHORE_PATH) clean |
---|
[444] | 95 | $(MAKE) -C $(LIBALMOSMKH_PATH) clean |
---|
[495] | 96 | $(MAKE) -C $(LIBMATH_PATH) clean |
---|
[439] | 97 | $(MAKE) -C user/init clean |
---|
| 98 | $(MAKE) -C user/ksh clean |
---|
| 99 | $(MAKE) -C user/sort clean |
---|
| 100 | $(MAKE) -C user/pgcd clean |
---|
[443] | 101 | $(MAKE) -C user/idbg clean |
---|
[459] | 102 | $(MAKE) -C user/fft clean |
---|
[439] | 103 | $(MAKE) -C $(HAL_ARCH) clean |
---|
| 104 | |
---|
| 105 | #################################################### |
---|
| 106 | # Rule for building a new virtual disk from scratch. |
---|
| 107 | # It creates the bin, bin/kernel, bin/user, and home directories. |
---|
| 108 | # This requires the generic Linux/MacOS 'create_dmg' script, that should be |
---|
| 109 | # placed in the same directory as this Makefile. |
---|
| 110 | build_disk: dirs |
---|
| 111 | rm -f $(DISK_IMAGE) |
---|
| 112 | ./create_dmg create $(basename $(DISK_IMAGE)) |
---|
| 113 | dd if=$(DISK_IMAGE) of=temp.dmg count=65536 |
---|
| 114 | mv temp.dmg $(DISK_IMAGE) |
---|
| 115 | mmd -o -i $(DISK_IMAGE) ::/bin || true |
---|
| 116 | mmd -o -i $(DISK_IMAGE) ::/bin/kernel || true |
---|
| 117 | mmd -o -i $(DISK_IMAGE) ::/bin/user || true |
---|
| 118 | mmd -o -i $(DISK_IMAGE) ::/home || true |
---|
| 119 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 120 | |
---|
| 121 | ############################################################## |
---|
| 122 | # Rules to generate hardware description files (hard_config.h, |
---|
| 123 | # arch_info.bin and arch_info.xml), and update the virtual disk. |
---|
| 124 | hard_config.h: build_disk $(ARCH)/arch_info.py |
---|
| 125 | tools/arch_info/genarch.py --arch=$(ARCH) \ |
---|
| 126 | --x_size=$(X_SIZE) \ |
---|
| 127 | --y_size=$(Y_SIZE) \ |
---|
| 128 | --nb_cores=$(NB_PROCS) \ |
---|
| 129 | --nb_ttys=$(NB_TTYS) \ |
---|
| 130 | --fbf_size=$(FBF_WIDTH) \ |
---|
| 131 | --ioc_type=$(IOC_TYPE) \ |
---|
[548] | 132 | --sys_clk=$(SYS_CLK) \ |
---|
[553] | 133 | --segs_set=$(SEGS_SET) \ |
---|
[439] | 134 | --hard=. \ |
---|
| 135 | --bin=. \ |
---|
| 136 | --xml=. |
---|
| 137 | mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/ || true |
---|
| 138 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 139 | |
---|
[440] | 140 | ############################################ |
---|
| 141 | # Rules to generate the user level libraries |
---|
[439] | 142 | build_libs: build_hal |
---|
[444] | 143 | $(MAKE) -C $(LIBALMOSMKH_PATH) headers |
---|
| 144 | $(MAKE) -C $(LIBPTHREAD_PATH) headers |
---|
[457] | 145 | $(MAKE) -C $(LIBSEMAPHORE_PATH) headers |
---|
[459] | 146 | $(MAKE) -C $(LIBMATH_PATH) headers |
---|
[439] | 147 | $(MAKE) -C $(LIBC_PATH) |
---|
[444] | 148 | $(MAKE) -C $(LIBALMOSMKH_PATH) |
---|
[439] | 149 | $(MAKE) -C $(LIBPTHREAD_PATH) |
---|
[457] | 150 | $(MAKE) -C $(LIBSEMAPHORE_PATH) |
---|
[459] | 151 | $(MAKE) -C $(LIBMATH_PATH) |
---|
[439] | 152 | |
---|
| 153 | ##################################################################### |
---|
| 154 | # Rule to generate boot.elf and place it in sector #2 of virtual disk |
---|
| 155 | $(BOOTLOADER_PATH)/build/boot.elf: |
---|
| 156 | $(MAKE) -C $(BOOTLOADER_PATH) |
---|
| 157 | dd if=$@ of=$(DISK_IMAGE) seek=2 conv=notrunc |
---|
| 158 | |
---|
[457] | 159 | ###################################################### |
---|
| 160 | # Rule to generate HAL objects (depending on HAL_ARCH) |
---|
[439] | 161 | build_hal: |
---|
| 162 | $(MAKE) -C $(HAL_ARCH) |
---|
| 163 | |
---|
| 164 | ############################################################# |
---|
| 165 | # Rule to generate kernel.elf and place it on virtual disk |
---|
| 166 | kernel/build/kernel.elf: build_hal |
---|
| 167 | $(MAKE) -C kernel/ |
---|
| 168 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/kernel |
---|
| 169 | |
---|
[440] | 170 | ##################################################### |
---|
| 171 | # Rules to generate user.elf and copy on virtual disk |
---|
[439] | 172 | user/init/build/init.elf: build_libs |
---|
| 173 | $(MAKE) -C user/init |
---|
| 174 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
| 175 | user/ksh/build/ksh.elf: build_libs |
---|
| 176 | $(MAKE) -C user/ksh |
---|
| 177 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[440] | 178 | user/pgcd/build/pgcd.elf: build_libs |
---|
| 179 | $(MAKE) -C user/pgcd |
---|
[439] | 180 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[443] | 181 | user/idbg/build/idbg.elf: build_libs |
---|
| 182 | $(MAKE) -C user/idbg |
---|
[440] | 183 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[439] | 184 | user/sort/build/sort.elf: build_libs |
---|
| 185 | $(MAKE) -C user/sort |
---|
| 186 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[459] | 187 | user/fft/build/fft.elf: build_libs |
---|
| 188 | $(MAKE) -C user/fft |
---|
| 189 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|