[CMAKE]
[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(ARCH MATCHES i386)
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(ARCH MATCHES i386)
48
49
50
51 set_source_files_properties(${FREELDR_BASE64K_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_")
52
53 include_directories(${REACTOS_SOURCE_DIR}/lib/cmlib)
54
55 list(APPEND FREELDR_BASE_SOURCE
56 arcemul/mm.c
57 arcemul/time.c
58 cache/blocklist.c
59 cache/cache.c
60 comm/rs232.c
61 disk/disk.c
62 disk/partition.c
63 disk/ramdisk.c
64 disk/scsiport.c
65 fs/ext2.c
66 fs/fat.c
67 fs/fs.c
68 fs/iso.c
69 fs/ntfs.c
70 inifile/ini_init.c
71 inifile/inifile.c
72 inifile/parse.c
73 mm/meminit.c
74 mm/mm.c
75 reactos/registry.c
76 reactos/arcname.c
77 reactos/archwsup.c
78 reactos/binhive.c
79 reactos/reactos.c
80 reactos/imageldr.c
81 rtl/bget.c
82 rtl/libsupp.c
83 ui/directui.c
84 ui/gui.c
85 ui/minitui.c
86 ui/noui.c
87 ui/tui.c
88 ui/tuimenu.c
89 ui/ui.c
90 video/fade.c
91 video/palette.c
92 video/video.c
93 windows/conversion.c
94 windows/peloader.c
95 windows/winldr.c
96 windows/wlmemory.c
97 windows/wlregistry.c
98 freeldr.c
99 debug.c
100 version.c
101 cmdline.c
102 machine.c
103 options.c
104 linuxboot.c
105 oslist.c)
106
107 if(ARCH MATCHES i386)
108 list(APPEND FREELDR_BASE_SOURCE
109 windows/headless.c
110 disk/scsiport.c)
111 endif(ARCH MATCHES i386)
112
113 set_source_files_properties(${FREELDR_BASE_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_;_BLDR_;_NTSYSTEM_")
114
115 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs)
116 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/elf)
117
118 if(ARCH MATCHES i386)
119 list(APPEND FREELDR_ARCH_SOURCE
120 arch/i386/archmach.c
121 arch/i386/custom.c
122 arch/i386/drivemap.c
123 arch/i386/halstub.c
124 arch/i386/hardware.c
125 arch/i386/hwacpi.c
126 arch/i386/hwapm.c
127 arch/i386/hwpci.c
128 arch/i386/i386disk.c
129 arch/i386/i386rtl.c
130 arch/i386/i386vid.c
131 arch/i386/loader.c
132 arch/i386/machpc.c
133 arch/i386/miscboot.c
134 arch/i386/ntoskrnl.c
135 arch/i386/pccons.c
136 arch/i386/pcdisk.c
137 arch/i386/pcmem.c
138 arch/i386/pcrtc.c
139 arch/i386/pcvideo.c
140 arch/i386/machxbox.c
141 arch/i386/xboxcons.c
142 arch/i386/xboxdisk.c
143 arch/i386/xboxfont.c
144 arch/i386/xboxhw.c
145 arch/i386/xboxi2c.c
146 arch/i386/xboxmem.c
147 arch/i386/xboxrtc.c
148 arch/i386/xboxvideo.c
149 windows/i386/ntsetup.c
150 windows/i386/wlmemory.c)
151 else()
152 #TBD
153 endif(ARCH MATCHES i386)
154
155 set_source_files_properties(${FREELDR_ARCH_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_;_BLDR_;_NTSYSTEM_")
156
157 list(APPEND SETUPLDR_MAIN_SOURCE
158 bootmgr.c
159 inffile/inffile.c
160 reactos/setupldr.c)
161
162 if(ARCH MATCHES i386)
163 list(APPEND SETUPLDR_MAIN_SOURCE windows/setupldr2.c)
164 elseif(ARCH MATCHES amd64)
165 list(APPEND SETUPLDR_MAIN_SOURCE windows/setupldr2.c)
166 endif(ARCH MATCHES i386)
167
168 set_source_files_properties(${SETUPLDR_MAIN_SOURCE} PROPERTIES COMPILE_FLAGS "-ffreestanding -fno-builtin -fno-inline -fno-zero-initialized-in-bss")
169
170
171
172 list(APPEND FREELDR_SOURCE
173 bootmgr.c
174 ${FREELDR_STARTUP_SOURCE}
175 ${FREELDR_BASE64K_SOURCE}
176 ${FREELDR_BASE_SOURCE}
177 ${FREELDR_ARCH_SOURCE})
178
179 add_library(freeldr SHARED
180 ${CMAKE_CURRENT_BINARY_DIR}/freeldr_freeldr.h.gch
181 ${FREELDR_SOURCE})
182
183 if(NOT MSVC)
184 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")
185 set_image_base(freeldr 0x8000)
186 else()
187 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")
188 set_image_base(freeldr 0x10000)
189 endif()
190
191 set_subsystem(freeldr native)
192 set_entrypoint(freeldr mainCRTStartup)
193
194 if(ARCH MATCHES i386)
195 target_link_libraries(freeldr mini_hal)
196 endif(ARCH MATCHES i386)
197
198 target_link_libraries(freeldr
199 cportlib
200 rossym
201 cmlib
202 rtl
203 libcntpr)
204 add_pch(freeldr ${CMAKE_CURRENT_SOURCE_DIR}/include/freeldr.h ${FREELDR_SOURCE})
205 add_dependencies(freeldr asm)
206
207 list(APPEND SETUPLDR_SOURCE
208 ${FREELDR_STARTUP_SOURCE}
209 ${FREELDR_BASE64K_SOURCE}
210 ${FREELDR_BASE_SOURCE}
211 ${FREELDR_ARCH_SOURCE}
212 ${SETUPLDR_MAIN_SOURCE})
213
214 add_library(setupldr SHARED ${SETUPLDR_SOURCE})
215
216 if(NOT MSVC)
217 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")
218 set_image_base(setupldr 0x8000)
219 else()
220 set_target_properties(setupldr PROPERTIES LINK_FLAGS "/DRIVER /SECTION:.text,ERWP,ALIGN=0x1000" SUFFIX ".sys" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP")
221 endif()
222
223 set_subsystem(setupldr native)
224 set_entrypoint(setupldr mainCRTStartup)
225
226 if(ARCH MATCHES i386)
227 target_link_libraries(setupldr mini_hal)
228 endif(ARCH MATCHES i386)
229
230 target_link_libraries(setupldr
231 cportlib
232 rossym
233 cmlib
234 rtl
235 libcntpr)
236
237 add_dependencies(setupldr asm)
238
239 # Bootcd files
240 add_minicd_target(setupldr loader setupldr.sys)
241 add_minicd_target(freeldr loader freeldr.sys)
242 add_livecd_target(setupldr loader)