[FREELDR]
[reactos.git] / boot / freeldr / freeldr / CMakeLists.txt
1
2 include_directories(BEFORE include)
3 include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
4
5 if(ARCH MATCHES arm)
6 if(SARCH MATCHES omap-zoom2)
7 add_definitions(-D_ZOOM2_)
8 endif()
9 endif()
10
11 if(ARCH MATCHES i386)
12 if(MSVC)
13 list(APPEND FREELDR_BASE64K_SOURCE
14 arch/i386/realmode.S)
15 else()
16 list(APPEND FREELDR_STARTUP_SOURCE
17 arch/i386/fathelp.S
18 arch/i386/arch.S)
19 endif()
20 elseif(ARCH MATCHES amd64)
21 list(APPEND FREELDR_STARTUP_SOURCE
22 arch/i386/fathelp.S
23 arch/amd64/arch.S)
24 endif()
25
26 if(ARCH MATCHES i386)
27 if(NOT MSVC)
28 list(APPEND FREELDR_BASE64K_SOURCE
29 arch/i386/boot.S
30 arch/i386/drvmap.S
31 arch/i386/i386cpu.S
32 arch/i386/i386idt.S
33 arch/i386/i386pnp.S
34 arch/i386/i386trap.S
35 arch/i386/int386.S
36 arch/i386/linux.S
37 arch/i386/mb.S
38 arch/i386/i386bug.c)
39 endif()
40 elseif(ARCH MATCHES amd64)
41 list(APPEND FREELDR_BASE64K_SOURCE
42 arch/i386/drvmap.S
43 arch/i386/i386cpu.S
44 arch/i386/i386idt.S
45 arch/i386/i386trap.S
46 arch/amd64/mb.S)
47 endif()
48
49 set_source_files_properties(${FREELDR_BASE64K_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_")
50
51 include_directories(${REACTOS_SOURCE_DIR}/lib/cmlib)
52
53 list(APPEND FREELDR_BASE_SOURCE
54 arcemul/mm.c
55 arcemul/time.c
56 cache/blocklist.c
57 cache/cache.c
58 comm/rs232.c
59 disk/disk.c
60 disk/partition.c
61 disk/ramdisk.c
62 disk/scsiport.c
63 fs/ext2.c
64 fs/fat.c
65 fs/fs.c
66 fs/iso.c
67 fs/ntfs.c
68 inifile/ini_init.c
69 inifile/inifile.c
70 inifile/parse.c
71 mm/meminit.c
72 mm/mm.c
73 reactos/registry.c
74 reactos/arcname.c
75 reactos/archwsup.c
76 reactos/binhive.c
77 reactos/reactos.c
78 reactos/imageldr.c
79 rtl/bget.c
80 rtl/libsupp.c
81 ui/directui.c
82 ui/gui.c
83 ui/minitui.c
84 ui/noui.c
85 ui/tui.c
86 ui/tuimenu.c
87 ui/ui.c
88 video/fade.c
89 video/palette.c
90 video/video.c
91 windows/conversion.c
92 windows/peloader.c
93 windows/winldr.c
94 windows/wlmemory.c
95 windows/wlregistry.c
96 freeldr.c
97 debug.c
98 version.c
99 cmdline.c
100 machine.c
101 options.c
102 linuxboot.c
103 oslist.c)
104
105 if(ARCH MATCHES i386)
106 list(APPEND FREELDR_BASE_SOURCE
107 windows/headless.c
108 disk/scsiport.c)
109 endif()
110
111 set_source_files_properties(${FREELDR_BASE_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_;_BLDR_;_NTSYSTEM_")
112
113 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs)
114 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/elf)
115
116 if(ARCH MATCHES i386)
117 list(APPEND FREELDR_ARCH_SOURCE
118 arch/i386/archmach.c
119 arch/i386/custom.c
120 arch/i386/drivemap.c
121 arch/i386/halstub.c
122 arch/i386/hardware.c
123 arch/i386/hwacpi.c
124 arch/i386/hwapm.c
125 arch/i386/hwpci.c
126 arch/i386/i386disk.c
127 arch/i386/i386rtl.c
128 arch/i386/i386vid.c
129 arch/i386/loader.c
130 arch/i386/machpc.c
131 arch/i386/miscboot.c
132 arch/i386/ntoskrnl.c
133 arch/i386/pccons.c
134 arch/i386/pcdisk.c
135 arch/i386/pcmem.c
136 arch/i386/pcrtc.c
137 arch/i386/pcvideo.c
138 arch/i386/machxbox.c
139 arch/i386/xboxcons.c
140 arch/i386/xboxdisk.c
141 arch/i386/xboxfont.c
142 arch/i386/xboxhw.c
143 arch/i386/xboxi2c.c
144 arch/i386/xboxmem.c
145 arch/i386/xboxrtc.c
146 arch/i386/xboxvideo.c
147 windows/i386/ntsetup.c
148 windows/i386/wlmemory.c)
149 else()
150 #TBD
151 endif()
152
153 set_source_files_properties(${FREELDR_ARCH_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_;_BLDR_;_NTSYSTEM_")
154 add_library(freeldr_arch ${FREELDR_ARCH_SOURCE})
155
156 list(APPEND FREELDR_SOURCE
157 bootmgr.c
158 ${FREELDR_STARTUP_SOURCE}
159 ${FREELDR_BASE64K_SOURCE}
160 ${FREELDR_BASE_SOURCE}
161 )
162
163 add_library(freeldr SHARED
164 ${CMAKE_CURRENT_BINARY_DIR}/freeldr_freeldr.h.gch
165 ${FREELDR_SOURCE})
166
167 if(NOT MSVC)
168 set_target_properties(freeldr PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk" SUFFIX ".sys")
169 set_image_base(freeldr 0x8000)
170 else()
171 set_target_properties(freeldr PROPERTIES LINK_FLAGS "/DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION" SUFFIX ".sys")
172 set_image_base(freeldr 0x10000)
173 endif()
174
175 set_subsystem(freeldr native)
176 set_entrypoint(freeldr mainCRTStartup)
177
178 if(ARCH MATCHES i386)
179 target_link_libraries(freeldr mini_hal)
180 endif()
181
182 target_link_libraries(freeldr
183 freeldr_arch
184 cportlib
185 rossym
186 cmlib
187 rtl
188 libcntpr)
189
190 add_pch(freeldr ${CMAKE_CURRENT_SOURCE_DIR}/include/freeldr.h ${FREELDR_SOURCE})
191 add_dependencies(freeldr asm)
192
193 list(APPEND SETUPLDR_MAIN_SOURCE
194 bootmgr.c
195 inffile/inffile.c
196 reactos/setupldr.c)
197
198 if(ARCH MATCHES i386 OR ARCH MATCHES amd64)
199 list(APPEND SETUPLDR_MAIN_SOURCE windows/setupldr2.c)
200 endif()
201
202 if(NOT MSVC)
203 set_source_files_properties(${SETUPLDR_MAIN_SOURCE} PROPERTIES COMPILE_FLAGS "-ffreestanding -fno-builtin -fno-inline -fno-zero-initialized-in-bss")
204 endif()
205
206 list(APPEND SETUPLDR_SOURCE
207 ${FREELDR_STARTUP_SOURCE}
208 ${FREELDR_BASE64K_SOURCE}
209 ${FREELDR_BASE_SOURCE}
210 ${SETUPLDR_MAIN_SOURCE})
211
212 add_library(setupldr SHARED ${SETUPLDR_SOURCE})
213
214 if(NOT MSVC)
215 set_target_properties(setupldr PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk" SUFFIX ".sys" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP")
216 set_image_base(setupldr 0x8000)
217 else()
218 set_target_properties(setupldr PROPERTIES LINK_FLAGS "/DRIVER /SECTION:.text,ERWP,ALIGN=0x1000" SUFFIX ".sys" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP")
219 endif()
220
221 set_subsystem(setupldr native)
222 set_entrypoint(setupldr mainCRTStartup)
223
224 if(ARCH MATCHES i386)
225 target_link_libraries(setupldr mini_hal)
226 endif()
227
228 target_link_libraries(setupldr
229 freeldr_arch
230 cportlib
231 rossym
232 cmlib
233 rtl
234 libcntpr)
235
236 add_dependencies(setupldr asm)
237
238 # Bootcd files
239 add_minicd_target(setupldr loader setupldr.sys)
240 add_minicd_target(freeldr loader freeldr.sys)
241 add_livecd_target(setupldr loader)