1a82184444c986a6113727bc7d8b1608c68d31bf
[reactos.git] / reactos / ntoskrnl / Makefile
1 # $Id: Makefile,v 1.66 2002/03/13 23:37:25 chorns Exp $
2 #
3 # ReactOS Operating System
4 #
5
6 #
7 # Path to the directory containing the root makefile
8 #
9 PATH_TO_TOP := ..
10
11 #
12 # Include details of the host OS configuration
13 #
14 include $(PATH_TO_TOP)/config
15
16 CONFIG :=
17
18 ifeq ($(DBG), 1)
19 CFLAGS_DBG := -g
20 LINKER_SCRIPT := ntoskrnl.lnk
21 STRIP_FLAGS := -Wl,-s
22 else
23 CFLAGS_DBG :=
24 LINKER_SCRIPT := ntoskrnl.lnk
25 STRIP_FLAGS := -Wl,-s
26 endif
27
28 ifeq ($(KDBG), 1)
29 OBJECTS_KDBG := dbg/kdb.o dbg/kdb_keyboard.o dbg/rdebug.o \
30 dbg/i386/kdb_help.o
31 else
32 OBJECTS_KDBG :=
33 endif
34
35 ifeq ($(strip $(SDK_PATH_INC)),)
36 ASFLAGS += -I./include
37 CFLAGS += -I./include -D__NTOSKRNL__ $(CFLAGS_DBG) -Wall -Werror
38 else
39 ASFLAGS += -I./include -I$(SDK_PATH_INC)
40 CFLAGS += -I./include -I$(SDK_PATH_INC) -D__NTOSKRNL__ $(CFLAGS_DBG) -Wall -Werror
41 endif
42
43 #
44 # Build configuration
45 #
46 include $(PATH_TO_TOP)/rules.mak
47
48
49 TARGETNAME := ntoskrnl
50
51 OBJECTS_PATH = objects
52
53 all: \
54 $(OBJECTS_PATH) \
55 bugcodes.rc \
56 $(TARGETNAME).nostrip.exe \
57 $(TARGETNAME).exe \
58 $(TARGETNAME).sym
59
60 #
61 # Architecture specific Makefile
62 # Defines $(OBJECTS_ARCH)
63 #
64 include Makefile.$(ARCH)
65
66 # System API (Nt/Zw)
67 OBJECTS_NT = \
68 nt/channel.o \
69 nt/evtpair.o \
70 nt/mutant.o \
71 nt/misc.o \
72 nt/nt.o \
73 nt/ntevent.o \
74 nt/ntsem.o \
75 nt/nttimer.o \
76 nt/plugplay.o \
77 nt/profile.o \
78 nt/zw.o \
79 nt/vdm.o
80
81 # Run-Time Library (Rtl)
82 OBJECTS_RTL = \
83 rtl/atom.o \
84 rtl/bitmap.o \
85 rtl/ctype.o \
86 rtl/error.o \
87 rtl/handle.o \
88 rtl/largeint.o \
89 rtl/mem.o \
90 rtl/memchr.o \
91 rtl/memcpy.o \
92 rtl/memmove.o \
93 rtl/memset.o \
94 rtl/message.o \
95 rtl/nls.o \
96 rtl/qsort.o \
97 rtl/regio.o \
98 rtl/seh.o \
99 rtl/sprintf.o \
100 rtl/stdlib.o \
101 rtl/string.o \
102 rtl/swprintf.o \
103 rtl/time.o \
104 rtl/timezone.o \
105 rtl/unicode.o \
106 rtl/wstring.o \
107 rtl/bitops.o \
108 rtl/memcmp.o \
109 rtl/capture.o
110
111 # Kernel (Ke)
112 OBJECTS_KE = \
113 ke/apc.o \
114 ke/bug.o \
115 ke/catch.o \
116 ke/critical.o \
117 ke/dpc.o \
118 ke/error.o \
119 ke/event.o \
120 ke/kqueue.o \
121 ke/main.o \
122 ke/mutex.o \
123 ke/process.o \
124 ke/sem.o \
125 ke/spinlock.o \
126 ke/timer.o \
127 ke/wait.o \
128 ke/kthread.o \
129 ke/queue.o
130
131 # Memory Manager (Mm)
132 OBJECTS_MM = \
133 mm/aspace.o \
134 mm/cont.o \
135 mm/freelist.o \
136 mm/iospace.o \
137 mm/marea.o \
138 mm/mdl.o \
139 mm/mm.o \
140 mm/ncache.o \
141 mm/npool.o \
142 mm/pagfault.o \
143 mm/pagefile.o \
144 mm/paging.o \
145 mm/pool.o \
146 mm/ppool.o \
147 mm/section.o \
148 mm/virtual.o \
149 mm/pager.o \
150 mm/wset.o \
151 mm/mminit.o \
152 mm/kmap.o \
153 mm/mpw.o \
154 mm/pageop.o \
155 mm/balance.o \
156 mm/rmap.o \
157 mm/slab.o
158
159 # I/O Subsystem (Io)
160 OBJECTS_IO = \
161 io/adapter.o \
162 io/arcname.o \
163 io/buildirp.o \
164 io/cancel.o \
165 io/cleanup.o \
166 io/cntrller.o \
167 io/create.o \
168 io/device.o \
169 io/dir.o \
170 io/drvlck.o \
171 io/errlog.o \
172 io/error.o \
173 io/event.o \
174 io/file.o \
175 io/flush.o \
176 io/fs.o \
177 io/iocomp.o \
178 io/ioctrl.o \
179 io/iomgr.o \
180 io/irp.o \
181 io/lock.o \
182 io/mailslot.o \
183 io/mdl.o \
184 io/npipe.o \
185 io/page.o \
186 io/parttab.o \
187 io/pnpmgr.o \
188 io/pnproot.o \
189 io/process.o \
190 io/queue.o \
191 io/resource.o \
192 io/rw.o \
193 io/share.o \
194 io/shutdown.o \
195 io/symlink.o \
196 io/timer.o \
197 io/vpb.o \
198 io/xhaldisp.o \
199 io/xhaldrv.o
200
201 # Object Manager (Ob)
202 OBJECTS_OB = \
203 ob/dirobj.o \
204 ob/handle.o \
205 ob/namespc.o \
206 ob/ntobj.o \
207 ob/object.o \
208 ob/security.o
209
210 # Process Manager (Ps)
211 OBJECTS_PS = \
212 ps/create.o \
213 ps/idle.o \
214 ps/kill.o \
215 ps/locale.o \
216 ps/process.o \
217 ps/psmgr.o \
218 ps/thread.o \
219 ps/tinfo.o \
220 ps/debug.o \
221 ps/suspend.o \
222 ps/win32.o
223
224 # Executive Subsystem (Ex)
225 OBJECTS_EX = \
226 ex/callback.o \
227 ex/fmutex.o \
228 ex/init.o \
229 ex/interlck.o \
230 ex/list.o \
231 ex/lookas.o \
232 ex/napi.o \
233 ex/power.o \
234 ex/resource.o \
235 ex/time.o \
236 ex/sysinfo.o \
237 ex/win32k.o \
238 ex/work.o \
239 ex/zone.o
240
241 # Installable File System Run-Time Library (FsRtl)
242 OBJECTS_FS = \
243 fs/dbcsname.o \
244 fs/filelock.o \
245 fs/mcb.o \
246 fs/mdl.o \
247 fs/name.o \
248 fs/notify.o \
249 fs/oplock.o \
250 fs/pool.o \
251 fs/tunnel.o \
252 fs/unc.o \
253 fs/util.o
254
255 # Security Subsystem
256 OBJECTS_SE = \
257 se/access.o \
258 se/acl.o \
259 se/lsa.o \
260 se/luid.o \
261 se/priv.o \
262 se/sd.o \
263 se/semgr.o \
264 se/sid.o \
265 se/token.o
266
267 # Configuration Manager (Registry)
268 OBJECTS_CM = \
269 cm/import.o \
270 cm/registry.o \
271 cm/ntfunc.o \
272 cm/rtlfunc.o \
273 cm/regfile.o \
274 cm/regobj.o
275
276 # Debugger Support (Dbg)
277 OBJECTS_DBG = \
278 dbg/dbgctrl.o \
279 dbg/errinfo.o \
280 dbg/print.o \
281 dbg/user.o \
282 $(OBJECTS_KDBG)
283
284 # Loader
285 OBJECTS_LDR = \
286 ldr/init.o \
287 ldr/loader.o \
288 ldr/resource.o \
289 ldr/rtl.o \
290 ldr/sysdll.o \
291 ldr/userldr.o
292
293 # Local Procedure Call (Lpc)
294 OBJECTS_LPC = \
295 lpc/close.o \
296 lpc/complete.o \
297 lpc/connect.o \
298 lpc/create.o \
299 lpc/listen.o \
300 lpc/port.o \
301 lpc/query.o \
302 lpc/queue.o \
303 lpc/receive.o \
304 lpc/reply.o \
305 lpc/send.o
306
307 # Nation Language Support Library (Nls)
308 OBJECTS_NLS = nls/nls.o
309
310 # Power Management (Po)
311 OBJECTS_PO = po/power.o
312
313 # Cache Manager (Cc)
314 OBJECTS_CC = \
315 cc/cacheman.o \
316 cc/view.o \
317 cc/copy.o \
318 cc/pin.o \
319 cc/misc.o
320
321 # Kernel Debugger Support (Kd)
322 OBJECTS_KD = \
323 kd/kdebug.o \
324 kd/service.o \
325 kd/dlog.o \
326 kd/gdbstub.o
327
328 DEP_OBJECTS := $(OBJECTS_NT) $(OBJECTS_MM) $(OBJECTS_ARCH) \
329 $(OBJECTS_IO) $(OBJECTS_KE) $(OBJECTS_OB) \
330 $(OBJECTS_PS) $(OBJECTS_EX) $(OBJECTS_CC) $(OBJECTS_FS) $(OBJECTS_SE) \
331 $(OBJECTS_DBG) $(OBJECTS_CM) $(OBJECTS_LDR) $(OBJECTS_LPC) \
332 $(OBJECTS_PO) $(OBJECTS_KD) $(OBJECTS_RTL)
333
334
335 #
336 # Include automatic dependancy tracking
337 #
338 include $(PATH_TO_TOP)/tools/depend.mk
339
340
341 # Resources
342 OBJECTS_RESOURCE = \
343 $(TARGETNAME).coff
344
345 # IMPORTS/EXPORTS
346 IE_DATA = \
347 $(TARGETNAME).def \
348 $(TARGETNAME).edf
349
350 $(OBJECTS_PATH):
351 mkdir $(OBJECTS_PATH)
352
353 $(OBJECTS_RESOURCE): $(TARGETNAME).rc bugcodes.rc $(PATH_TO_TOP)/include/reactos/resource.h
354
355 #
356 # Build subsystem intermediate objects
357 #
358 $(OBJECTS_PATH)/arch.o: $(OBJECTS_ARCH)
359 $(LD) -r -o $(OBJECTS_PATH)/arch.o $(OBJECTS_ARCH)
360
361 $(OBJECTS_PATH)/io.o: $(OBJECTS_IO)
362 $(LD) \
363 -r \
364 -o $(OBJECTS_PATH)/io.o \
365 $(OBJECTS_IO)
366
367 $(OBJECTS_PATH)/ke.o: $(OBJECTS_KE)
368 $(LD) \
369 -r \
370 -o $(OBJECTS_PATH)/ke.o \
371 $(OBJECTS_KE)
372
373 $(OBJECTS_PATH)/rtl.o: $(OBJECTS_RTL)
374 $(LD) \
375 -r \
376 -o $(OBJECTS_PATH)/rtl.o \
377 $(OBJECTS_RTL)
378
379 $(OBJECTS_PATH)/mm.o: $(OBJECTS_MM)
380 $(LD) \
381 -r \
382 -o $(OBJECTS_PATH)/mm.o \
383 $(OBJECTS_MM)
384
385 $(OBJECTS_PATH)/ob.o: $(OBJECTS_OB)
386 $(LD) \
387 -r \
388 -o $(OBJECTS_PATH)/ob.o \
389 $(OBJECTS_OB)
390
391 $(OBJECTS_PATH)/ps.o: $(OBJECTS_PS)
392 $(LD) \
393 -r \
394 -o $(OBJECTS_PATH)/ps.o \
395 $(OBJECTS_PS)
396
397 $(OBJECTS_PATH)/ex.o: $(OBJECTS_EX)
398 $(LD) \
399 -r \
400 -o $(OBJECTS_PATH)/ex.o \
401 $(OBJECTS_EX)
402
403 $(OBJECTS_PATH)/fs.o: $(OBJECTS_FS)
404 $(LD) \
405 -r \
406 -o $(OBJECTS_PATH)/fs.o \
407 $(OBJECTS_FS)
408
409 $(OBJECTS_PATH)/se.o: $(OBJECTS_SE)
410 $(LD) \
411 -r \
412 -o $(OBJECTS_PATH)/se.o \
413 $(OBJECTS_SE)
414
415 $(OBJECTS_PATH)/cm.o: $(OBJECTS_CM)
416 $(LD) \
417 -r \
418 -o $(OBJECTS_PATH)/cm.o \
419 $(OBJECTS_CM)
420
421 $(OBJECTS_PATH)/dbg.o: $(OBJECTS_DBG)
422 $(LD) \
423 -r \
424 -o $(OBJECTS_PATH)/dbg.o \
425 $(OBJECTS_DBG)
426
427 $(OBJECTS_PATH)/ldr.o: $(OBJECTS_LDR)
428 $(LD) \
429 -r \
430 -o $(OBJECTS_PATH)/ldr.o \
431 $(OBJECTS_LDR)
432
433 $(OBJECTS_PATH)/lpc.o: $(OBJECTS_LPC)
434 $(LD) \
435 -r \
436 -o $(OBJECTS_PATH)/lpc.o \
437 $(OBJECTS_LPC)
438
439 $(OBJECTS_PATH)/nls.o: $(OBJECTS_NLS)
440 $(LD) \
441 -r \
442 -o $(OBJECTS_PATH)/nls.o \
443 $(OBJECTS_NLS)
444
445 $(OBJECTS_PATH)/nt.o: $(OBJECTS_NT)
446 $(LD) \
447 -r \
448 -o $(OBJECTS_PATH)/nt.o \
449 $(OBJECTS_NT)
450
451 $(OBJECTS_PATH)/po.o: $(OBJECTS_PO)
452 $(LD) \
453 -r \
454 -o $(OBJECTS_PATH)/po.o \
455 $(OBJECTS_PO)
456
457 $(OBJECTS_PATH)/cc.o: $(OBJECTS_CC)
458 $(LD) \
459 -r \
460 -o $(OBJECTS_PATH)/cc.o \
461 $(OBJECTS_CC)
462
463 $(OBJECTS_PATH)/kd.o: $(OBJECTS_KD)
464 $(LD) \
465 -r \
466 -o $(OBJECTS_PATH)/kd.o \
467 $(OBJECTS_KD)
468
469 # Note: arch.o MUST be the first file!!!
470 OBJECTS := \
471 $(OBJECTS_PATH)/arch.o \
472 $(OBJECTS_PATH)/ke.o \
473 $(OBJECTS_PATH)/cc.o \
474 $(OBJECTS_PATH)/cm.o \
475 $(OBJECTS_PATH)/dbg.o \
476 $(OBJECTS_PATH)/ex.o \
477 $(OBJECTS_PATH)/lpc.o \
478 $(OBJECTS_PATH)/fs.o \
479 $(OBJECTS_PATH)/io.o \
480 $(OBJECTS_PATH)/kd.o \
481 $(OBJECTS_PATH)/ldr.o \
482 $(OBJECTS_PATH)/mm.o \
483 $(OBJECTS_PATH)/nls.o \
484 $(OBJECTS_PATH)/nt.o \
485 $(OBJECTS_PATH)/ob.o \
486 $(OBJECTS_PATH)/po.o \
487 $(OBJECTS_PATH)/ps.o \
488 $(OBJECTS_PATH)/rtl.o \
489 $(OBJECTS_PATH)/se.o \
490 $(OBJECTS_RESOURCE)
491
492 CLEAN_FILES = $(OBJECTS_PATH)/*.o cc/*.o cm/*.o dbg/*.o dbg/i386/*.o ex/*.o \
493 ex/i386/*.o io/*.o ke/*.o ldr/*.o mm/*.o nt/*.o ob/*.o ps/*.o \
494 rtl/*.o se/*.o ke/i386/*.o mm/i386/*.o fs/*.o po/*.o nls/*.o \
495 lpc/*.o kd/*.o $(TARGETNAME).o junk.tmp base.tmp temp.exp \
496 $(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym \
497 $(TARGETNAME).coff bugcodes.rc msg?????.bin $(DEP_FILES)
498
499 $(TARGETNAME).nostrip.exe: $(TARGETNAME).o $(IE_DATA)
500 $(CC) \
501 -Wl,-T,ntoskrnl.lnk \
502 -nostartfiles \
503 -nostdlib \
504 -mdll \
505 -o junk.tmp \
506 -Wl,--subsystem,native \
507 -Wl,--image-base,0xc0000000 \
508 -Wl,--file-alignment,0x1000 \
509 -Wl,--section-alignment,0x1000 \
510 -Wl,--base-file,base.tmp \
511 $(TARGETNAME).o -lgcc \
512 $(DDK_PATH_LIB)/hal.a
513 - $(RM) junk.tmp
514 $(DLLTOOL) \
515 --dllname $(TARGETNAME).exe \
516 --base-file base.tmp \
517 --output-exp temp.exp \
518 --def $(TARGETNAME).edf \
519 --kill-at
520 - $(RM) base.tmp
521 $(CC) \
522 -nostartfiles \
523 -nostdlib \
524 -Wl,-T,ntoskrnl.lnk \
525 -mdll \
526 -o $(TARGETNAME).nostrip.exe \
527 -Wl,--subsystem,native \
528 -Wl,--image-base,0xc0000000 \
529 -Wl,--file-alignment,0x1000 \
530 -Wl,--section-alignment,0x1000 \
531 -Wl,temp.exp \
532 $(TARGETNAME).o -lgcc \
533 $(DDK_PATH_LIB)/hal.a
534 - $(RM) temp.exp
535
536 $(TARGETNAME).exe: $(TARGETNAME).o $(LINKER_SCRIPT) $(DDK_PATH_LIB)/hal.a
537 - $(CC) \
538 -Wl,-T,$(LINKER_SCRIPT) \
539 -nostartfiles \
540 -nostdlib \
541 -mdll \
542 -o junk.tmp \
543 -Wl,--subsystem,native \
544 -Wl,--image-base,0xc0000000 \
545 -Wl,--file-alignment,0x1000 \
546 -Wl,--section-alignment,0x1000 \
547 -Wl,--base-file,base.tmp \
548 $(TARGETNAME).o -lgcc \
549 $(DDK_PATH_LIB)/hal.a
550 - $(RM) junk.tmp
551 $(DLLTOOL) \
552 --dllname $(TARGETNAME).exe \
553 --base-file base.tmp \
554 --output-exp temp.exp \
555 --def $(TARGETNAME).edf \
556 --kill-at
557 - $(RM) base.tmp
558 $(CC) \
559 -Wl,-T,$(LINKER_SCRIPT) $(STRIP_FLAGS)\
560 -nostartfiles \
561 -nostdlib \
562 -mdll \
563 -o $(TARGETNAME).exe \
564 -Wl,--subsystem,native \
565 -Wl,--image-base,0xc0000000 \
566 -Wl,--file-alignment,0x1000 \
567 -Wl,--section-alignment,0x1000 \
568 -Wl,temp.exp \
569 $(TARGETNAME).o -lgcc \
570 $(DDK_PATH_LIB)/hal.a
571 - $(RM) temp.exp
572
573 $(TARGETNAME).dbg.o: $(TARGETNAME).o
574 $(STRIP) --strip-debug -o $(TARGETNAME).dbg.o $(TARGETNAME).o
575
576 $(TARGETNAME).dbg: $(TARGETNAME).dbg.o $(TARGETNAME).a $(TARGETNAME).dbg.lnk
577 $(CC) \
578 -Wl,-T,$(TARGETNAME).dbg.lnk \
579 -nostartfiles \
580 -nostdlib \
581 -mdll \
582 -o junk.tmp \
583 -Wl,--subsystem,native \
584 -Wl,--image-base,0xc0000000 \
585 -Wl,--file-alignment,0x1000 \
586 -Wl,--section-alignment,0x1000 \
587 -Wl,--base-file,base.tmp \
588 $(TARGETNAME).dbg.o -lgcc \
589 $(DDK_PATH_LIB)/hal.a
590 - $(RM) junk.tmp
591 $(DLLTOOL) \
592 --dllname $(TARGETNAME).dbg \
593 --base-file base.tmp \
594 --output-exp temp.exp \
595 --def $(TARGETNAME).edf \
596 --kill-at
597 - $(RM) base.tmp
598 $(CC) \
599 -Wl,-T,$(TARGETNAME).dbg.lnk \
600 -nostartfiles \
601 -nostdlib \
602 -mdll \
603 -o $(TARGETNAME).dbg \
604 -Wl,--subsystem,native \
605 -Wl,--image-base,0xc0000000 \
606 -Wl,--file-alignment,0x1000 \
607 -Wl,--section-alignment,0x1000 \
608 -Wl,temp.exp \
609 $(TARGETNAME).dbg.o -lgcc \
610 $(DDK_PATH_LIB)/hal.a
611 - $(RM) temp.exp
612
613 $(TARGETNAME).sym: $(TARGETNAME).nostrip.exe
614 $(NM) --numeric-sort $(TARGETNAME).nostrip.exe > $(TARGETNAME).sym
615
616 $(TARGETNAME).o: $(OBJECTS)
617 $(LD) \
618 -r \
619 -o $(TARGETNAME).o \
620 $(OBJECTS)
621
622 bugcodes.rc: ntoskrnl.mc
623 $(MC) \
624 -H $(PATH_TO_TOP)/include/reactos/bugcodes.h \
625 -o bugcodes.rc \
626 $(TARGETNAME).mc
627
628 implib:
629 - $(DLLTOOL) \
630 --dllname $(TARGETNAME).exe \
631 --def $(TARGETNAME).def \
632 --output-lib $(DDK_PATH_LIB)/$(TARGETNAME).a \
633 --kill-at
634
635 clean:
636 - $(RM) $(CLEAN_FILES)
637
638 .PHONY: clean
639
640 install: all $(INSTALL_DIR)/system32/$(TARGETNAME).exe $(INSTALL_DIR)/symbols/$(TARGETNAME).sym
641
642 $(INSTALL_DIR)/system32/$(TARGETNAME).exe: $(TARGETNAME).exe
643 $(CP) $(TARGETNAME).exe $(INSTALL_DIR)/system32/$(TARGETNAME).exe
644
645 $(INSTALL_DIR)/symbols/$(TARGETNAME).sym: $(TARGETNAME).sym
646 $(CP) $(TARGETNAME).sym $(INSTALL_DIR)/symbols/$(TARGETNAME).sym
647
648 .PHONY: install
649
650 dist: $(DIST_DIR)/$(TARGETNAME).exe
651
652 $(DIST_DIR)/$(TARGETNAME).exe: $(TARGETNAME).exe
653 $(CP) $(TARGETNAME).exe $(DIST_DIR)/$(TARGETNAME).exe
654
655 .PHONY: dist
656
657 ex/napi.o: ex/napi.c $(PATH_TO_TOP)/include/ntdll/napi.h
658
659 ke/main.o: ke/main.c $(PATH_TO_TOP)/include/reactos/buildno.h
660
661 %.o: %.cc
662 $(CC) $(CFLAGS) -c $< -o $@
663 %.o: %.c
664 $(CC) $(CFLAGS) -c $< -o $@
665 %.o: %.S
666 $(AS) $(ASFLAGS) -c $< -o $@
667 %.o: %.s
668 $(AS) $(ASFLAGS) -c $< -o $@
669 %.o: %.asm
670 $(NASM_CMD) $(NFLAGS) $< -o $@
671 %.coff: %.rc
672 $(RC) $(RCINC) $< -o $@
673
674 # EOF