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