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