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