3 # Helper makefile for ReactOS modules
4 # Variables this makefile accepts:
5 # $TARGET_TYPE = Type of target:
6 # program = User mode program
7 # proglib = Executable program that have exported functions
8 # dynlink = Dynamic Link Library (DLL)
9 # library = Library that will be linked with other code
10 # driver = Kernel mode driver
11 # export_driver = Kernel mode driver that have exported functions
12 # driver_library = Import library for a driver
13 # kmlibrary = Static kernel-mode library
14 # host_library = Static library for use in the build env
15 # hal = Hardware Abstraction Layer
16 # bootpgm = Boot program
17 # miniport = Kernel mode driver that does not link with ntoskrnl.exe or hal.dll
18 # gdi_driver = Kernel mode graphics driver that link with win32k.sys
19 # subsystem = Kernel subsystem
20 # kmdll = Kernel mode DLL
21 # winedll = DLL imported from wine
22 # kernel = ReactOS kernel
24 # $TARGET_APPTYPE = Application type (windows,native,console).
25 # Required only for TARGET_TYPEs program and proglib
26 # $TARGET_NAME = Base name of output file and .rc, .def, and .edf files
27 # $TARGET_OBJECTS = Object files that compose the module
28 # $TARGET_CPPAPP = C++ application (no,yes) (optional)
29 # $TARGET_HEADERS = Header files that the object files depend on (optional)
30 # $TARGET_DEFNAME = Base name of .def and .edf files (optional)
31 # $TARGET_BASENAME = Base name of output file (overrides $TARGET_NAME if it exists) (optional)
32 # $TARGET_EXTENSION = Extension of the output file (optional)
33 # $TARGET_DDKLIBS = DDK libraries that are to be imported by the module (optional)
34 # $TARGET_SDKLIBS = SDK libraries that are to be imported by the module (optional)
35 # $TARGET_LIBS = Other libraries that are to be imported by the module (optional)
36 # $TARGET_GCCLIBS = GCC libraries imported with -l (optional)
37 # $TARGET_LFLAGS = GCC flags when linking (optional)
38 # $TARGET_CFLAGS = GCC flags (optional)
39 # $TARGET_CPPFLAGS = G++ flags (optional)
40 # $TARGET_ASFLAGS = GCC assembler flags (optional)
41 # $TARGET_NFLAGS = NASM flags (optional)
42 # $TARGET_RCFLAGS = Windres flags (optional)
43 # $TARGET_CLEAN = Files that are part of the clean rule (optional)
44 # $TARGET_PATH = Relative path for *.def, *.edf, and *.rc (optional)
45 # $TARGET_BASE = Default base address (optional)
46 # $TARGET_ENTRY = Entry point (optional)
47 # $TARGET_NORC = Do not include standard resource file (no,yes) (optional)
48 # $TARGET_LIBPATH = Destination path for static libraries (optional)
49 # $TARGET_IMPLIBPATH = Destination path for import libraries (optional)
50 # $TARGET_INSTALLDIR = Destination path when installed (optional)
51 # $TARGET_PCH = Filename of header to use to generate a PCH if supported by the compiler (optional)
52 # $TARGET_BOOTSTRAP = Whether this file is needed to bootstrap the installation (no,yes) (optional)
53 # $TARGET_BOOTSTRAP_NAME = Name on the installation medium (optional)
54 # $TARGET_REGTESTS = This module has regression tests (no,yes) (optional)
55 # $TARGET_WINETESTS = This module Wine regression tests (no,yes) (optional)
56 # $TARGET_INSTALL = Install the file (no,yes) (optional)
57 # $SUBDIRS = Subdirs in which to run make (optional)
59 include $(PATH_TO_TOP
)/config
60 include $(PATH_TO_TOP
)/baseaddress.cfg
62 ifeq ($(TARGET_PATH
),)
71 MK_ARCH_ID
:= _M_ALPHA
78 ifeq ($(ARCH
),powerpc
)
82 # unknown architecture
84 MK_ARCH_ID
:= _M_UNKNOWN
88 # VARIABLES IN USE BY VARIOUS TARGETS
90 # MK_BOOTCDDIR = Directory on the ReactOS ISO CD in which to place the file (subdir of reactos/)
91 # MK_CFLAGS = C compiler command-line flags for this target
92 # MK_CPPFLAGS = C++ compiler command-line flags for this target
93 # MK_DDKLIBS = Import libraries from the ReactOS DDK to link with
94 # MK_DEFENTRY = Module entry point:
95 # _WinMain@16 for windows EXE files that are export libraries
96 # _DriverEntry@8 for .SYS files
97 # _DllMain@12 for .DLL files
98 # _DrvEnableDriver@12 for GDI drivers
99 # _WinMainCRTStartup for Win32 EXE files
100 # _NtProcessStartup@4 for Native EXE files
101 # _mainCRTStartup for Console EXE files
102 # MK_DEFEXT = Extension to give compiled modules (.EXE, .DLL, .SYS, .a)
103 # MK_DISTDIR = (unused?)
104 # MK_EXETYPE = Compiler option packages based on type of PE file (exe, dll)
105 # MK_IMPLIB = Whether or not to generate a DLL import stub library (yes, no)
106 # MK_IMPLIB_EXT = Extension to give import libraries (.a always)
107 # MK_IMPLIBDEFPATH = Default place to put the import stub library when built
108 # MK_IMPLIBONLY = Whether the target is only an import library (yes, no; used only by generic hal)
109 # MK_INSTALLDIR = Where "make install" should put the target, relative to reactos/
110 # MK_MODE = Mode the target's code is intended to run in
111 # user - User-mode compiler settings
112 # kernel - Kernel-mode compiler settings
113 # static - Static library compiler settings
114 # MK_RCFLAGS = Flags to add to resource compiler command line
115 # MK_RES_BASE = Base name of resource files
116 # MK_SDKLIBS = Default SDK libriaries to link with
119 ifeq ($(TARGET_TYPE
),program
)
123 MK_DEFENTRY
:= _DEFINE_TARGET_APPTYPE
133 MK_BOOTCDDIR
:= system32
135 MK_RES_BASE
:= $(TARGET_NAME
)
138 ifeq ($(TARGET_TYPE
),proglib
)
142 MK_DEFENTRY
:= _WinMain@
16
149 MK_IMPLIBDEFPATH
:= $(SDK_PATH_LIB
)
152 MK_BOOTCDDIR
:= system32
154 MK_RES_BASE
:= $(TARGET_NAME
)
157 ifeq ($(TARGET_TYPE
),dynlink
)
161 MK_DEFENTRY
:= _DllMain@
12
168 MK_IMPLIBDEFPATH
:= $(SDK_PATH_LIB
)
170 MK_INSTALLDIR
:= system32
171 MK_BOOTCDDIR
:= system32
173 MK_RES_BASE
:= $(TARGET_NAME
)
176 ifeq ($(TARGET_TYPE
),library
)
190 MK_INSTALLDIR
:= # none
191 MK_BOOTCDDIR
:= system32
196 ifeq ($(TARGET_TYPE
),kmlibrary
)
204 MK_IMPLIBDEFPATH
:= $(DDK_PATH_LIB
)
208 ifeq ($(TARGET_TYPE
),driver_library
)
219 MK_IMPLIBDEFPATH
:= $(DDK_PATH_LIB
)
221 MK_INSTALLDIR
:= $(DDK_PATH_INC
)
223 MK_DISTDIR
:= # FIXME
227 ifeq ($(TARGET_TYPE
),host_library
)
241 ifeq ($(TARGET_TYPE
),driver
)
245 MK_DEFENTRY
:= _DriverEntry@
8
246 MK_DDKLIBS
:= ntoskrnl.a hal.a
248 MK_CFLAGS
:= -D__NTDRIVER__
-I.
249 MK_CPPFLAGS
:= -D__NTDRIVER__
-I.
254 MK_INSTALLDIR
:= system32
/drivers
256 MK_DISTDIR
:= drivers
257 MK_RES_BASE
:= $(TARGET_NAME
)
260 ifeq ($(TARGET_TYPE
),export_driver
)
264 MK_DEFENTRY
:= _DriverEntry@
8
265 MK_DDKLIBS
:= ntoskrnl.a hal.a
267 MK_CFLAGS
:= -D__NTDRIVER__
-I.
268 MK_CPPFLAGS
:= -D__NTDRIVER__
-I.
271 MK_IMPLIBDEFPATH
:= $(DDK_PATH_LIB
)
273 MK_INSTALLDIR
:= system32
/drivers
275 MK_DISTDIR
:= drivers
276 MK_RES_BASE
:= $(TARGET_NAME
)
279 ifeq ($(TARGET_TYPE
),hal
)
283 MK_DEFENTRY
:= _DriverEntry@
8
284 MK_DDKLIBS
:= ntoskrnl.a
286 MK_CFLAGS
:= -D__NTHAL__
-I.
287 MK_CPPFLAGS
:= -D__NTHAL__
-I.
290 MK_IMPLIBDEFPATH
:= $(DDK_PATH_LIB
)
292 MK_INSTALLDIR
:= system32
295 MK_RES_BASE
:= $(TARGET_NAME
)
296 MK_INSTALL_BASENAME
:= hal
297 MK_INSTALL_FULLNAME
:= hal.dll
298 ifeq ($(TARGET_BOOTSTRAP
),yes
)
299 TARGET_BOOTSTRAP_NAME
:= hal.dll
301 TARGET_BOOTSTRAP_NAME
:= $(TARGET_NAME
)$(MK_DEFEXT
)
303 TARGET_BOOTSTRAP
:= yes
306 ifeq ($(TARGET_TYPE
),bootpgm
)
310 MK_DEFENTRY
:= _DriverEntry@
8
313 MK_CFLAGS
:= -D__NTDRIVER__
-I.
314 MK_CPPFLAGS
:= -D__NTDRIVER__
-I.
319 MK_INSTALLDIR
:= system32
320 MK_BOOTCDDIR
:= system32
321 MK_DISTDIR
:= # FIXME
322 MK_RES_BASE
:= $(TARGET_NAME
)
325 ifeq ($(TARGET_TYPE
),miniport
)
329 MK_DEFENTRY
:= _DriverEntry@
8
332 MK_CFLAGS
:= -D__NTDRIVER__
-I.
333 MK_CPPFLAGS
:= -D__NTDRIVER__
-I.
338 MK_INSTALLDIR
:= system32
/drivers
340 MK_DISTDIR
:= drivers
341 MK_RES_BASE
:= $(TARGET_NAME
)
344 ifeq ($(TARGET_TYPE
),gdi_driver
)
348 MK_DEFENTRY
:= _DrvEnableDriver@
12
349 MK_DDKLIBS
:= ntoskrnl.a hal.a win32k.a
351 MK_CFLAGS
:= -D__NTDRIVER__
-I.
352 MK_CPPFLAGS
:= -D__NTDRIVER__
-I.
355 MK_IMPLIBDEFPATH
:= $(DDK_PATH_LIB
)
357 MK_INSTALLDIR
:= system32
360 MK_RES_BASE
:= $(TARGET_NAME
)
363 ifeq ($(TARGET_TYPE
),kernel
)
367 MK_DEFENTRY
:= _NtProcessStartup
370 MK_CFLAGS
:= -D__NTOSKRNL__
-I.
371 MK_CPPFLAGS
:= -D__NTOSKRNL__
-I.
374 MK_IMPLIBDEFPATH
:= $(DDK_PATH_LIB
)
376 MK_INSTALLDIR
:= system32
378 MK_RES_BASE
:= $(TARGET_NAME
)
381 ifeq ($(TARGET_TYPE
),test)
395 MK_INSTALLDIR
:= # none
396 MK_BOOTCDDIR
:= system32
399 TARGET_OBJECTS
:= _rtstub.o _regtests.o
$(TARGET_OBJECTS
)
410 # can be overidden with $(CXX) for linkage of c++ executables
413 ifeq ($(RM_AT_FROM_SYMBOLS
),no
)
416 MK_KILLAT
:= --kill-at
419 ifeq ($(TARGET_TYPE
),program
)
420 ifeq ($(TARGET_APPTYPE
),windows
)
421 MK_DEFENTRY
:= _WinMainCRTStartup
422 MK_SDKLIBS
:= ntdll.a kernel32.a gdi32.a user32.a
423 TARGET_LFLAGS
+= -Wl
,--subsystem
,windows
426 ifeq ($(TARGET_APPTYPE
),native
)
427 MK_DEFENTRY
:= _NtProcessStartup@
4
428 MK_SDKLIBS
:= ntdll.a
429 TARGET_LFLAGS
+= -Wl
,--subsystem
,native
-nostartfiles
432 ifeq ($(TARGET_APPTYPE
),console
)
433 MK_DEFENTRY
:= _mainCRTStartup
435 TARGET_LFLAGS
+= -Wl
,--subsystem
,console
439 ifeq ($(TARGET_TYPE
),proglib
)
440 ifeq ($(TARGET_APPTYPE
),windows
)
441 MK_DEFENTRY
:= _WinMainCRTStartup
442 MK_SDKLIBS
:= ntdll.a kernel32.a gdi32.a user32.a
443 TARGET_LFLAGS
+= -Wl
,--subsystem
,windows
446 ifeq ($(TARGET_APPTYPE
),native
)
447 MK_DEFENTRY
:= _NtProcessStartup@
4
448 MK_SDKLIBS
:= ntdll.a
449 TARGET_LFLAGS
+= -Wl
,--subsystem
,native
-nostartfiles
452 ifeq ($(TARGET_APPTYPE
),console
)
453 MK_DEFENTRY
:= _mainCRTStartup
455 TARGET_LFLAGS
+= -Wl
,--subsystem
,console
459 ifeq ($(TARGET_TYPE
),subsystem
)
463 MK_DEFENTRY
:= _DriverEntry@
8
464 MK_DDKLIBS
:= ntoskrnl.a hal.a
466 MK_CFLAGS
:= -D__NTDRIVER__
-I.
467 MK_CPPFLAGS
:= -D__NTDRIVER__
-I.
470 MK_IMPLIBDEFPATH
:= $(DDK_PATH_LIB
)
472 MK_INSTALLDIR
:= system32
473 MK_DISTDIR
:= drivers
474 MK_RES_BASE
:= $(TARGET_NAME
)
477 ifeq ($(TARGET_TYPE
),kmdll
)
482 MK_DDKLIBS
:= ntoskrnl.a hal.a
484 MK_CFLAGS
:= -D__NTDRIVER__
-I.
485 MK_CPPFLAGS
:= -D__NTDRIVER__
-I.
488 MK_IMPLIBDEFPATH
:= $(DDK_PATH_LIB
)
490 MK_INSTALLDIR
:= system32
491 MK_DISTDIR
:= drivers
492 MK_RES_BASE
:= $(TARGET_NAME
)
495 ifeq ($(TARGET_TYPE
),winedll
)
496 -include Makefile.ros
497 MK_GENERATED_MAKEFILE
= Makefile.ros
501 MK_DEFENTRY
:= _DllMain@
12
504 MK_CFLAGS
:= -D__USE_W32API
-D_WIN32_IE
=0x600 -D_WIN32_WINNT
=0x501 -DWINVER
=0x501 -D_STDDEF_H
-I
$(PATH_TO_TOP
)/include/wine
505 MK_CPPFLAGS
:= -D__USE_W32API
-D_WIN32_IE
=0x600 -D_WIN32_WINNT
=0x501 -DWINVER
=0x501 -D__need_offsetof
-I
$(PATH_TO_TOP
)/include -I
$(PATH_TO_TOP
)/include/wine
506 MK_PREPROC_FOR_RC_FLAGS
:= -xc
-E
-DRC_INVOKED
-D__USE_W32API
-I
$(PATH_TO_TOP
)/include/wine
-I
$(PATH_TO_TOP
)/include -I
$(PATH_TO_TOP
)/w32api
/include
509 MK_IMPLIBDEFPATH
:= $(SDK_PATH_LIB
)
511 MK_INSTALLDIR
:= system32
512 MK_BOOTCDDIR
:= system32
514 MK_RES_BASE
:= $(TARGET_NAME
)
515 ifeq ($(TARGET_DEFNAME
),)
516 MK_DEFBASENAME
:= $(TARGET_NAME
).spec
517 MK_SPECDEF
:= $(MK_DEFBASENAME
).def
519 MK_DEFBASENAME
:= $(TARGET_DEFNAME
)
521 ifneq ($(TARGET_STUBS
),no
)
522 MK_STUBS_SRC
:= $(TARGET_NAME
).stubs.c
523 MK_STUBS_OBJ
:= $(TARGET_NAME
).stubs.o
525 MK_RC_BINARIES
= $(TARGET_RC_BINARIES
)
528 ifeq ($(TARGET_TYPE
),winedrv
)
529 -include Makefile.ros
530 MK_GENERATED_MAKEFILE
= Makefile.ros
534 # does this need changing?:
535 MK_DEFENTRY
:= _DllMain@
12
538 MK_CFLAGS
:= -D__USE_W32API
-D_WIN32_IE
=0x600 -D_WIN32_WINNT
=0x501 -DWINVER
=0x501 -D__need_offsetof
-I
$(PATH_TO_TOP
)/include/wine
539 MK_CPPFLAGS
:= -D__USE_W32API
-D_WIN32_IE
=0x600 -D_WIN32_WINNT
=0x501 -DWINVER
=0x501 -D__need_offsetof
-I
$(PATH_TO_TOP
)/include -I
$(PATH_TO_TOP
)/include/wine
540 MK_RCFLAGS
:= --define __USE_W32API
--include-dir
$(PATH_TO_TOP
)/include/wine
543 MK_IMPLIBDEFPATH
:= $(SDK_PATH_LIB
)
545 MK_INSTALLDIR
:= system32
546 MK_BOOTCDDIR
:= system32
548 MK_RES_BASE
:= $(TARGET_NAME
)
549 ifeq ($(TARGET_DEFNAME
),)
550 MK_DEFBASENAME
:= $(TARGET_NAME
).spec
551 MK_SPECDEF
:= $(MK_DEFBASENAME
).def
553 MK_DEFBASENAME
:= $(TARGET_DEFNAME
)
555 MK_RC_BINARIES
= $(TARGET_RC_BINARIES
)
558 ifeq ($(TARGET_RC_SRCS
),)
559 MK_RES_SRC
:= $(TARGET_PATH
)/$(MK_RES_BASE
).rc
560 MK_RESOURCE
:= $(TARGET_PATH
)/$(MK_RES_BASE
).coff
562 MK_RES_SRC
:= $(TARGET_RC_SRCS
)
563 MK_RESOURCE
:= $(TARGET_RC_SRCS
:.rc
=.coff
)
566 ifneq ($(TARGET_INSTALLDIR
),)
567 MK_INSTALLDIR
:= $(TARGET_INSTALLDIR
)
571 ifneq ($(BOOTCD_INSTALL
),)
576 ifeq ($(TARGET_LIBPATH
),)
577 ifeq ($(MK_LIBPATH
),)
578 MK_LIBPATH
:= $(SDK_PATH_LIB
)
581 MK_LIBPATH
:= $(TARGET_LIBPATH
)
584 ifeq ($(TARGET_IMPLIBPATH
),)
585 MK_IMPLIBPATH
:= $(MK_IMPLIBDEFPATH
)
587 MK_IMPLIBPATH
:= $(TARGET_IMPLIBPATH
)
591 ifeq ($(TARGET_BASENAME
),)
592 MK_BASENAME
:= $(TARGET_NAME
)
594 MK_BASENAME
:= $(TARGET_BASENAME
)
598 ifeq ($(TARGET_EXTENSION
),)
599 MK_EXT
:= $(MK_DEFEXT
)
601 MK_EXT
:= $(TARGET_EXTENSION
)
605 ifeq ($(TARGET_NORC
),yes
)
608 MK_FULLRES
:= $(MK_RESOURCE
)
611 ifneq ($(TARGET_TYPE
),winedll
)
612 ifeq ($(TARGET_DEFNAME
),)
613 MK_DEFBASENAME
:= $(TARGET_NAME
)
615 MK_DEFBASENAME
:= $(TARGET_DEFNAME
)
619 MK_DEFNAME
:= $(TARGET_PATH
)/$(MK_DEFBASENAME
).def
621 ifeq ($(MK_MODE
),user
)
622 ifeq ($(MK_EXETYPE
),dll
)
623 MK_DEFBASE
:= 0x10000000
625 MK_DEFBASE
:= 0x400000
627 ifneq ($(TARGET_SDKLIBS
),)
628 MK_LIBS
:= $(addprefix $(SDK_PATH_LIB
)/lib
, $(TARGET_SDKLIBS
))
630 MK_LIBS
:= $(addprefix $(SDK_PATH_LIB
)/lib
, $(MK_SDKLIBS
))
635 ifeq ($(MK_MODE
),kernel
)
636 MK_DEFBASE
:= 0x10000
637 MK_LIBS
:= $(addprefix $(DDK_PATH_LIB
)/lib
, $(TARGET_DDKLIBS
) $(MK_DDKLIBS
))
638 MK_CFLAGS
+= -D_SEH_NO_NATIVE_NLG
639 MK_CPPFLAGS
+= -D_SEH_NO_NATIVE_NLG
640 MK_LFLAGS
+= -nostartfiles
641 ifneq ($(TARGET_TYPE
),kernel
)
642 MK_LFLAGS
+= -nostdlib
647 # Enable Tree-Wide Optimization.
648 # Protect uncompatible files here with an ifneq
649 # if needed, until their problems can be found
652 MK_CFLAGS
+= -O2
-Wno-strict-aliasing
653 MK_CPPFLAGS
+= -O2
-Wno-strict-aliasing
656 ifneq ($(TARGET_LIBS
),)
657 MK_LIBS
:= $(TARGET_LIBS
) $(MK_LIBS
)
661 ifeq ($(TARGET_BASE
),)
662 TARGET_BASE
:= $(MK_DEFBASE
)
666 ifeq ($(TARGET_ENTRY
),)
667 TARGET_ENTRY
:= $(MK_DEFENTRY
)
671 # Include details of the OS configuration
673 include $(PATH_TO_TOP
)/config
676 TARGET_CFLAGS
+= $(MK_CFLAGS
) $(STD_CFLAGS
) -g
678 TARGET_CPPFLAGS
+= $(MK_CPPFLAGS
) $(STD_CPPFLAGS
) -g
680 TARGET_RCFLAGS
+= $(MK_RCFLAGS
) $(STD_RCFLAGS
)
682 TARGET_ASFLAGS
+= $(MK_ASFLAGS
) $(STD_ASFLAGS
) -g
684 TARGET_NFLAGS
+= $(MK_NFLAGS
) $(STD_NFLAGS
)
686 TARGET_LFLAGS
+= $(MK_LFLAGS
) $(STD_LFLAGS
) -g
689 MK_GCCLIBS
:= $(addprefix -l
, $(TARGET_GCCLIBS
))
691 ifeq ($(MK_MODE
),static
)
692 MK_FULLNAME
:= $(MK_LIBPATH
)/lib
$(MK_BASENAME
)$(MK_EXT
)
694 MK_FULLNAME
:= $(MK_BASENAME
)$(MK_EXT
)
697 ifeq ($(TARGET_TYPE
), kmlibrary
)
698 MK_FULLNAME
:= $(DDK_PATH_LIB
)/lib
$(MK_BASENAME
)$(MK_EXT
)
701 MK_IMPLIB_FULLNAME
:= lib
$(MK_BASENAME
)$(MK_IMPLIB_EXT
)
703 MK_NOSTRIPNAME
:= $(MK_BASENAME
).nostrip
$(MK_EXT
)
704 MK_DEBUGNAME
:= $(MK_BASENAME
).dbg
706 MK_EXTRADEP
:= $(filter %.h
,$(TARGET_OBJECTS
))
708 ifeq ($(TARGET_TYPE
),test)
709 MK_EXTRADEP
+= _stubs.o _hooks.o
712 # We don't want to link header files
713 MK_OBJECTS
:= $(filter-out %.h
,$(TARGET_OBJECTS
)) $(MK_STUBS_OBJ
)
715 # There is problems with C++ applications and ld -r. Ld can cause errors like:
716 # reloc refers to symbol `.text$_ZN9CCABCodecC2Ev' which is not being output
717 ifeq ($(TARGET_CPPAPP
),yes
)
718 MK_STRIPPED_OBJECT
:= $(MK_OBJECTS
)
720 MK_STRIPPED_OBJECT
:= $(MK_BASENAME
).stripped.o
723 ifeq ($(TARGET_REGTESTS
),yes
)
724 REGTEST_TARGETS
:= tests
/_hooks.c tests
/_regtests.c tests
/_stubs.S tests
/Makefile.tests tests
/_rtstub.c
725 MK_REGTESTS_CLEAN
:= clean_regtests
731 ifeq ($(TARGET_WINETESTS
),yes
)
733 - $(MAKE
) -C winetests
734 MK_REGTESTS_CLEAN
:= clean_winetests
737 ifeq ($(TARGET_INSTALL
),)
740 MK_INSTALL
:= $(TARGET_INSTALL
)
743 ifeq ($(MK_INSTALL_BASENAME
),)
744 MK_INSTALL_BASENAME
:= $(MK_BASENAME
)
746 ifeq ($(MK_INSTALL_FULLNAME
),)
747 MK_INSTALL_FULLNAME
:= $(MK_FULLNAME
)
750 ifeq ($(MK_IMPLIBONLY
),yes
)
752 TARGET_CLEAN
+= $(MK_IMPLIBPATH
)/$(MK_IMPLIB_FULLNAME
)
754 all: $(WINETEST_TARGETS
) $(REGTEST_TARGETS
) $(MK_IMPLIBPATH
)/$(MK_IMPLIB_FULLNAME
)
756 $(MK_IMPLIBPATH
)/$(MK_IMPLIB_FULLNAME
): $(MK_OBJECTS
) $(MK_DEFNAME
)
757 $(HALFVERBOSEECHO
) [DLLTOOL
] $(MK_IMPLIB_FULLNAME
)
759 --dllname
$(MK_FULLNAME
) \
760 --def
$(MK_DEFNAME
) \
761 --output-lib
$(MK_IMPLIBPATH
)/$(MK_IMPLIB_FULLNAME
) \
766 all: $(REGTEST_TARGETS
) $(MK_FULLNAME
) $(MK_NOSTRIPNAME
) $(SUBDIRS
:%=%_all
)
769 ifeq ($(MK_IMPLIB
),yes
)
770 MK_EXTRACMD
:= --def
$(MK_DEFNAME
)
777 ifeq ($(MK_MODE
),user
)
779 ifeq ($(MK_EXETYPE
),dll
)
780 TARGET_LFLAGS
+= -mdll
-Wl
,--image-base
,$(TARGET_BASE
)
781 MK_EXTRADEP
+= $(MK_DEFNAME
)
782 MK_EXTRACMD2
:= -Wl
,temp.exp
787 $(MK_BASENAME
).a
: $(MK_OBJECTS
)
788 $(HALFVERBOSEECHO
) [AR
] $(MK_BASENAME
).a
789 $(MK_AR
) -rc
$(MK_BASENAME
).a
$(MK_OBJECTS
)
791 $(MK_NOSTRIPNAME
): $(MK_EXTRADEP
) $(MK_FULLRES
) $(MK_BASENAME
).a
$(MK_LIBS
) $(MK_STUBS_SRC
) $(MK_STUBS_OBJ
)
792 $(HALFVERBOSEECHO
) [LD
] $(MK_NOSTRIPNAME
)
793 ifeq ($(MK_EXETYPE
),dll
)
794 $(LD_CC
) -Wl
,--base-file
,base.tmp \
795 -Wl
,--entry
,$(TARGET_ENTRY
) \
798 $(MK_FULLRES
) $(MK_OBJECTS
) $(MK_LIBS
) $(MK_GCCLIBS
)
800 $(DLLTOOL
) --dllname
$(MK_FULLNAME
) \
801 --base-file base.tmp \
802 --output-exp temp.exp
$(MK_EXTRACMD
)
804 $(LD_CC
) -Wl
,--base-file
,base.tmp \
805 -Wl
,--entry
,$(TARGET_ENTRY
) \
809 $(MK_FULLRES
) $(MK_OBJECTS
) $(MK_LIBS
) $(MK_GCCLIBS
)
811 $(DLLTOOL
) --dllname
$(MK_FULLNAME
) \
812 --base-file base.tmp \
813 --output-exp temp.exp
$(MK_KILLAT
) $(MK_EXTRACMD
)
816 $(LD_CC
) $(TARGET_LFLAGS
) \
817 -Wl
,--entry
,$(TARGET_ENTRY
) $(MK_EXTRACMD2
) \
818 -o
$(MK_NOSTRIPNAME
) \
819 $(MK_FULLRES
) $(MK_OBJECTS
) $(MK_LIBS
) $(MK_GCCLIBS
)
821 ifeq ($(BUILD_MAP
),full
)
822 $(HALFVERBOSEECHO
) [OBJDUMP
] $(MK_BASENAME
).map
823 $(OBJDUMP
) -d
-S
$(MK_NOSTRIPNAME
) > $(MK_BASENAME
).map
825 ifeq ($(BUILD_MAP
),yes
)
826 $(HALFVERBOSEECHO
) [NM
] $(MK_BASENAME
).map
827 $(NM
) --numeric-sort
$(MK_NOSTRIPNAME
) > $(MK_BASENAME
).map
831 $(MK_FULLNAME
): $(MK_NOSTRIPNAME
) $(MK_EXTRADEP
)
832 $(HALFVERBOSEECHO
) [RSYM
] $(MK_FULLNAME
)
833 $(RSYM
) $(MK_NOSTRIPNAME
) $(MK_FULLNAME
)
837 # Kernel mode targets
838 ifeq ($(MK_MODE
),kernel
)
840 ifeq ($(MK_IMPLIB
),yes
)
841 MK_EXTRACMD
:= --def
$(MK_DEFNAME
)
846 $(MK_BASENAME
).a
: $(MK_OBJECTS
)
847 $(HALFVERBOSEECHO
) [AR
] $(MK_BASENAME
).a
848 $(MK_AR
) -rc
$(MK_BASENAME
).a
$(MK_OBJECTS
)
850 $(MK_NOSTRIPNAME
): $(MK_EXTRADEP
) $(MK_FULLRES
) $(MK_BASENAME
).a
$(MK_LIBS
)
851 $(HALFVERBOSEECHO
) [LD
] $(MK_NOSTRIPNAME
)
852 $(LD_CC
) -Wl
,--base-file
,base.tmp \
853 -Wl
,--entry
,$(TARGET_ENTRY
) \
856 $(MK_FULLRES
) $(MK_OBJECTS
) $(MK_LIBS
) $(MK_GCCLIBS
)
858 $(DLLTOOL
) --dllname
$(MK_FULLNAME
) \
859 --base-file base.tmp \
860 --output-exp temp.exp
$(MK_EXTRACMD
) $(MK_KILLAT
)
862 $(LD_CC
) $(TARGET_LFLAGS
) \
863 -Wl
,--subsystem
,native \
864 -Wl
,--image-base
,$(TARGET_BASE
) \
865 -Wl
,--file-alignment
,0x1000 \
866 -Wl
,--section-alignment
,0x1000 \
867 -Wl
,--entry
,$(TARGET_ENTRY
) \
869 -o
$(MK_NOSTRIPNAME
) \
870 $(MK_FULLRES
) $(MK_OBJECTS
) $(MK_LIBS
) $(MK_GCCLIBS
)
872 ifeq ($(BUILD_MAP
),full
)
873 $(HALFVERBOSEECHO
) [OBJDUMP
] $(MK_BASENAME
).map
874 $(OBJDUMP
) -d
-S
$(MK_NOSTRIPNAME
) > $(MK_BASENAME
).map
876 ifeq ($(BUILD_MAP
),yes
)
877 $(HALFVERBOSEECHO
) [NM
] $(MK_BASENAME
).map
878 $(NM
) --numeric-sort
$(MK_NOSTRIPNAME
) > $(MK_BASENAME
).map
882 $(MK_FULLNAME
): $(MK_NOSTRIPNAME
)
883 $(HALFVERBOSEECHO
) [RSYM
] $(MK_FULLNAME
)
884 $(RSYM
) $(MK_NOSTRIPNAME
) $(MK_FULLNAME
)
888 # Static library target
889 ifeq ($(MK_MODE
),static
)
891 $(MK_FULLNAME
): $(MK_EXTRADEP
) $(MK_OBJECTS
)
892 $(HALFVERBOSEECHO
) [AR
] $(MK_FULLNAME
)
893 $(MK_AR
) -rc
$(MK_FULLNAME
) $(MK_OBJECTS
)
895 # Static libraries dont have a nostrip version
899 .PHONY
: $(MK_NOSTRIPNAME
)
903 endif # MK_IMPLIBONLY
906 $(MK_FULLRES
): $(PATH_TO_TOP
)/include/reactos
/buildno.h
$(MK_RES_SRC
)
908 ifeq ($(MK_DEPENDS
),yes
)
914 ifeq ($(MK_IMPLIB
),yes
)
915 $(MK_IMPLIBPATH
)/$(MK_IMPLIB_FULLNAME
): $(MK_DEFNAME
)
916 $(HALFVERBOSEECHO
) [DLLTOOL
] $(MK_IMPLIB_FULLNAME
)
917 $(DLLTOOL
) --dllname
$(MK_FULLNAME
) \
918 --def
$(MK_DEFNAME
) \
919 --output-lib
$(MK_IMPLIBPATH
)/$(MK_IMPLIB_FULLNAME
) \
922 implib
: $(MK_IMPLIBPATH
)/$(MK_IMPLIB_FULLNAME
)
924 implib
: $(SUBDIRS
:%=%_implib
)
927 # Precompiled header support
928 # When using PCHs, use dependency tracking to keep the .gch files up-to-date.
929 # When TARGET_PCH is defined, we always want to clean the .gch file, even if
930 # ROS_USE_PCH is not active. This prevents problems when switching between
931 # PCH and non-PCH builds.
933 ifneq ($(TARGET_PCH
),)
934 MK_PCHCLEAN
= $(TARGET_PCH
).gch
935 ifeq ($(ROS_USE_PCH
),yes
)
936 MK_PCHNAME
= $(TARGET_PCH
).gch
937 ifeq ($(TARGET_CPPAPP
),yes
)
941 endif # TARGET_CPPAPP
950 # Be carefull not to clean non-object files
951 MK_CLEANFILES
:= $(filter %.o
,$(MK_OBJECTS
))
952 MK_CLEANFILTERED
:= $(MK_OBJECTS
:.o
=.d
) $(TARGET_PCH
:.h
=.d
)
953 MK_CLEANDEPS
:= $(join $(dir $(MK_CLEANFILTERED
)), $(addprefix .
, $(notdir $(MK_CLEANFILTERED
))))
955 clean: $(MK_REGTESTS_CLEAN
) $(SUBDIRS
:%=%_clean
)
956 $(HALFVERBOSEECHO
) [CLEAN
]
957 - $(RM
) *.o
$(MK_PCHCLEAN
) $(MK_BASENAME
).a
$(MK_RESOURCE
) \
958 $(MK_FULLNAME
) $(MK_NOSTRIPNAME
) $(MK_CLEANFILES
) $(MK_CLEANDEPS
) $(MK_BASENAME
).map \
959 junk.tmp base.tmp temp.exp
$(MK_RC_BINARIES
) $(MK_SPECDEF
) $(MK_STUBS_SRC
) \
960 $(MK_RES_TEMPS
) $(MK_GENERATED_MAKEFILE
) $(TARGET_CLEAN
)
962 ifneq ($(TARGET_HEADERS
),)
963 $(TARGET_OBJECTS
): $(TARGET_HEADERS
)
966 # install and bootcd rules
968 ifeq ($(MK_IMPLIBONLY
),yes
)
970 # Don't install import libraries
981 # Don't install static libraries
982 ifeq ($(MK_MODE
),static
)
992 ifneq ($(MK_INSTALL
),no
)
994 install: forceinstall
1002 forceinstall
: $(SUBDIRS
:%=%_install
) $(MK_FULLNAME
)
1003 $(HALFVERBOSEECHO
) [INSTALL
] $(MK_FULLNAME
) to
$(MK_INSTALLDIR
)/$(MK_INSTALL_FULLNAME
)
1004 -$(CP
) $(MK_FULLNAME
) $(INSTALL_DIR
)/$(MK_INSTALLDIR
)/$(MK_INSTALL_FULLNAME
)
1006 # Bootstrap files for the bootable CD
1007 ifeq ($(TARGET_BOOTSTRAP
),yes
)
1009 ifneq ($(TARGET_BOOTSTRAP_NAME
),)
1010 MK_BOOTSTRAP_NAME
:= $(TARGET_BOOTSTRAP_NAME
)
1011 else # TARGET_BOOTSTRAP_NAME
1012 MK_BOOTSTRAP_NAME
:= $(MK_INSTALL_FULLNAME
)
1013 endif # TARGET_BOOTSTRAP_NAME
1015 bootcd
: $(SUBDIRS
:%=%_bootcd
)
1016 - $(CP
) $(MK_FULLNAME
) $(BOOTCD_DIR
)/reactos
/$(MK_BOOTCDDIR
)/$(MK_BOOTSTRAP_NAME
)
1018 else # TARGET_BOOTSTRAP
1022 endif # TARGET_BOOTSTRAP
1026 endif # MK_IMPLIBONLY
1028 ifeq ($(TARGET_TYPE
),winedll
)
1029 Makefile.ros
: Makefile.in Makefile.ros-template
1030 $(WINE2ROS
) Makefile.in Makefile.ros-template Makefile.ros
1032 $(MK_RC_BINARIES
): $(TARGET_RC_BINSRC
)
1033 $(BIN2RES
) -f
-o
$@
$(TARGET_RC_BINSRC
)
1035 $(MK_RESOURCE
): $(MK_RC_BINARIES
)
1037 MK_RES_TEMPS
= $(MK_RESOURCE
:.coff
=.rci
) $(MK_RESOURCE
:.coff
=.res
)
1040 REGTEST_TESTS
= $(wildcard tests
/tests
/*.c
)
1042 $(REGTEST_TARGETS
): $(REGTEST_TESTS
) .
/tests
/stubs.tst
1043 $(REGTESTS
) .
/tests
/tests .
/tests
/_regtests.c .
/tests
/Makefile.tests
-e .
/tests
/_rtstub.c
1044 $(REGTESTS
) -s .
/tests
/stubs.tst .
/tests
/_stubs.S .
/tests
/_hooks.c
1047 - $(MAKE
) -C tests TARGET_REGTESTS
=no
clean
1048 - $(RM
) .
/tests
/_rtstub.c .
/tests
/_hooks.c .
/tests
/_regtests.c .
/tests
/_stubs.S .
/tests
/Makefile.tests
1051 - $(MAKE
) -C winetests
clean
1053 .PHONY
: all depends implib
clean install dist bootcd depends gen_regtests clean_regtests clean_winetests
1056 $(SUBDIRS
:%=%_all
): %_all
:
1057 $(MAKE
) -C
$* SUBDIRS
= all
1059 $(SUBDIRS
:%=%_implib
): %_implib
:
1060 $(MAKE
) -C
$* SUBDIRS
= implib
1062 $(SUBDIRS
:%=%_test
): %_test
:
1063 $(MAKE
) -C
$* SUBDIRS
= test
1065 $(SUBDIRS
:%=%_clean
): %_clean
:
1066 $(MAKE
) -C
$* SUBDIRS
= clean
1068 $(SUBDIRS
:%=%_install
): %_install
:
1069 $(MAKE
) -C
$* SUBDIRS
= install
1071 $(SUBDIRS
:%=%_dist
): %_dist
:
1072 $(MAKE
) -C
$* SUBDIRS
= dist
1074 $(SUBDIRS
:%=%_bootcd
): %_bootcd
:
1075 $(MAKE
) -C
$* SUBDIRS
= bootcd
1077 .PHONY
: $(SUBDIRS
:%=%_all
) $(SUBDIRS
:%=%_implib
) $(SUBDIRS
:%=%_test
) \
1078 $(SUBDIRS
:%=%_clean
) $(SUBDIRS
:%=%_install
) $(SUBDIRS
:%=%_dist
) \
1079 $(SUBDIRS
:%=%_bootcd
)
1082 ifeq ($(TARGET_REGTESTS
),yes
)
1084 $(MAKE
) -C tests run
1090 ifeq ($(TARGET_TYPE
),test)
1092 @
$(MK_CC
) -nostdlib
-o _runtest.exe regtests.a
$(TARGET_LIBS
) _stubs.o \
1093 $(SDK_PATH_LIB
)/librtshared.a
$(SDK_PATH_LIB
)/libregtests.a
$(SDK_PATH_LIB
)/libpseh.a \
1094 _hooks.o
-lgcc
-lmsvcrt
-lntdll
1095 @
$(CP
) $(REGTESTS_PATH
)/regtests
/regtests.dll regtests.dll
1101 %.o
: %.c
$(MK_PCHNAME
)
1102 $(HALFVERBOSEECHO
) [CC
] $<
1103 $(MK_CC
) $(TARGET_CFLAGS
) -c
$< -o
$@
1104 %.o
: %.
cc $(MK_PCHNAME
)
1105 $(HALFVERBOSEECHO
) [CXX
] $<
1106 $(CXX
) $(TARGET_CPPFLAGS
) -c
$< -o
$@
1107 %.o
: %.
cxx $(MK_PCHNAME
)
1108 $(HALFVERBOSEECHO
) [CXX
] $<
1109 $(CXX
) $(TARGET_CPPFLAGS
) -c
$< -o
$@
1110 %.o
: %.
cpp $(MK_PCHNANE
)
1111 $(HALFVERBOSEECHO
) [CXX
] $<
1112 $(CXX
) $(TARGET_CPPFLAGS
) -c
$< -o
$@
1114 $(HALFVERBOSEECHO
) [AS
] $<
1115 $(AS
) $(TARGET_ASFLAGS
) -c
$< -o
$@
1117 $(HALFVERBOSEECHO
) [AS
] $<
1118 $(AS
) $(TARGET_ASFLAGS
) -c
$< -o
$@
1120 $(HALFVERBOSEECHO
) [NASM
] $<
1121 $(NASM_CMD
) $(TARGET_NFLAGS
) $< -o
$@
1122 ifeq ($(TARGET_TYPE
),winedll
)
1124 $(HALFVERBOSEECHO
) [RC
] $<
1125 $(MK_CC
) $(MK_PREPROC_FOR_RC_FLAGS
) $< > $(<:.rc
=.rci
)
1126 $(WRC
) $(<:.rc
=.rci
) $(<:.rc
=.res
)
1128 $(RC
) $(<:.rc
=.res
) -o
$@
1132 $(HALFVERBOSEECHO
) [RC
] $<
1133 $(RC
) $(TARGET_RCFLAGS
) $< -o
$@
1136 $(HALFVERBOSEECHO
) [DEF
] $<
1137 $(WINEBUILD
) $(DEFS
) -o
$@
--def
$<
1138 %.drv.spec.def
: %.spec
1139 $(HALFVERBOSEECHO
) [DEF
] $<
1140 $(WINEBUILD
) $(DEFS
) -o
$@
--def
$<
1142 $(HALFVERBOSEECHO
) [STUBS
] $<
1143 $(WINEBUILD
) $(DEFS
) -o
$@
--pedll
$<
1145 $(HALFVERBOSEECHO
) [CPP
] $<
1146 $(MK_CC
) $(TARGET_CFLAGS
) -E
$< > $@
1148 $(HALFVERBOSEECHO
) [PCH
] $<
1149 $(PCH_CC
) $(CFLAGS
) $<
1150 # rule for msvc conversion
1152 $(HALFVERBOSEECHO
) [MS2PS
] $<
1153 $(subst /,$(SEP
),$(MS2PS
)) -try try
-except except
-finally finally
< $< > $@
1155 # Kill implicit rule
1159 CFLAGS
:= $(TARGET_CFLAGS
)
1160 NFLAGS
:= $(TARGET_NFLAGS
)