[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 \ |
---|
| 43 | user/hello/build/hello.elf \ |
---|
| 44 | user/sort/build/sort.elf |
---|
[439] | 45 | |
---|
| 46 | # Virtual disk path |
---|
| 47 | DISK_IMAGE := hdd/virt_hdd.dmg |
---|
| 48 | |
---|
| 49 | # The Mtools used to build the FAT32 disk image perfom a few sanity checks, to |
---|
| 50 | # make sure that the disk is indeed an MS-DOS disk. However, the size of the |
---|
[440] | 51 | # disk image used by ALMOS-MKH is not MS-DOS compliant. |
---|
[439] | 52 | # Setting this variable prevents these checks. |
---|
| 53 | MTOOLS_SKIP_CHECK := 1 |
---|
| 54 | |
---|
[440] | 55 | # Rule to generate boot.elf, kernel.elf, all user.elf files, and update virtual disk. |
---|
| 56 | compile: dirs \ |
---|
| 57 | build_disk \ |
---|
| 58 | hard_config.h \ |
---|
| 59 | build_libs \ |
---|
[439] | 60 | $(BOOTLOADER_PATH)/build/boot.elf \ |
---|
[440] | 61 | kernel/build/kernel.elf \ |
---|
| 62 | user/init/build/init.elf \ |
---|
| 63 | user/ksh/build/ksh.elf \ |
---|
| 64 | user/pgcd/build/pgcd.elf \ |
---|
| 65 | user/hello/build/hello.elf \ |
---|
| 66 | user/sort/build/sort.elf \ |
---|
[439] | 67 | list |
---|
| 68 | |
---|
[440] | 69 | # Rule to create the hdd directory |
---|
[439] | 70 | dirs: |
---|
| 71 | @mkdir -p hdd |
---|
| 72 | |
---|
| 73 | # Rule to make a recursive list of the virtual disk content. |
---|
| 74 | list: |
---|
| 75 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 76 | |
---|
| 77 | ############################################################## |
---|
| 78 | # Rule to copy the files generated by the virtual prototype |
---|
| 79 | # from the virtual disk 'home' directory to the current directory. |
---|
| 80 | extract: |
---|
| 81 | mcopy -o -i $(DISK_IMAGE) ::/home . |
---|
| 82 | |
---|
| 83 | # Rules to delete all binary files from Unix File System |
---|
| 84 | # without modifying the virtual disk. |
---|
| 85 | clean: |
---|
| 86 | rm -f hard_config.h arch_info.xml arch_info.bin |
---|
| 87 | rm -rf build |
---|
| 88 | $(MAKE) -C kernel clean |
---|
| 89 | $(MAKE) -C $(BOOTLOADER_PATH) clean |
---|
| 90 | $(MAKE) -C $(LIBC_PATH) clean |
---|
| 91 | $(MAKE) -C $(LIBPTHREAD_PATH) clean |
---|
| 92 | $(MAKE) -C user/init clean |
---|
| 93 | $(MAKE) -C user/ksh clean |
---|
| 94 | $(MAKE) -C user/sort clean |
---|
| 95 | $(MAKE) -C user/pgcd clean |
---|
[440] | 96 | $(MAKE) -C user/hello clean |
---|
[439] | 97 | $(MAKE) -C $(HAL_ARCH) clean |
---|
| 98 | |
---|
| 99 | #################################################### |
---|
| 100 | # Rule for building a new virtual disk from scratch. |
---|
| 101 | # It creates the bin, bin/kernel, bin/user, and home directories. |
---|
| 102 | # This requires the generic Linux/MacOS 'create_dmg' script, that should be |
---|
| 103 | # placed in the same directory as this Makefile. |
---|
| 104 | build_disk: dirs |
---|
| 105 | rm -f $(DISK_IMAGE) |
---|
| 106 | ./create_dmg create $(basename $(DISK_IMAGE)) |
---|
| 107 | dd if=$(DISK_IMAGE) of=temp.dmg count=65536 |
---|
| 108 | mv temp.dmg $(DISK_IMAGE) |
---|
| 109 | mmd -o -i $(DISK_IMAGE) ::/bin || true |
---|
| 110 | mmd -o -i $(DISK_IMAGE) ::/bin/kernel || true |
---|
| 111 | mmd -o -i $(DISK_IMAGE) ::/bin/user || true |
---|
| 112 | mmd -o -i $(DISK_IMAGE) ::/home || true |
---|
| 113 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 114 | |
---|
| 115 | ############################################################## |
---|
| 116 | # Rules to generate hardware description files (hard_config.h, |
---|
| 117 | # arch_info.bin and arch_info.xml), and update the virtual disk. |
---|
| 118 | hard_config.h: build_disk $(ARCH)/arch_info.py |
---|
| 119 | tools/arch_info/genarch.py --arch=$(ARCH) \ |
---|
| 120 | --x_size=$(X_SIZE) \ |
---|
| 121 | --y_size=$(Y_SIZE) \ |
---|
| 122 | --nb_cores=$(NB_PROCS) \ |
---|
| 123 | --nb_ttys=$(NB_TTYS) \ |
---|
| 124 | --fbf_size=$(FBF_WIDTH) \ |
---|
| 125 | --ioc_type=$(IOC_TYPE) \ |
---|
| 126 | --hard=. \ |
---|
| 127 | --bin=. \ |
---|
| 128 | --xml=. |
---|
| 129 | mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/ || true |
---|
| 130 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 131 | |
---|
[440] | 132 | ############################################ |
---|
| 133 | # Rules to generate the user level libraries |
---|
[439] | 134 | build_libs: build_hal |
---|
| 135 | $(MAKE) -C $(LIBC_PATH) |
---|
| 136 | $(MAKE) -C $(LIBPTHREAD_PATH) |
---|
| 137 | |
---|
| 138 | ##################################################################### |
---|
| 139 | # Rule to generate boot.elf and place it in sector #2 of virtual disk |
---|
| 140 | $(BOOTLOADER_PATH)/build/boot.elf: |
---|
| 141 | $(MAKE) -C $(BOOTLOADER_PATH) |
---|
| 142 | dd if=$@ of=$(DISK_IMAGE) seek=2 conv=notrunc |
---|
| 143 | |
---|
[440] | 144 | ##################################################################### |
---|
| 145 | # Rule to generate boot.elf and place it in sector #2 of virtual disk |
---|
[439] | 146 | build_hal: |
---|
| 147 | $(MAKE) -C $(HAL_ARCH) |
---|
| 148 | |
---|
| 149 | ############################################################# |
---|
| 150 | # Rule to generate kernel.elf and place it on virtual disk |
---|
| 151 | kernel/build/kernel.elf: build_hal |
---|
| 152 | $(MAKE) -C kernel/ |
---|
| 153 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/kernel |
---|
| 154 | |
---|
[440] | 155 | ##################################################### |
---|
| 156 | # Rules to generate user.elf and copy on virtual disk |
---|
[439] | 157 | user/init/build/init.elf: build_libs |
---|
| 158 | $(MAKE) -C user/init |
---|
| 159 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
| 160 | user/ksh/build/ksh.elf: build_libs |
---|
| 161 | $(MAKE) -C user/ksh |
---|
| 162 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[440] | 163 | user/pgcd/build/pgcd.elf: build_libs |
---|
| 164 | $(MAKE) -C user/pgcd |
---|
[439] | 165 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[440] | 166 | user/hello/build/hello.elf: build_libs |
---|
| 167 | $(MAKE) -C user/hello |
---|
| 168 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[439] | 169 | user/sort/build/sort.elf: build_libs |
---|
| 170 | $(MAKE) -C user/sort |
---|
| 171 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|