Added a binary tree implementation
[reactos.git] / reactos / ntoskrnl / Makefile
1 # $Id: Makefile,v 1.67 2002/03/22 20:58:23 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/btree.o \
227 ex/callback.o \
228 ex/fmutex.o \
229 ex/hashtab.o \
230 ex/init.o \
231 ex/interlck.o \
232 ex/list.o \
233 ex/lookas.o \
234 ex/napi.o \
235 ex/power.o \
236 ex/resource.o \
237 ex/time.o \
238 ex/stree.o \
239 ex/sysinfo.o \
240 ex/win32k.o \
241 ex/work.o \
242 ex/zone.o
243
244 # Installable File System Run-Time Library (FsRtl)
245 OBJECTS_FS = \
246 fs/dbcsname.o \
247 fs/filelock.o \
248 fs/mcb.o \
249 fs/mdl.o \
250 fs/name.o \
251 fs/notify.o \
252 fs/oplock.o \
253 fs/pool.o \
254 fs/tunnel.o \
255 fs/unc.o \
256 fs/util.o
257
258 # Security Subsystem
259 OBJECTS_SE = \
260 se/access.o \
261 se/acl.o \
262 se/lsa.o \
263 se/luid.o \
264 se/priv.o \
265 se/sd.o \
266 se/semgr.o \
267 se/sid.o \
268 se/token.o
269
270 # Configuration Manager (Registry)
271 OBJECTS_CM = \
272 cm/import.o \
273 cm/registry.o \
274 cm/ntfunc.o \
275 cm/rtlfunc.o \
276 cm/regfile.o \
277 cm/regobj.o
278
279 # Debugger Support (Dbg)
280 OBJECTS_DBG = \
281 dbg/dbgctrl.o \
282 dbg/errinfo.o \
283 dbg/print.o \
284 dbg/user.o \
285 $(OBJECTS_KDBG)
286
287 # Loader
288 OBJECTS_LDR = \
289 ldr/init.o \
290 ldr/loader.o \
291 ldr/resource.o \
292 ldr/rtl.o \
293 ldr/sysdll.o \
294 ldr/userldr.o
295
296 # Local Procedure Call (Lpc)
297 OBJECTS_LPC = \
298 lpc/close.o \
299 lpc/complete.o \
300 lpc/connect.o \
301 lpc/create.o \
302 lpc/listen.o \
303 lpc/port.o \
304 lpc/query.o \
305 lpc/queue.o \
306 lpc/receive.o \
307 lpc/reply.o \
308 lpc/send.o
309
310 # Nation Language Support Library (Nls)
311 OBJECTS_NLS = nls/nls.o
312
313 # Power Management (Po)
314 OBJECTS_PO = po/power.o
315
316 # Cache Manager (Cc)
317 OBJECTS_CC = \
318 cc/cacheman.o \
319 cc/view.o \
320 cc/copy.o \
321 cc/pin.o \
322 cc/misc.o
323
324 # Kernel Debugger Support (Kd)
325 OBJECTS_KD = \
326 kd/kdebug.o \
327 kd/service.o \
328 kd/dlog.o \
329 kd/gdbstub.o
330
331 DEP_OBJECTS := $(OBJECTS_NT) $(OBJECTS_MM) $(OBJECTS_ARCH) \
332 $(OBJECTS_IO) $(OBJECTS_KE) $(OBJECTS_OB) \
333 $(OBJECTS_PS) $(OBJECTS_EX) $(OBJECTS_CC) $(OBJECTS_FS) $(OBJECTS_SE) \
334 $(OBJECTS_DBG) $(OBJECTS_CM) $(OBJECTS_LDR) $(OBJECTS_LPC) \
335 $(OBJECTS_PO) $(OBJECTS_KD) $(OBJECTS_RTL)
336
337
338 #
339 # Include automatic dependancy tracking
340 #
341 include $(PATH_TO_TOP)/tools/depend.mk
342
343
344 # Resources
345 OBJECTS_RESOURCE = \
346 $(TARGETNAME).coff
347
348 # IMPORTS/EXPORTS
349 IE_DATA = \
350 $(TARGETNAME).def \
351 $(TARGETNAME).edf
352
353 $(OBJECTS_PATH):
354 mkdir $(OBJECTS_PATH)
355
356 $(OBJECTS_RESOURCE): $(TARGETNAME).rc bugcodes.rc $(PATH_TO_TOP)/include/reactos/resource.h
357
358 #
359 # Build subsystem intermediate objects
360 #
361 $(OBJECTS_PATH)/arch.o: $(OBJECTS_ARCH)
362 $(LD) -r -o $(OBJECTS_PATH)/arch.o $(OBJECTS_ARCH)
363
364 $(OBJECTS_PATH)/io.o: $(OBJECTS_IO)
365 $(LD) \
366 -r \
367 -o $(OBJECTS_PATH)/io.o \
368 $(OBJECTS_IO)
369
370 $(OBJECTS_PATH)/ke.o: $(OBJECTS_KE)
371 $(LD) \
372 -r \
373 -o $(OBJECTS_PATH)/ke.o \
374 $(OBJECTS_KE)
375
376 $(OBJECTS_PATH)/rtl.o: $(OBJECTS_RTL)
377 $(LD) \
378 -r \
379 -o $(OBJECTS_PATH)/rtl.o \
380 $(OBJECTS_RTL)
381
382 $(OBJECTS_PATH)/mm.o: $(OBJECTS_MM)
383 $(LD) \
384 -r \
385 -o $(OBJECTS_PATH)/mm.o \
386 $(OBJECTS_MM)
387
388 $(OBJECTS_PATH)/ob.o: $(OBJECTS_OB)
389 $(LD) \
390 -r \
391 -o $(OBJECTS_PATH)/ob.o \
392 $(OBJECTS_OB)
393
394 $(OBJECTS_PATH)/ps.o: $(OBJECTS_PS)
395 $(LD) \
396 -r \
397 -o $(OBJECTS_PATH)/ps.o \
398 $(OBJECTS_PS)
399
400 $(OBJECTS_PATH)/ex.o: $(OBJECTS_EX)
401 $(LD) \
402 -r \
403 -o $(OBJECTS_PATH)/ex.o \
404 $(OBJECTS_EX)
405
406 $(OBJECTS_PATH)/fs.o: $(OBJECTS_FS)
407 $(LD) \
408 -r \
409 -o $(OBJECTS_PATH)/fs.o \
410 $(OBJECTS_FS)
411
412 $(OBJECTS_PATH)/se.o: $(OBJECTS_SE)
413 $(LD) \
414 -r \
415 -o $(OBJECTS_PATH)/se.o \
416 $(OBJECTS_SE)
417
418 $(OBJECTS_PATH)/cm.o: $(OBJECTS_CM)
419 $(LD) \
420 -r \
421 -o $(OBJECTS_PATH)/cm.o \
422 $(OBJECTS_CM)
423
424 $(OBJECTS_PATH)/dbg.o: $(OBJECTS_DBG)
425 $(LD) \
426 -r \
427 -o $(OBJECTS_PATH)/dbg.o \
428 $(OBJECTS_DBG)
429
430 $(OBJECTS_PATH)/ldr.o: $(OBJECTS_LDR)
431 $(LD) \
432 -r \
433 -o $(OBJECTS_PATH)/ldr.o \
434 $(OBJECTS_LDR)
435
436 $(OBJECTS_PATH)/lpc.o: $(OBJECTS_LPC)
437 $(LD) \
438 -r \
439 -o $(OBJECTS_PATH)/lpc.o \
440 $(OBJECTS_LPC)
441
442 $(OBJECTS_PATH)/nls.o: $(OBJECTS_NLS)
443 $(LD) \
444 -r \
445 -o $(OBJECTS_PATH)/nls.o \
446 $(OBJECTS_NLS)
447
448 $(OBJECTS_PATH)/nt.o: $(OBJECTS_NT)
449 $(LD) \
450 -r \
451 -o $(OBJECTS_PATH)/nt.o \
452 $(OBJECTS_NT)
453
454 $(OBJECTS_PATH)/po.o: $(OBJECTS_PO)
455 $(LD) \
456 -r \
457 -o $(OBJECTS_PATH)/po.o \
458 $(OBJECTS_PO)
459
460 $(OBJECTS_PATH)/cc.o: $(OBJECTS_CC)
461 $(LD) \
462 -r \
463 -o $(OBJECTS_PATH)/cc.o \
464 $(OBJECTS_CC)
465
466 $(OBJECTS_PATH)/kd.o: $(OBJECTS_KD)
467 $(LD) \
468 -r \
469 -o $(OBJECTS_PATH)/kd.o \
470 $(OBJECTS_KD)
471
472 # Note: arch.o MUST be the first file!!!
473 OBJECTS := \
474 $(OBJECTS_PATH)/arch.o \
475 $(OBJECTS_PATH)/ke.o \
476 $(OBJECTS_PATH)/cc.o \
477 $(OBJECTS_PATH)/cm.o \
478 $(OBJECTS_PATH)/dbg.o \
479 $(OBJECTS_PATH)/ex.o \
480 $(OBJECTS_PATH)/lpc.o \
481 $(OBJECTS_PATH)/fs.o \
482 $(OBJECTS_PATH)/io.o \
483 $(OBJECTS_PATH)/kd.o \
484 $(OBJECTS_PATH)/ldr.o \
485 $(OBJECTS_PATH)/mm.o \
486 $(OBJECTS_PATH)/nls.o \
487 $(OBJECTS_PATH)/nt.o \
488 $(OBJECTS_PATH)/ob.o \
489 $(OBJECTS_PATH)/po.o \
490 $(OBJECTS_PATH)/ps.o \
491 $(OBJECTS_PATH)/rtl.o \
492 $(OBJECTS_PATH)/se.o \
493 $(OBJECTS_RESOURCE)
494
495 CLEAN_FILES = $(OBJECTS_PATH)/*.o cc/*.o cm/*.o dbg/*.o dbg/i386/*.o ex/*.o \
496 ex/i386/*.o io/*.o ke/*.o ldr/*.o mm/*.o nt/*.o ob/*.o ps/*.o \
497 rtl/*.o se/*.o ke/i386/*.o mm/i386/*.o fs/*.o po/*.o nls/*.o \
498 lpc/*.o kd/*.o $(TARGETNAME).o junk.tmp base.tmp temp.exp \
499 $(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym \
500 $(TARGETNAME).coff bugcodes.rc msg?????.bin $(DEP_FILES)
501
502 $(TARGETNAME).nostrip.exe: $(TARGETNAME).o $(IE_DATA)
503 $(CC) \
504 -Wl,-T,ntoskrnl.lnk \
505 -nostartfiles \
506 -nostdlib \
507 -mdll \
508 -o junk.tmp \
509 -Wl,--subsystem,native \
510 -Wl,--image-base,0xc0000000 \
511 -Wl,--file-alignment,0x1000 \
512 -Wl,--section-alignment,0x1000 \
513 -Wl,--base-file,base.tmp \
514 $(TARGETNAME).o -lgcc \
515 $(DDK_PATH_LIB)/hal.a
516 - $(RM) junk.tmp
517 $(DLLTOOL) \
518 --dllname $(TARGETNAME).exe \
519 --base-file base.tmp \
520 --output-exp temp.exp \
521 --def $(TARGETNAME).edf \
522 --kill-at
523 - $(RM) base.tmp
524 $(CC) \
525 -nostartfiles \
526 -nostdlib \
527 -Wl,-T,ntoskrnl.lnk \
528 -mdll \
529 -o $(TARGETNAME).nostrip.exe \
530 -Wl,--subsystem,native \
531 -Wl,--image-base,0xc0000000 \
532 -Wl,--file-alignment,0x1000 \
533 -Wl,--section-alignment,0x1000 \
534 -Wl,temp.exp \
535 $(TARGETNAME).o -lgcc \
536 $(DDK_PATH_LIB)/hal.a
537 - $(RM) temp.exp
538
539 $(TARGETNAME).exe: $(TARGETNAME).o $(LINKER_SCRIPT) $(DDK_PATH_LIB)/hal.a
540 - $(CC) \
541 -Wl,-T,$(LINKER_SCRIPT) \
542 -nostartfiles \
543 -nostdlib \
544 -mdll \
545 -o junk.tmp \
546 -Wl,--subsystem,native \
547 -Wl,--image-base,0xc0000000 \
548 -Wl,--file-alignment,0x1000 \
549 -Wl,--section-alignment,0x1000 \
550 -Wl,--base-file,base.tmp \
551 $(TARGETNAME).o -lgcc \
552 $(DDK_PATH_LIB)/hal.a
553 - $(RM) junk.tmp
554 $(DLLTOOL) \
555 --dllname $(TARGETNAME).exe \
556 --base-file base.tmp \
557 --output-exp temp.exp \
558 --def $(TARGETNAME).edf \
559 --kill-at
560 - $(RM) base.tmp
561 $(CC) \
562 -Wl,-T,$(LINKER_SCRIPT) $(STRIP_FLAGS)\
563 -nostartfiles \
564 -nostdlib \
565 -mdll \
566 -o $(TARGETNAME).exe \
567 -Wl,--subsystem,native \
568 -Wl,--image-base,0xc0000000 \
569 -Wl,--file-alignment,0x1000 \
570 -Wl,--section-alignment,0x1000 \
571 -Wl,temp.exp \
572 $(TARGETNAME).o -lgcc \
573 $(DDK_PATH_LIB)/hal.a
574 - $(RM) temp.exp
575
576 $(TARGETNAME).dbg.o: $(TARGETNAME).o
577 $(STRIP) --strip-debug -o $(TARGETNAME).dbg.o $(TARGETNAME).o
578
579 $(TARGETNAME).dbg: $(TARGETNAME).dbg.o $(TARGETNAME).a $(TARGETNAME).dbg.lnk
580 $(CC) \
581 -Wl,-T,$(TARGETNAME).dbg.lnk \
582 -nostartfiles \
583 -nostdlib \
584 -mdll \
585 -o junk.tmp \
586 -Wl,--subsystem,native \
587 -Wl,--image-base,0xc0000000 \
588 -Wl,--file-alignment,0x1000 \
589 -Wl,--section-alignment,0x1000 \
590 -Wl,--base-file,base.tmp \
591 $(TARGETNAME).dbg.o -lgcc \
592 $(DDK_PATH_LIB)/hal.a
593 - $(RM) junk.tmp
594 $(DLLTOOL) \
595 --dllname $(TARGETNAME).dbg \
596 --base-file base.tmp \
597 --output-exp temp.exp \
598 --def $(TARGETNAME).edf \
599 --kill-at
600 - $(RM) base.tmp
601 $(CC) \
602 -Wl,-T,$(TARGETNAME).dbg.lnk \
603 -nostartfiles \
604 -nostdlib \
605 -mdll \
606 -o $(TARGETNAME).dbg \
607 -Wl,--subsystem,native \
608 -Wl,--image-base,0xc0000000 \
609 -Wl,--file-alignment,0x1000 \
610 -Wl,--section-alignment,0x1000 \
611 -Wl,temp.exp \
612 $(TARGETNAME).dbg.o -lgcc \
613 $(DDK_PATH_LIB)/hal.a
614 - $(RM) temp.exp
615
616 $(TARGETNAME).sym: $(TARGETNAME).nostrip.exe
617 $(NM) --numeric-sort $(TARGETNAME).nostrip.exe > $(TARGETNAME).sym
618
619 $(TARGETNAME).o: $(OBJECTS)
620 $(LD) \
621 -r \
622 -o $(TARGETNAME).o \
623 $(OBJECTS)
624
625 bugcodes.rc: ntoskrnl.mc
626 $(MC) \
627 -H $(PATH_TO_TOP)/include/reactos/bugcodes.h \
628 -o bugcodes.rc \
629 $(TARGETNAME).mc
630
631 implib:
632 - $(DLLTOOL) \
633 --dllname $(TARGETNAME).exe \
634 --def $(TARGETNAME).def \
635 --output-lib $(DDK_PATH_LIB)/$(TARGETNAME).a \
636 --kill-at
637
638 clean:
639 - $(RM) $(CLEAN_FILES)
640
641 .PHONY: clean
642
643 install: all $(INSTALL_DIR)/system32/$(TARGETNAME).exe $(INSTALL_DIR)/symbols/$(TARGETNAME).sym
644
645 $(INSTALL_DIR)/system32/$(TARGETNAME).exe: $(TARGETNAME).exe
646 $(CP) $(TARGETNAME).exe $(INSTALL_DIR)/system32/$(TARGETNAME).exe
647
648 $(INSTALL_DIR)/symbols/$(TARGETNAME).sym: $(TARGETNAME).sym
649 $(CP) $(TARGETNAME).sym $(INSTALL_DIR)/symbols/$(TARGETNAME).sym
650
651 .PHONY: install
652
653 dist: $(DIST_DIR)/$(TARGETNAME).exe
654
655 $(DIST_DIR)/$(TARGETNAME).exe: $(TARGETNAME).exe
656 $(CP) $(TARGETNAME).exe $(DIST_DIR)/$(TARGETNAME).exe
657
658 .PHONY: dist
659
660 ex/napi.o: ex/napi.c $(PATH_TO_TOP)/include/ntdll/napi.h
661
662 ke/main.o: ke/main.c $(PATH_TO_TOP)/include/reactos/buildno.h
663
664 %.o: %.cc
665 $(CC) $(CFLAGS) -c $< -o $@
666 %.o: %.c
667 $(CC) $(CFLAGS) -c $< -o $@
668 %.o: %.S
669 $(AS) $(ASFLAGS) -c $< -o $@
670 %.o: %.s
671 $(AS) $(ASFLAGS) -c $< -o $@
672 %.o: %.asm
673 $(NASM_CMD) $(NFLAGS) $< -o $@
674 %.coff: %.rc
675 $(RC) $(RCINC) $< -o $@
676
677 # EOF