1## efisys.bin 2 3# EFI platform ID, used in environ/CMakelists.txt for bootmgfw filename naming also. 4if(ARCH STREQUAL "amd64") 5 set(EFI_PLATFORM_ID "x64") 6elseif(ARCH STREQUAL "i386") 7 if(NOT (SARCH STREQUAL "pc98" OR SARCH STREQUAL "xbox")) 8 set(EFI_PLATFORM_ID "ia32") 9 endif() 10elseif(ARCH STREQUAL "ia64") 11 set(EFI_PLATFORM_ID "ia64") 12elseif(ARCH STREQUAL "arm") 13 set(EFI_PLATFORM_ID "arm") 14elseif(ARCH STREQUAL "arm64") 15 set(EFI_PLATFORM_ID "aa64") 16else() 17 message(FATAL_ERROR "Unknown ARCH '" ${ARCH} "', cannot generate a valid UEFI boot filename.") 18endif() 19 20if(DEFINED EFI_PLATFORM_ID) 21 add_custom_target(efisys 22 COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 EFIBOOT 23 -boot ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/fat.bin 24 -mkdir EFI -mkdir EFI/BOOT -add $<TARGET_FILE:uefildr> EFI/BOOT/boot${EFI_PLATFORM_ID}.efi 25 DEPENDS native-fatten fat uefildr 26 VERBATIM) 27endif() 28 29# ISO image EFI boot parameters 30set(ISO_EFI_BOOT_PARAMS) 31 32# Create an 'empty' directory (guaranteed to be empty) to be able to add 33# arbitrary empty directories to the ISO image using mkisofs. 34file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty) 35 36# Retrieve the full paths to the generated files of the 'isombr', 'isoboot', 'isobtrt' and 'efisys' targets 37set(_isombr_file ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isombr.bin) # get_target_property(_isombr_file isombr LOCATION) 38set(_isoboot_file ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin) # get_target_property(_isoboot_file isoboot LOCATION) 39set(_isobtrt_file ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isobtrt.bin) # get_target_property(_isobtrt_file isobtrt LOCATION) 40if(DEFINED EFI_PLATFORM_ID) 41 set(_efisys_file ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin) # get_target_property(_efisys_file efisys LOCATION) 42 list(APPEND ISO_EFI_BOOT_PARAMS -eltorito-alt-boot -eltorito-platform efi -eltorito-boot loader/efisys.bin -no-emul-boot) 43endif() 44 45# Create a mkisofs sort file to specify an explicit ordering for the boot files 46# to place them at the beginning of the image (makes ISO image analysis easier). 47# See mkisofs/schilytools/mkisofs/README.sort for more details. 48# As the default file sort weight is '0', give the boot files sort weights >= 1. 49# Note that it is sad that '-sort' does not work using grafted points, and as a 50# result we need in particular to use the boot catalog file "path" mkisofs that 51# mkisofs expects, that is, the boot catalog file name is appended to the first 52# host-system path listed in the file list, whatever it is, and that does not 53# work well if the first item is a graft point (and especially if it's a file 54# and not a directory). To fix that, the trick is to use as the first file item 55# the empty directory created earlier. This ensures that: 56# - the boot catalog file path is meaningful; 57# - since its contents are included by mkisofs in the root of the ISO image, 58# using the empty directory ensures that no extra unwanted files are added. 59# 60set(ISO_SORT_FILE_DATA "\ 61${CMAKE_CURRENT_BINARY_DIR}/empty/boot.catalog 4 62${_isoboot_file} 3 63${_isobtrt_file} 2 64") 65if(DEFINED EFI_PLATFORM_ID) 66 string(APPEND ISO_SORT_FILE_DATA "${_efisys_file} 1\n") 67endif() 68file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort ${ISO_SORT_FILE_DATA}) 69 70# ISO image identifier names 71set(ISO_MANUFACTURER "ReactOS Project") # For both the publisher and the preparer 72set(ISO_VOLNAME "ReactOS") # For both the Volume ID and the Volume set ID 73 74 75# Create user profile directories in the LiveImage 76function(add_allusers_profile_dirs _image_filelist _rootdir) 77 file(APPEND ${_image_filelist} "${_rootdir}/All Users/Application Data=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 78 file(APPEND ${_image_filelist} "${_rootdir}/All Users/Documents/My Music=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 79 file(APPEND ${_image_filelist} "${_rootdir}/All Users/Documents/My Pictures=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 80 file(APPEND ${_image_filelist} "${_rootdir}/All Users/Documents/My Videos=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 81 file(APPEND ${_image_filelist} "${_rootdir}/All Users/Favorites=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 82 file(APPEND ${_image_filelist} "${_rootdir}/All Users/My Documents=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 83 file(APPEND ${_image_filelist} "${_rootdir}/All Users/Start Menu/Programs/StartUp=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 84 file(APPEND ${_image_filelist} "${_rootdir}/All Users/Templates=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 85endfunction() 86function(add_user_profile_dirs _image_filelist _rootdir _username) 87 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Application Data=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 88 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Application Data/Microsoft/Internet Explorer/Quick Launch=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 89 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Cookies=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 90 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Desktop=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 91 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Favorites=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 92 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Local Settings/Application Data=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 93 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Local Settings/History=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 94 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Local Settings/Temporary Internet Files=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 95 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/My Music=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 96 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/My Pictures=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 97 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/My Videos=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 98 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/NetHood=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 99 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/PrintHood=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 100 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Recent=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 101 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/SendTo=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 102 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Start Menu/Programs=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 103 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Start Menu/Programs/Administrative Tools=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 104 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Start Menu/Programs/StartUp=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 105 file(APPEND ${_image_filelist} "${_rootdir}/${_username}/Templates=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 106endfunction() 107 108 109## BootCD 110# Create the file list 111file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcd.cmake.lst "") 112file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcd.cmake.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n") 113 114add_custom_target(bootcd 115 COMMAND native-mkisofs -quiet -o ${REACTOS_BINARY_DIR}/bootcd.iso -iso-level 4 116 -publisher ${ISO_MANUFACTURER} -preparer ${ISO_MANUFACTURER} -volid ${ISO_VOLNAME} -volset ${ISO_VOLNAME} 117 -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4 ${ISO_EFI_BOOT_PARAMS} -hide boot.catalog 118 -sort ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort 119 -no-cache-inodes -graft-points -path-list ${CMAKE_CURRENT_BINARY_DIR}/bootcd.$<CONFIG>.lst 120 COMMAND native-isohybrid -b ${_isombr_file} -t 0x96 ${REACTOS_BINARY_DIR}/bootcd.iso 121 DEPENDS isombr native-isohybrid native-mkisofs 122 VERBATIM) 123 124## BootCDRegTest 125# Create the file list 126file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.cmake.lst "") 127file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.cmake.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n") 128 129add_custom_target(bootcdregtest 130 COMMAND native-mkisofs -quiet -o ${REACTOS_BINARY_DIR}/bootcdregtest.iso -iso-level 4 131 -publisher ${ISO_MANUFACTURER} -preparer ${ISO_MANUFACTURER} -volid ${ISO_VOLNAME} -volset ${ISO_VOLNAME} 132 -eltorito-boot loader/isobtrt.bin -no-emul-boot -boot-load-size 4 ${ISO_EFI_BOOT_PARAMS} -hide boot.catalog 133 -sort ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort 134 -no-cache-inodes -graft-points -path-list ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.$<CONFIG>.lst 135 COMMAND native-isohybrid -b ${_isombr_file} -t 0x96 ${REACTOS_BINARY_DIR}/bootcdregtest.iso 136 DEPENDS isombr native-isohybrid native-mkisofs 137 VERBATIM) 138 139## LiveCD 140# Create the file list 141file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake.lst "") 142file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n") 143 144# Create TEMP dir 145file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake.lst "reactos/TEMP=${CMAKE_CURRENT_BINARY_DIR}/empty\n") 146 147# Create user profile directories 148add_allusers_profile_dirs(${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake.lst "Profiles") 149add_user_profile_dirs(${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake.lst "Profiles" "Default User") 150 151add_custom_target(livecd 152 COMMAND native-mkisofs -quiet -o ${REACTOS_BINARY_DIR}/livecd.iso -iso-level 4 153 -publisher ${ISO_MANUFACTURER} -preparer ${ISO_MANUFACTURER} -volid ${ISO_VOLNAME} -volset ${ISO_VOLNAME} 154 -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4 ${ISO_EFI_BOOT_PARAMS} -hide boot.catalog 155 -sort ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort 156 -no-cache-inodes -graft-points -path-list ${CMAKE_CURRENT_BINARY_DIR}/livecd.$<CONFIG>.lst 157 COMMAND native-isohybrid -b ${_isombr_file} -t 0x96 ${REACTOS_BINARY_DIR}/livecd.iso 158 DEPENDS isombr native-isohybrid native-mkisofs 159 VERBATIM) 160 161## HybridCD 162# Create the file list 163file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.cmake.lst "") 164file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.cmake.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n") 165 166# Create user profile directories 167add_allusers_profile_dirs(${CMAKE_CURRENT_BINARY_DIR}/hybridcd.cmake.lst "livecd/Profiles") 168add_user_profile_dirs(${CMAKE_CURRENT_BINARY_DIR}/hybridcd.cmake.lst "livecd/Profiles" "Default User") 169 170add_custom_target(hybridcd 171 COMMAND native-mkisofs -quiet -o ${REACTOS_BINARY_DIR}/hybridcd.iso -iso-level 4 172 -publisher ${ISO_MANUFACTURER} -preparer ${ISO_MANUFACTURER} -volid ${ISO_VOLNAME} -volset ${ISO_VOLNAME} 173 -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4 ${ISO_EFI_BOOT_PARAMS} -hide boot.catalog 174 -sort ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort 175 -duplicates-once -no-cache-inodes -graft-points -path-list ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.$<CONFIG>.lst 176 COMMAND native-isohybrid -b ${_isombr_file} -t 0x96 ${REACTOS_BINARY_DIR}/hybridcd.iso 177 DEPENDS bootcd livecd 178 VERBATIM) 179 180if(DEFINED EFI_PLATFORM_ID) 181 # For things like flashing USB drives, we also add the efi file into efi/boot. 182 add_cd_file(TARGET efisys FILE ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin DESTINATION loader NO_CAB NOT_IN_HYBRIDCD FOR bootcd regtest livecd hybridcd) 183 184 add_cd_file( 185 TARGET uefildr 186 DESTINATION efi/boot 187 NO_CAB 188 NAME_ON_CD boot${EFI_PLATFORM_ID}.efi 189 FOR livecd hybridcd) 190endif() 191