[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. |
---|
| 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 | mcopy -o -i $(DISK_IMAGE) Makefile ::/home || true |
---|
| 126 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
[610] | 127 | |
---|
[439] | 128 | ############################################################## |
---|
| 129 | # Rules to generate hardware description files (hard_config.h, |
---|
| 130 | # arch_info.bin and arch_info.xml), and update the virtual disk. |
---|
[623] | 131 | hard_config.h: $(ARCH)/arch_info.py |
---|
[439] | 132 | tools/arch_info/genarch.py --arch=$(ARCH) \ |
---|
| 133 | --x_size=$(X_SIZE) \ |
---|
| 134 | --y_size=$(Y_SIZE) \ |
---|
| 135 | --nb_cores=$(NB_PROCS) \ |
---|
| 136 | --nb_ttys=$(NB_TTYS) \ |
---|
| 137 | --ioc_type=$(IOC_TYPE) \ |
---|
[590] | 138 | --txt_type=$(TXT_TYPE) \ |
---|
| 139 | --fbf_type=$(FBF_TYPE) \ |
---|
| 140 | --sys_clk=$(SYS_CLK) \ |
---|
[439] | 141 | --hard=. \ |
---|
| 142 | --bin=. \ |
---|
| 143 | --xml=. |
---|
| 144 | mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/ || true |
---|
| 145 | mdir -/ -b -i $(DISK_IMAGE) ::/ |
---|
| 146 | |
---|
[440] | 147 | ############################################ |
---|
| 148 | # Rules to generate the user level libraries |
---|
[439] | 149 | build_libs: build_hal |
---|
[444] | 150 | $(MAKE) -C $(LIBALMOSMKH_PATH) headers |
---|
| 151 | $(MAKE) -C $(LIBPTHREAD_PATH) headers |
---|
[457] | 152 | $(MAKE) -C $(LIBSEMAPHORE_PATH) headers |
---|
[459] | 153 | $(MAKE) -C $(LIBMATH_PATH) headers |
---|
[439] | 154 | $(MAKE) -C $(LIBC_PATH) |
---|
[444] | 155 | $(MAKE) -C $(LIBALMOSMKH_PATH) |
---|
[439] | 156 | $(MAKE) -C $(LIBPTHREAD_PATH) |
---|
[457] | 157 | $(MAKE) -C $(LIBSEMAPHORE_PATH) |
---|
[459] | 158 | $(MAKE) -C $(LIBMATH_PATH) |
---|
[439] | 159 | |
---|
| 160 | ##################################################################### |
---|
| 161 | # Rule to generate boot.elf and place it in sector #2 of virtual disk |
---|
| 162 | $(BOOTLOADER_PATH)/build/boot.elf: |
---|
| 163 | $(MAKE) -C $(BOOTLOADER_PATH) |
---|
| 164 | dd if=$@ of=$(DISK_IMAGE) seek=2 conv=notrunc |
---|
| 165 | |
---|
[457] | 166 | ###################################################### |
---|
| 167 | # Rule to generate HAL objects (depending on HAL_ARCH) |
---|
[439] | 168 | build_hal: |
---|
| 169 | $(MAKE) -C $(HAL_ARCH) |
---|
| 170 | |
---|
| 171 | ############################################################# |
---|
| 172 | # Rule to generate kernel.elf and place it on virtual disk |
---|
| 173 | kernel/build/kernel.elf: build_hal |
---|
| 174 | $(MAKE) -C kernel/ |
---|
| 175 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/kernel |
---|
| 176 | |
---|
[440] | 177 | ##################################################### |
---|
| 178 | # Rules to generate user.elf and copy on virtual disk |
---|
[439] | 179 | user/init/build/init.elf: build_libs |
---|
| 180 | $(MAKE) -C user/init |
---|
| 181 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
| 182 | user/ksh/build/ksh.elf: build_libs |
---|
| 183 | $(MAKE) -C user/ksh |
---|
| 184 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[440] | 185 | user/pgcd/build/pgcd.elf: build_libs |
---|
| 186 | $(MAKE) -C user/pgcd |
---|
[439] | 187 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[443] | 188 | user/idbg/build/idbg.elf: build_libs |
---|
| 189 | $(MAKE) -C user/idbg |
---|
[440] | 190 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[439] | 191 | user/sort/build/sort.elf: build_libs |
---|
| 192 | $(MAKE) -C user/sort |
---|
| 193 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|
[459] | 194 | user/fft/build/fft.elf: build_libs |
---|
| 195 | $(MAKE) -C user/fft |
---|
| 196 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user |
---|