More sensible dependencies scheme for configuration
[reactos.git] / reactos / ntoskrnl / Makefile
1 # $Id: Makefile,v 1.32 2001/04/10 22:13:22 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 # Include details of the kernel configuration
13 #
14 include config
15
16 #
17 #
18 #
19 CONFIG :=
20
21 ifeq ($(DBG), 1)
22 CFLAGS_DBG := -g
23 CONFIG += DBG
24 else
25 CFLAGS_DBG :=
26 endif
27
28 ifeq ($(KDBG), 1)
29 OBJECTS_KDBG := dbg/kdb.o dbg/kdb_keyboard.o dbg/i386/kdb_help.o
30 CONFIG += KDBG
31 else
32 OBJECTS_KDBG :=
33 endif
34
35 ifeq ($(MP), 1)
36 CONFIG += MP
37 else
38 CONFIG += UP
39 endif
40
41 TARGETNAME := ntoskrnl
42
43 OBJECTS_PATH = objects
44
45 ASFLAGS = -Iinclude
46 CFLAGS = -Iinclude -D__NTOSKRNL__ $(CFLAGS_DBG) -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 $(OBJECTS_KDBG)
269
270 # Loader
271 OBJECTS_LDR = \
272 ldr/init.o \
273 ldr/loader.o \
274 ldr/resource.o \
275 ldr/rtl.o \
276 ldr/sysdll.o \
277 ldr/userldr.o
278
279 # Local Procedure Call (Lpc)
280 OBJECTS_LPC = \
281 lpc/close.o \
282 lpc/complete.o \
283 lpc/connect.o \
284 lpc/create.o \
285 lpc/listen.o \
286 lpc/port.o \
287 lpc/query.o \
288 lpc/queue.o \
289 lpc/receive.o \
290 lpc/reply.o \
291 lpc/send.o
292
293 # Nation Language Support Library (Nls)
294 OBJECTS_NLS = nls/nls.o
295
296 # Power Management (Po)
297 OBJECTS_PO = po/power.o
298
299 # Cache Manager (Cc)
300 OBJECTS_CC = \
301 cc/cacheman.o \
302 cc/view.o
303
304 # Kernel Debugger Support (Kd)
305 OBJECTS_KD = \
306 kd/kdebug.o \
307 kd/service.o \
308 kd/dlog.o
309
310 C_OBJECTS := $(OBJECTS_NT) $(OBJECTS_HAL) $(OBJECTS_MM) $(OBJECTS_ARCH) \
311 $(OBJECTS_IO) $(OBJECTS_KE) $(OBJECTS_OB) \
312 $(OBJECTS_PS) $(OBJECTS_EX) $(OBJECTS_CC) $(OBJECTS_FS) $(OBJECTS_SE) \
313 $(OBJECTS_DBG) $(OBJECTS_CM) $(OBJECTS_LDR) $(OBJECTS_LPC) \
314 $(OBJECTS_PO) $(OBJECTS_KD) $(OBJECTS_RTL)
315
316 D_FILES := $(filter-out ex/napi.%, $(filter-out nt/zw.%, $(C_OBJECTS:.o=.d)))
317 D1_FILES := $(join $(dir $(D_FILES)), $(addprefix ., $(notdir $(D_FILES))))
318
319 # Resources
320 OBJECTS_RESOURCE = \
321 $(TARGETNAME).coff
322
323 # IMPORTS/EXPORTS
324 IE_DATA = \
325 $(TARGETNAME).def \
326 $(TARGETNAME).edf
327
328 $(OBJECTS_PATH):
329 mkdir $(OBJECTS_PATH)
330
331 #
332 # Build subsystem intermediate objects
333 #
334 $(OBJECTS_PATH)/hal.o: $(OBJECTS_HAL)
335 $(LD) \
336 -r \
337 -o $(OBJECTS_PATH)/hal.o \
338 $(OBJECTS_HAL)
339
340 $(OBJECTS_PATH)/arch.o: $(OBJECTS_ARCH)
341 $(LD) -r -o $(OBJECTS_PATH)/arch.o $(OBJECTS_ARCH)
342
343 $(OBJECTS_PATH)/io.o: $(OBJECTS_IO)
344 $(LD) \
345 -r \
346 -o $(OBJECTS_PATH)/io.o \
347 $(OBJECTS_IO)
348
349 $(OBJECTS_PATH)/ke.o: $(OBJECTS_KE)
350 $(LD) \
351 -r \
352 -o $(OBJECTS_PATH)/ke.o \
353 $(OBJECTS_KE)
354
355 $(OBJECTS_PATH)/rtl.o: $(OBJECTS_RTL)
356 $(LD) \
357 -r \
358 -o $(OBJECTS_PATH)/rtl.o \
359 $(OBJECTS_RTL)
360
361 $(OBJECTS_PATH)/mm.o: $(OBJECTS_MM)
362 $(LD) \
363 -r \
364 -o $(OBJECTS_PATH)/mm.o \
365 $(OBJECTS_MM)
366
367 $(OBJECTS_PATH)/ob.o: $(OBJECTS_OB)
368 $(LD) \
369 -r \
370 -o $(OBJECTS_PATH)/ob.o \
371 $(OBJECTS_OB)
372
373 $(OBJECTS_PATH)/ps.o: $(OBJECTS_PS)
374 $(LD) \
375 -r \
376 -o $(OBJECTS_PATH)/ps.o \
377 $(OBJECTS_PS)
378
379 $(OBJECTS_PATH)/ex.o: $(OBJECTS_EX)
380 $(LD) \
381 -r \
382 -o $(OBJECTS_PATH)/ex.o \
383 $(OBJECTS_EX)
384
385 $(OBJECTS_PATH)/fs.o: $(OBJECTS_FS)
386 $(LD) \
387 -r \
388 -o $(OBJECTS_PATH)/fs.o \
389 $(OBJECTS_FS)
390
391 $(OBJECTS_PATH)/se.o: $(OBJECTS_SE)
392 $(LD) \
393 -r \
394 -o $(OBJECTS_PATH)/se.o \
395 $(OBJECTS_SE)
396
397 $(OBJECTS_PATH)/cm.o: $(OBJECTS_CM)
398 $(LD) \
399 -r \
400 -o $(OBJECTS_PATH)/cm.o \
401 $(OBJECTS_CM)
402
403 $(OBJECTS_PATH)/dbg.o: $(OBJECTS_DBG)
404 $(LD) \
405 -r \
406 -o $(OBJECTS_PATH)/dbg.o \
407 $(OBJECTS_DBG)
408
409 $(OBJECTS_PATH)/ldr.o: $(OBJECTS_LDR)
410 $(LD) \
411 -r \
412 -o $(OBJECTS_PATH)/ldr.o \
413 $(OBJECTS_LDR)
414
415 $(OBJECTS_PATH)/lpc.o: $(OBJECTS_LPC)
416 $(LD) \
417 -r \
418 -o $(OBJECTS_PATH)/lpc.o \
419 $(OBJECTS_LPC)
420
421 $(OBJECTS_PATH)/nls.o: $(OBJECTS_NLS)
422 $(LD) \
423 -r \
424 -o $(OBJECTS_PATH)/nls.o \
425 $(OBJECTS_NLS)
426
427 $(OBJECTS_PATH)/nt.o: $(OBJECTS_NT)
428 $(LD) \
429 -r \
430 -o $(OBJECTS_PATH)/nt.o \
431 $(OBJECTS_NT)
432
433 $(OBJECTS_PATH)/po.o: $(OBJECTS_PO)
434 $(LD) \
435 -r \
436 -o $(OBJECTS_PATH)/po.o \
437 $(OBJECTS_PO)
438
439 $(OBJECTS_PATH)/cc.o: $(OBJECTS_CC)
440 $(LD) \
441 -r \
442 -o $(OBJECTS_PATH)/cc.o \
443 $(OBJECTS_CC)
444
445 $(OBJECTS_PATH)/kd.o: $(OBJECTS_KD)
446 $(LD) \
447 -r \
448 -o $(OBJECTS_PATH)/kd.o \
449 $(OBJECTS_KD)
450
451 $(TARGETNAME).coff: $(TARGETNAME).rc ../include/reactos/resource.h
452
453
454 # Note: ke.o MUST be the first file!!!
455 OBJECTS := \
456 $(OBJECTS_PATH)/arch.o \
457 $(OBJECTS_PATH)/ke.o \
458 $(OBJECTS_PATH)/hal.o \
459 $(OBJECTS_PATH)/cc.o \
460 $(OBJECTS_PATH)/cm.o \
461 $(OBJECTS_PATH)/dbg.o \
462 $(OBJECTS_PATH)/ex.o \
463 $(OBJECTS_PATH)/lpc.o \
464 $(OBJECTS_PATH)/fs.o \
465 $(OBJECTS_PATH)/io.o \
466 $(OBJECTS_PATH)/kd.o \
467 $(OBJECTS_PATH)/ldr.o \
468 $(OBJECTS_PATH)/mm.o \
469 $(OBJECTS_PATH)/nls.o \
470 $(OBJECTS_PATH)/nt.o \
471 $(OBJECTS_PATH)/ob.o \
472 $(OBJECTS_PATH)/po.o \
473 $(OBJECTS_PATH)/ps.o \
474 $(OBJECTS_PATH)/rtl.o \
475 $(OBJECTS_PATH)/se.o \
476 $(OBJECTS_RESOURCE)
477
478
479 ifeq ($(DOSCLI),yes)
480 CLEAN_FILES = $(OBJECTS_PATH)\*.o cc\*.o cm\*.o dbg\*.o ex\*.o hal\x86\*.o io\*.o \
481 ke\*.o ldr\*.o mm\*.o nt\*.o ob\*.o ps\*.o rtl\*.o se\*.o \
482 ke\i386\*.o mm\i386\*.o fs\*.o po\*.o nls\*.o lpc\*.o \
483 kd\*.o $(TARGETNAME).o $(TARGETNAME).a junk.tmp base.tmp temp.exp \
484 $(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym $(TARGETNAME).coff $(D1_FILES)
485 else
486 CLEAN_FILES = $(OBJECTS_PATH)/*.o cc/*.o cm/*.o dbg/*.o ex/*.o hal/x86/*.o io/*.o \
487 ke/*.o ldr/*.o mm/*.o nt/*.o ob/*.o ps/*.o rtl/*.o se/*.o \
488 ke/i386/*.o mm/i386/*.o fs/*.o po/*.o nls/*.o lpc/*.o \
489 kd/*.o $(TARGETNAME).o $(TARGETNAME).a junk.tmp base.tmp temp.exp \
490 $(TARGETNAME).exe $(TARGETNAME).nostrip.exe $(TARGETNAME).sym $(TARGETNAME).coff $(D1_FILES)
491 endif
492
493
494 $(TARGETNAME).nostrip.exe: $(TARGETNAME).o $(TARGETNAME).a $(IE_DATA)
495 $(CC) \
496 -Wl,-T,ntoskrnl.lnk \
497 -nostartfiles -nostdlib \
498 -mdll \
499 -o junk.tmp \
500 -Wl,--subsystem,native \
501 -Wl,--image-base,0xc0000000 \
502 -Wl,--file-alignment,0x1000 \
503 -Wl,--section-alignment,0x1000 \
504 -Wl,--base-file,base.tmp \
505 $(TARGETNAME).o -lgcc
506 - $(RM) junk.tmp
507 $(DLLTOOL) \
508 --dllname $(TARGETNAME).exe \
509 --base-file base.tmp \
510 --output-exp temp.exp \
511 --def $(TARGETNAME).edf \
512 --kill-at
513 - $(RM) base.tmp
514 $(CC) \
515 -nostartfiles -nostdlib \
516 -Wl,-T,ntoskrnl.lnk \
517 -mdll \
518 -o $(TARGETNAME).nostrip.exe \
519 -Wl,--subsystem,native \
520 -Wl,--image-base,0xc0000000 \
521 -Wl,--file-alignment,0x1000 \
522 -Wl,--section-alignment,0x1000 \
523 -Wl,temp.exp \
524 $(TARGETNAME).o -lgcc
525 - $(RM) temp.exp
526
527 $(TARGETNAME).exe: $(TARGETNAME).o $(TARGETNAME).a
528 $(CC) \
529 -Wl,-T,ntoskrnl.lnk \
530 -nostartfiles -nostdlib \
531 -mdll \
532 -o junk.tmp \
533 -Wl,--subsystem,native \
534 -Wl,--image-base,0xc0000000 \
535 -Wl,--file-alignment,0x1000 \
536 -Wl,--section-alignment,0x1000 \
537 -Wl,--base-file,base.tmp \
538 $(TARGETNAME).o -lgcc
539 - $(RM) junk.tmp
540 $(DLLTOOL) \
541 --dllname $(TARGETNAME).exe \
542 --base-file base.tmp \
543 --output-exp temp.exp \
544 --def $(TARGETNAME).edf \
545 --kill-at
546 - $(RM) base.tmp
547 $(CC) \
548 -Wl,-T,ntoskrnl.lnk -Wl,-s\
549 -nostartfiles -nostdlib \
550 -mdll \
551 -o $(TARGETNAME).exe \
552 -Wl,--subsystem,native \
553 -Wl,--image-base,0xc0000000 \
554 -Wl,--file-alignment,0x1000 \
555 -Wl,--section-alignment,0x1000 \
556 -Wl,temp.exp \
557 $(TARGETNAME).o -lgcc
558 - $(RM) temp.exp
559
560 $(TARGETNAME).sym: $(TARGETNAME).nostrip.exe
561 $(NM) --numeric-sort $(TARGETNAME).nostrip.exe > $(TARGETNAME).sym
562
563 $(TARGETNAME).o: $(OBJECTS)
564 $(LD) \
565 -r \
566 -o $(TARGETNAME).o \
567 $(OBJECTS)
568
569 $(TARGETNAME).a: $(TARGETNAME).def
570 $(DLLTOOL) \
571 --dllname $(TARGETNAME).exe \
572 --def $(TARGETNAME).def \
573 --output-lib $(TARGETNAME).a \
574 --kill-at
575
576 clean: $(CLEAN_FILES:%=%_clean)
577
578 $(CLEAN_FILES:%=%_clean): %_clean:
579 - $(RM) $*
580
581 .PHONY: clean $(CLEAN_FILES:%=%_clean)
582
583 install: $(FLOPPY_DIR)/$(TARGETNAME).exe
584
585 $(FLOPPY_DIR)/$(TARGETNAME).exe: $(TARGETNAME).exe
586 $(CP) $(TARGETNAME).exe $(FLOPPY_DIR)/$(TARGETNAME).exe
587
588 .PHONY: install
589
590 dist: ../$(DIST_DIR)/$(TARGETNAME).exe
591
592 ../$(DIST_DIR)/$(TARGETNAME).exe: $(TARGETNAME).exe
593 $(CP) $(TARGETNAME).exe ../$(DIST_DIR)/$(TARGETNAME).exe
594
595 .PHONY: dist
596
597 ex/napi.o: ex/napi.c ../include/ntdll/napi.h
598
599 ke/main.o: ke/main.c ../include/reactos/buildno.h
600
601 mkconfig$(EXE_SUFFIX): mkconfig.c
602 $(HOST_CC) -g -o mkconfig$(EXE_SUFFIX) mkconfig.c
603
604 include/internal/config.h: config mkconfig$(EXE_SUFFIX)
605 $(EXE_PREFIX)mkconfig$(EXE_SUFFIX) include/internal/config.h$(CONFIG)
606
607 ifneq ($(MAKECMDGOALS),clean)
608 include $(D1_FILES)
609 endif
610
611 .%.d: %.c $(EXE_PREFIX)depends$(EXE_POSTFIX)
612 $(CC) $(CFLAGS) -M $< | $(EXE_PREFIX)depends$(EXE_POSTFIX) $(@D) $@
613
614 .%.d: %.s
615 $(CC) $(CFLAGS) -M $< | $(EXE_PREFIX)depends$(EXE_POSTFIX) $(@D) $@
616
617 .%.d: %.S
618 $(CC) $(CFLAGS) -M $< | $(EXE_PREFIX)depends$(EXE_POSTFIX) $(@D) $@
619
620
621
622 # EOF