| 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-hard.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 |  | 
|---|
| 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 | 
|---|
| 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/idbg/build/idbg.elf           \ | 
|---|
| 44 | user/sort/build/sort.elf           \ | 
|---|
| 45 | user/fft/build/fft.elf | 
|---|
| 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 | 
|---|
| 52 | # disk image used by ALMOS-MKH is not MS-DOS compliant. | 
|---|
| 53 | # Setting this variable prevents these checks. | 
|---|
| 54 | MTOOLS_SKIP_CHECK := 1 | 
|---|
| 55 |  | 
|---|
| 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                        \ | 
|---|
| 61 | $(BOOTLOADER_PATH)/build/boot.elf \ | 
|---|
| 62 | kernel/build/kernel.elf           \ | 
|---|
| 63 | user/init/build/init.elf          \ | 
|---|
| 64 | user/ksh/build/ksh.elf            \ | 
|---|
| 65 | user/pgcd/build/pgcd.elf          \ | 
|---|
| 66 | user/idbg/build/idbg.elf          \ | 
|---|
| 67 | user/sort/build/sort.elf          \ | 
|---|
| 68 | user/fft/build/fft.elf           \ | 
|---|
| 69 | list | 
|---|
| 70 |  | 
|---|
| 71 | # Rule to create the hdd directory | 
|---|
| 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 | 
|---|
| 94 | $(MAKE) -C $(LIBSEMAPHORE_PATH) clean | 
|---|
| 95 | $(MAKE) -C $(LIBALMOSMKH_PATH) clean | 
|---|
| 96 | $(MAKE) -C $(LIBMATH_PATH) clean | 
|---|
| 97 | $(MAKE) -C user/init clean | 
|---|
| 98 | $(MAKE) -C user/ksh clean | 
|---|
| 99 | $(MAKE) -C user/sort clean | 
|---|
| 100 | $(MAKE) -C user/pgcd clean | 
|---|
| 101 | $(MAKE) -C user/idbg clean | 
|---|
| 102 | $(MAKE) -C user/fft clean | 
|---|
| 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)  \ | 
|---|
| 132 | --hard=.                                \ | 
|---|
| 133 | --bin=.                                 \ | 
|---|
| 134 | --xml=. | 
|---|
| 135 | mcopy -o -i $(DISK_IMAGE) arch_info.bin ::/   || true | 
|---|
| 136 | mdir             -/ -b -i $(DISK_IMAGE) ::/ | 
|---|
| 137 |  | 
|---|
| 138 | ############################################ | 
|---|
| 139 | # Rules to generate the user level libraries | 
|---|
| 140 | build_libs: build_hal | 
|---|
| 141 | $(MAKE) -C $(LIBALMOSMKH_PATH) headers | 
|---|
| 142 | $(MAKE) -C $(LIBPTHREAD_PATH) headers | 
|---|
| 143 | $(MAKE) -C $(LIBSEMAPHORE_PATH) headers | 
|---|
| 144 | $(MAKE) -C $(LIBMATH_PATH) headers | 
|---|
| 145 | $(MAKE) -C $(LIBC_PATH) | 
|---|
| 146 | $(MAKE) -C $(LIBALMOSMKH_PATH) | 
|---|
| 147 | $(MAKE) -C $(LIBPTHREAD_PATH) | 
|---|
| 148 | $(MAKE) -C $(LIBSEMAPHORE_PATH) | 
|---|
| 149 | $(MAKE) -C $(LIBMATH_PATH) | 
|---|
| 150 |  | 
|---|
| 151 | ##################################################################### | 
|---|
| 152 | # Rule to generate boot.elf and place it in sector #2 of virtual disk | 
|---|
| 153 | $(BOOTLOADER_PATH)/build/boot.elf: | 
|---|
| 154 | $(MAKE) -C $(BOOTLOADER_PATH) | 
|---|
| 155 | dd if=$@ of=$(DISK_IMAGE) seek=2 conv=notrunc | 
|---|
| 156 |  | 
|---|
| 157 | ###################################################### | 
|---|
| 158 | # Rule to generate HAL objects (depending on HAL_ARCH) | 
|---|
| 159 | build_hal: | 
|---|
| 160 | $(MAKE) -C $(HAL_ARCH) | 
|---|
| 161 |  | 
|---|
| 162 | ############################################################# | 
|---|
| 163 | # Rule to generate kernel.elf and place it on virtual disk | 
|---|
| 164 | kernel/build/kernel.elf: build_hal | 
|---|
| 165 | $(MAKE) -C kernel/ | 
|---|
| 166 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/kernel | 
|---|
| 167 |  | 
|---|
| 168 | ##################################################### | 
|---|
| 169 | # Rules to generate user.elf and copy on virtual disk | 
|---|
| 170 | user/init/build/init.elf: build_libs | 
|---|
| 171 | $(MAKE) -C user/init | 
|---|
| 172 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user | 
|---|
| 173 | user/ksh/build/ksh.elf: build_libs | 
|---|
| 174 | $(MAKE) -C user/ksh | 
|---|
| 175 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user | 
|---|
| 176 | user/pgcd/build/pgcd.elf: build_libs | 
|---|
| 177 | $(MAKE) -C user/pgcd | 
|---|
| 178 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user | 
|---|
| 179 | user/idbg/build/idbg.elf: build_libs | 
|---|
| 180 | $(MAKE) -C user/idbg | 
|---|
| 181 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user | 
|---|
| 182 | user/sort/build/sort.elf: build_libs | 
|---|
| 183 | $(MAKE) -C user/sort | 
|---|
| 184 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user | 
|---|
| 185 | user/fft/build/fft.elf: build_libs | 
|---|
| 186 | $(MAKE) -C user/fft | 
|---|
| 187 | mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user | 
|---|