[BOOTDATA]: Diverse improvements for mkisofs support and ISO image configuration:
[reactos.git] / reactos / boot / CMakeLists.txt
1 ## efisys.bin
2
3 # EFI platform ID, used in environ/CMakelists.txt for bootmgfw filename naming also.
4 if(ARCH STREQUAL "amd64")
5 set(EFI_PLATFORM_ID "x64")
6 elseif(ARCH STREQUAL "i386")
7 set(EFI_PLATFORM_ID "ia32")
8 elseif(ARCH STREQUAL "ia64")
9 set(EFI_PLATFORM_ID "ia64")
10 elseif(ARCH STREQUAL "arm")
11 set(EFI_PLATFORM_ID "arm")
12 elseif(ARCH STREQUAL "aarch64")
13 set(EFI_PLATFORM_ID "aa64")
14 else()
15 message(FATAL_ERROR "Unknown ARCH '" ${ARCH} "', cannot generate a valid UEFI boot filename.")
16 endif()
17
18 add_custom_target(efisys
19 COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 EFIBOOT -boot ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/fat.bin -mkdir EFI -mkdir EFI/BOOT -add $<TARGET_FILE:bootmgfw> EFI/BOOT/boot${EFI_PLATFORM_ID}.efi
20 DEPENDS native-fatten fat bootmgfw bcd_hive
21 VERBATIM)
22
23 if(USE_MKISOFS)
24 # Create an 'empty' directory (guaranteed to be empty) to be able to add
25 # arbitrary empty directories to the ISO image using mkisofs.
26 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty)
27 endif()
28
29 # Retrieve the full paths to the generated files of the 'isoboot', 'isobtrt' and 'efisys' targets
30 set(_isoboot_file ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin) # get_target_property(_isoboot_file isoboot LOCATION)
31 set(_isobtrt_file ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isobtrt.bin) # get_target_property(_isobtrt_file isobtrt LOCATION)
32 set(_efisys_file ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin) # get_target_property(_efisys_file efisys LOCATION)
33
34 if(USE_MKISOFS)
35 # Create a mkisofs sort file to specify an explicit ordering for the boot files
36 # to place them at the beginning of the image (makes ISO image analysis easier).
37 # See mkisofs/schilytools/mkisofs/README.sort for more details.
38 # As the default file sort weight is '0', give the boot files sort weights >= 1.
39 # Note that it is sad that '-sort' does not work using grafted points, and as a
40 # result we need in particular to use the boot catalog file "path" mkisofs that
41 # mkisofs expects, that is, the boot catalog file name is appended to the first
42 # host-system path listed in the file list, whatever it is, and that does not
43 # work well if the first item is a graft point (and especially if it's a file
44 # and not a directory). To fix that, the trick is to use as the first file item
45 # the empty directory created earlier. This ensures that:
46 # - the boot catalog file path is meaningful;
47 # - since its contents are included by mkisofs in the root of the ISO image,
48 # using the empty directory ensures that no extra unwanted files are added.
49 #
50 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort "\
51 ${CMAKE_CURRENT_BINARY_DIR}/empty/boot.catalog 4
52 ${_isoboot_file} 3
53 ${_isobtrt_file} 2
54 ${_efisys_file} 1
55 ")
56 endif()
57
58 # ISO image identificator names
59 set(ISO_MANUFACTURER "ReactOS Foundation") # For both the publisher and the preparer
60 set(ISO_VOLNAME "ReactOS") # For both the Volume ID and the Volume set ID
61
62 ## BootCD
63 # Create the file list
64 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcd.lst "")
65
66 if(USE_MKISOFS)
67 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcd.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n")
68
69 add_custom_target(bootcd
70 COMMAND native-mkisofs -o ${REACTOS_BINARY_DIR}/bootcd.iso -iso-level 4
71 -publisher ${ISO_MANUFACTURER} -preparer ${ISO_MANUFACTURER} -volid ${ISO_VOLNAME} -volset ${ISO_VOLNAME}
72 -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4 -eltorito-alt-boot -eltorito-platform efi -eltorito-boot loader/efisys.bin -no-emul-boot -hide boot.catalog
73 -sort ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort
74 -no-cache-inodes -graft-points -path-list ${CMAKE_CURRENT_BINARY_DIR}/bootcd.lst
75 DEPENDS native-mkisofs
76 VERBATIM)
77 else()
78 add_custom_target(bootcd
79 COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${_isoboot_file}\#pEF,e,b${_efisys_file} @${CMAKE_CURRENT_BINARY_DIR}/bootcd.lst REACTOS ${REACTOS_BINARY_DIR}/bootcd.iso
80 DEPENDS native-cdmake efisys
81 VERBATIM)
82 endif()
83
84 ## BootCDRegTest
85 # Create the file list
86 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.lst "")
87
88 if(USE_MKISOFS)
89 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n")
90
91 add_custom_target(bootcdregtest
92 COMMAND native-mkisofs -o ${REACTOS_BINARY_DIR}/bootcdregtest.iso -iso-level 4
93 -publisher ${ISO_MANUFACTURER} -preparer ${ISO_MANUFACTURER} -volid ${ISO_VOLNAME} -volset ${ISO_VOLNAME}
94 -eltorito-boot loader/isobtrt.bin -no-emul-boot -boot-load-size 4 -eltorito-alt-boot -eltorito-platform efi -eltorito-boot loader/efisys.bin -no-emul-boot -hide boot.catalog
95 -sort ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort
96 -no-cache-inodes -graft-points -path-list ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.lst
97 DEPENDS native-mkisofs
98 VERBATIM)
99 else()
100 add_custom_target(bootcdregtest
101 COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${_isobtrt_file}\#pEF,e,b${_efisys_file} @${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.lst REACTOS ${REACTOS_BINARY_DIR}/bootcdregtest.iso
102 DEPENDS native-cdmake efisys
103 VERBATIM)
104 endif()
105
106 ## LiveCD
107 # Create the file list
108 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "")
109
110 if(USE_MKISOFS)
111 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n")
112
113 # Create the empty Desktop, Favorites, and Start Menu folders
114 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Desktop=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
115 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Favorites=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
116 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Start Menu/Programs=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
117
118 add_custom_target(livecd
119 COMMAND native-mkisofs -o ${REACTOS_BINARY_DIR}/livecd.iso -iso-level 4
120 -publisher ${ISO_MANUFACTURER} -preparer ${ISO_MANUFACTURER} -volid ${ISO_VOLNAME} -volset ${ISO_VOLNAME}
121 -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4 -eltorito-alt-boot -eltorito-platform efi -eltorito-boot loader/efisys.bin -no-emul-boot -hide boot.catalog
122 -sort ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort
123 -no-cache-inodes -graft-points -path-list ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst
124 DEPENDS native-mkisofs
125 VERBATIM)
126 else()
127 # Create the empty Desktop, Favorites, and Start Menu folders
128 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Desktop\n")
129 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Favorites\n")
130 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Start Menu/Programs\n")
131
132 add_custom_target(livecd
133 COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${_isoboot_file}\#pEF,e,b${_efisys_file} @${CMAKE_CURRENT_BINARY_DIR}/livecd.lst REACTOS ${REACTOS_BINARY_DIR}/livecd.iso
134 DEPENDS native-cdmake efisys
135 VERBATIM)
136 endif()
137
138 ## HybridCD
139 # Create the file list
140 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "")
141
142 if(USE_MKISOFS)
143 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "${CMAKE_CURRENT_BINARY_DIR}/empty\n")
144
145 # Create the empty Desktop, Favorites, and Start Menu folders
146 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Desktop=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
147 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Favorites=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
148 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Start Menu/Programs=${CMAKE_CURRENT_BINARY_DIR}/empty\n")
149
150 add_custom_target(hybridcd
151 COMMAND native-mkisofs -o ${REACTOS_BINARY_DIR}/hybridcd.iso -iso-level 4
152 -publisher ${ISO_MANUFACTURER} -preparer ${ISO_MANUFACTURER} -volid ${ISO_VOLNAME} -volset ${ISO_VOLNAME}
153 -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4 -eltorito-alt-boot -eltorito-platform efi -eltorito-boot loader/efisys.bin -no-emul-boot -hide boot.catalog
154 -sort ${CMAKE_CURRENT_BINARY_DIR}/bootfiles.sort
155 -no-cache-inodes -graft-points -path-list ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst
156 DEPENDS native-mkisofs bootcd livecd
157 VERBATIM)
158 else()
159 # Create the empty Desktop, Favorites, and Start Menu folders
160 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Desktop\n")
161 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Favorites\n")
162 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Start Menu/Programs\n")
163
164 add_custom_target(hybridcd
165 COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${_isoboot_file}\#pEF,e,b${_efisys_file} @${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst REACTOS ${REACTOS_BINARY_DIR}/hybridcd.iso
166 DEPENDS native-cdmake efisys bootcd livecd
167 VERBATIM)
168 endif()
169
170 if(USE_MKISOFS)
171 add_cd_file(TARGET efisys FILE ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin DESTINATION loader NO_CAB NOT_IN_HYBRIDCD FOR bootcd regtest livecd hybridcd)
172 endif()
173
174 add_subdirectory(freeldr)
175 add_subdirectory(bootdata)
176 add_subdirectory(environ)