NtSetInformationFile(): FileRenameInformation: Fixed missing fields
[reactos.git] / tools / helper.mk
1 # $Id$
2 #
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_library = Import library for a driver
11 #                        driver = Kernel mode driver
12 #                        export_driver = Kernel mode driver that have exported functions
13 #                        hal = Hardware Abstraction Layer
14 #                        bootpgm = Boot program
15 #                        miniport = Kernel mode driver that does not link with ntoskrnl.exe or hal.dll
16 #                        gdi_driver = Kernel mode graphics driver that link with win32k.sys
17 #   $TARGET_APPTYPE    = Application type (windows,native,console)
18 #   $TARGET_NAME       = Base name of output file and .rc, .def, and .edf files
19 #   $TARGET_OBJECTS    = Object files that compose the module
20 #   $TARGET_HEADERS    = Header files that the object files depend on (optional)
21 #   $TARGET_DEFNAME    = Base name of .def and .edf files (optional)
22 #   $TARGET_BASENAME   = Base name of output file (overrides $TARGET_NAME if it exists) (optional)
23 #   $TARGET_EXTENSION  = Extesion of the output file (optional)
24 #   $TARGET_DDKLIBS    = DDK libraries that are to be imported by the module (optional)
25 #   $TARGET_SDKLIBS    = SDK libraries that are to be imported by the module (optional)
26 #   $TARGET_LIBS       = Other libraries that are to be imported by the module (optional)
27 #   $TARGET_GCCLIBS    = GCC libraries imported with -l (optional)
28 #   $TARGET_LFLAGS     = GCC flags when linking (optional)
29 #   $TARGET_CFLAGS     = GCC flags (optional)
30 #   $TARGET_CPPFLAGS   = G++ flags (optional)
31 #   $TARGET_ASFLAGS    = GCC assembler flags (optional)
32 #   $TARGET_NFLAGS     = NASM flags (optional)
33 #   $TARGET_RCFLAGS    = Windres flags (optional)
34 #   $TARGET_CLEAN      = Files that are part of the clean rule (optional)
35 #   $TARGET_PATH       = Relative path for *.def, *.edf, and *.rc (optional)
36 #   $TARGET_BASE       = Default base address (optional)
37 #   $TARGET_ENTRY      = Entry point (optional)
38 #   $TARGET_DEFONLY    = Use .def instead of .edf extension (no,yes) (optional)
39 #   $TARGET_NORC       = Do not include standard resource file (no,yes) (optional)
40 #   $TARGET_LIBPATH    = Destination path for import libraries (optional)
41 #   $TARGET_INSTALLDIR = Destination path when installed (optional)
42 #   $WINE_MODE         = Compile using WINE headers (no,yes) (optional)
43 #   $WINE_RC           = Name of .rc file for WINE modules (optional)
44
45 include $(PATH_TO_TOP)/config
46
47
48 ifeq ($(TARGET_PATH),)
49 TARGET_PATH := .
50 endif
51
52
53 ifeq ($(TARGET_TYPE),program)
54   MK_MODE := user
55   MK_EXETYPE := exe
56   MK_DEFEXT := .exe
57   MK_DEFENTRY := _DEFINE_TARGET_APPTYPE
58   MK_DDKLIBS :=
59   MK_SDKLIBS :=
60 ifneq ($(WINE_MODE),yes)
61   MK_CFLAGS := -I./ -I$(SDK_PATH_INC)
62   MK_CPPFLAGS := -I./ -I$(SDK_PATH_INC)
63   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
64 else
65   MK_CFLAGS := -I$(PATH_TO_TOP)/include/wine -I./ -I$(WINE_INCLUDE)
66   MK_CPPFLAGS := -I$(PATH_TO_TOP)/include/wine -I./ -I$(WINE_INCLUDE)
67   MK_RCFLAGS := --include-dir $(PATH_TO_TOP)/include/wine --include-dir $(WINE_INCLUDE)
68 endif
69   MK_IMPLIB := no
70   MK_IMPLIBONLY := no
71   MK_IMPLIBDEFPATH :=
72   MK_IMPLIB_EXT := .a
73   MK_INSTALLDIR := bin
74   MK_DISTDIR := apps
75 ifeq ($(WINE_RC),)
76   MK_RES_BASE := $(TARGET_NAME)
77 else
78   MK_RES_BASE := $(WINE_RC)
79 endif
80 endif
81
82 ifeq ($(TARGET_TYPE),proglib)
83   MK_MODE := user
84   MK_EXETYPE := dll
85   MK_DEFEXT := .exe
86   MK_DEFENTRY := _WinMain@16
87   MK_DDKLIBS :=
88   MK_SDKLIBS :=
89   MK_CFLAGS := -I./ -I$(SDK_PATH_INC)
90   MK_CPPFLAGS := -I./ -I$(SDK_PATH_INC)
91   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
92   MK_IMPLIB := yes
93   MK_IMPLIBONLY := no
94   MK_IMPLIBDEFPATH := $(SDK_PATH_LIB)
95   MK_IMPLIB_EXT := .a
96   MK_INSTALLDIR := bin
97   MK_DISTDIR := apps
98   MK_RES_BASE := $(TARGET_NAME)
99 endif
100
101 ifeq ($(TARGET_TYPE),dynlink)
102   MK_MODE := user
103   MK_EXETYPE := dll
104   MK_DEFEXT := .dll
105   MK_DEFENTRY := _DllMain@12
106   MK_DDKLIBS :=
107   MK_SDKLIBS :=
108 ifneq ($(WINE_MODE),yes)
109   MK_CFLAGS := -I./ -I$(SDK_PATH_INC)
110   MK_CPPFLAGS := -I./ -I$(SDK_PATH_INC)
111   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
112 else
113   MK_CFLAGS := -I$(PATH_TO_TOP)/include/wine -I./ -I$(WINE_INCLUDE)
114   MK_CPPFLAGS := -I$(PATH_TO_TOP)/include/wine -I./ -I$(WINE_INCLUDE)
115   MK_RCFLAGS := --include-dir $(PATH_TO_TOP)/include/wine --include-dir $(WINE_INCLUDE)
116 endif
117   MK_IMPLIB := yes
118   MK_IMPLIBONLY := no
119   MK_IMPLIBDEFPATH := $(SDK_PATH_LIB)
120   MK_IMPLIB_EXT := .a
121   MK_INSTALLDIR := system32
122   MK_DISTDIR := dlls
123 ifeq ($(WINE_RC),)
124   MK_RES_BASE := $(TARGET_NAME)
125 else
126   MK_RES_BASE := $(WINE_RC)
127 endif
128 endif
129
130 ifeq ($(TARGET_TYPE),library)
131   MK_MODE := static
132   MK_EXETYPE :=
133   MK_DEFEXT := .a
134   MK_DEFENTRY :=
135   MK_DDKLIBS :=
136   MK_SDKLIBS :=
137   MK_CFLAGS := -I./ -I$(SDK_PATH_INC)
138   MK_CPPFLAGS := -I./ -I$(SDK_PATH_INC)
139   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
140   MK_IMPLIB := no
141   MK_IMPLIBONLY := no
142   MK_IMPLIBDEFPATH :=
143   MK_IMPLIB_EXT :=
144   MK_INSTALLDIR := system32
145   MK_DISTDIR := # FIXME
146   MK_RES_BASE :=
147 endif
148
149 ifeq ($(TARGET_TYPE),driver_library)
150   MK_MODE := kernel
151   MK_EXETYPE := dll
152   MK_DEFEXT := .dll
153   MK_DEFENTRY :=
154   MK_DDKLIBS :=
155   MK_SDKLIBS :=
156   MK_CFLAGS := -I./ -I$(DDK_PATH_INC)
157   MK_CPPFLAGS := -I./ -I$(DDK_PATH_INC)
158   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
159   MK_IMPLIB := no
160   MK_IMPLIBONLY := yes
161   MK_IMPLIBDEFPATH := $(DDK_PATH_LIB)
162   MK_IMPLIB_EXT := .a
163   MK_INSTALLDIR := $(DDK_PATH_INC)
164   MK_DISTDIR := # FIXME
165   MK_RES_BASE :=
166 endif
167
168 ifeq ($(TARGET_TYPE),driver)
169   MK_MODE := kernel
170   MK_EXETYPE := dll
171   MK_DEFEXT := .sys
172   MK_DEFENTRY := _DriverEntry@8
173   MK_DDKLIBS := ntoskrnl.a hal.a
174   MK_SDKLIBS :=
175   MK_CFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
176   MK_CPPFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
177   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
178   MK_IMPLIB := no
179   MK_IMPLIBONLY := no
180   MK_IMPLIBDEFPATH :=
181   MK_IMPLIB_EXT := .a
182   MK_INSTALLDIR := system32/drivers
183   MK_DISTDIR := drivers
184   MK_RES_BASE := $(TARGET_NAME)
185 endif
186
187 ifeq ($(TARGET_TYPE),export_driver)
188   MK_MODE := kernel
189   MK_EXETYPE := dll
190   MK_DEFEXT := .sys
191   MK_DEFENTRY := _DriverEntry@8
192   MK_DDKLIBS := ntoskrnl.a hal.a
193   MK_SDKLIBS :=
194   MK_CFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
195   MK_CPPFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
196   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
197   MK_IMPLIB := yes
198   MK_IMPLIBONLY := no
199   MK_IMPLIBDEFPATH := $(DDK_PATH_LIB)
200   MK_IMPLIB_EXT := .a
201   MK_INSTALLDIR := system32/drivers
202   MK_DISTDIR := drivers
203   MK_RES_BASE := $(TARGET_NAME)
204 endif
205
206 ifeq ($(TARGET_TYPE),hal)
207   MK_MODE := kernel
208   MK_EXETYPE := dll
209   MK_DEFEXT := .dll
210   MK_DEFENTRY := _DriverEntry@8
211   MK_DDKLIBS := ntoskrnl.a
212   MK_SDKLIBS :=
213   MK_CFLAGS := -D__NTHAL__ -I./ -I$(DDK_PATH_INC)
214   MK_CPPFLAGS := -D__NTHAL__ -I./ -I$(DDK_PATH_INC)
215   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
216   MK_IMPLIB := yes
217   MK_IMPLIBONLY := no
218   MK_IMPLIBDEFPATH :=
219   MK_IMPLIB_EXT := .a
220   MK_INSTALLDIR := system32
221   MK_DISTDIR := dlls
222   MK_RES_BASE := $(TARGET_NAME)
223 endif
224
225 ifeq ($(TARGET_TYPE),bootpgm)
226   MK_MODE := kernel
227   MK_EXETYPE := exe
228   MK_DEFEXT := .exe
229   MK_DEFENTRY := _DriverEntry@8
230   MK_DDKLIBS :=
231   MK_SDKLIBS :=
232   MK_CFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
233   MK_CPPFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
234   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
235   MK_IMPLIB := no
236   MK_IMPLIBONLY := no
237   MK_IMPLIBDEFPATH :=
238   MK_IMPLIB_EXT := .a
239   MK_INSTALLDIR := system32
240   MK_DISTDIR := # FIXME
241   MK_RES_BASE := $(TARGET_NAME)
242 endif
243
244 ifeq ($(TARGET_TYPE),miniport)
245   MK_MODE := kernel
246   MK_EXETYPE := dll
247   MK_DEFEXT := .sys
248   MK_DEFENTRY := _DriverEntry@8
249   MK_DDKLIBS :=
250   MK_SDKLIBS :=
251   MK_CFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
252   MK_CPPFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
253   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
254   MK_IMPLIB := no
255   MK_IMPLIBONLY := no
256   MK_IMPLIBDEFPATH :=
257   MK_IMPLIB_EXT := .a
258   MK_INSTALLDIR := system32/drivers
259   MK_DISTDIR := drivers
260   MK_RES_BASE := $(TARGET_NAME)
261 endif
262
263 ifeq ($(TARGET_TYPE),gdi_driver)
264   MK_MODE := kernel
265   MK_EXETYPE := dll
266   MK_DEFEXT := .dll
267   MK_DEFENTRY := _DrvEnableDriver@12
268   MK_DDKLIBS := ntoskrnl.a hal.a win32k.a
269   MK_SDKLIBS :=
270   MK_CFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
271   MK_CPPFLAGS := -D__NTDRIVER__ -I./ -I$(DDK_PATH_INC)
272   MK_RCFLAGS := --include-dir $(SDK_PATH_INC)
273   MK_IMPLIB := yes
274   MK_IMPLIBONLY := no
275   MK_IMPLIBDEFPATH := $(DDK_PATH_LIB)
276   MK_IMPLIB_EXT := .a
277   MK_INSTALLDIR := system32/drivers
278   MK_DISTDIR := drivers
279   MK_RES_BASE := $(TARGET_NAME)
280 endif
281
282
283 ifeq ($(TARGET_TYPE),program)
284   ifeq ($(TARGET_APPTYPE),windows)
285     MK_DEFENTRY := _WinMainCRTStartup
286     MK_SDKLIBS := ntdll.a kernel32.a gdi32.a user32.a
287     TARGET_LFLAGS += -Wl,--subsystem,windows
288   endif
289
290   ifeq ($(TARGET_APPTYPE),native)
291     MK_DEFENTRY := _NtProcessStartup@4
292     MK_SDKLIBS := ntdll.a
293     TARGET_LFLAGS += -Wl,--subsystem,native -nostartfiles
294   endif
295
296   ifeq ($(TARGET_APPTYPE),console)
297     MK_DEFENTRY := _mainCRTStartup
298     MK_SDKLIBS :=
299     TARGET_LFLAGS += -Wl,--subsystem,console
300   endif
301 endif
302
303
304 MK_RESOURCE := $(MK_RES_BASE).coff
305
306
307 ifneq ($(TARGET_INSTALLDIR),)
308   MK_INSTALLDIR := $(TARGET_INSTALLDIR)
309 endif
310
311
312 ifeq ($(TARGET_LIBPATH),)
313   MK_IMPLIBPATH := $(MK_IMPLIBDEFPATH)
314 else
315   MK_IMPLIBPATH := $(TARGET_LIBPATH)
316 endif
317
318
319 ifeq ($(TARGET_BASENAME),)
320   MK_BASENAME := $(TARGET_NAME)
321 else
322   MK_BASENAME := $(TARGET_BASENAME)
323 endif
324
325
326 ifeq ($(TARGET_EXTENSION),)
327   MK_EXT := $(MK_DEFEXT)
328 else
329   MK_EXT := $(TARGET_EXTENSION)
330 endif
331
332
333 ifeq ($(TARGET_NORC),yes)
334   MK_FULLRES :=
335 else
336   MK_FULLRES := $(TARGET_PATH)/$(MK_RESOURCE)
337 endif
338
339
340 ifeq ($(TARGET_DEFNAME),)
341   MK_DEFBASE := $(TARGET_NAME)
342 else
343   MK_DEFBASE := $(TARGET_DEFNAME)
344 endif
345
346 MK_DEFNAME := $(TARGET_PATH)/$(MK_DEFBASE).def
347 ifeq ($(TARGET_DEFONLY),yes)
348   MK_EDFNAME := $(MK_DEFNAME)
349 else
350   MK_EDFNAME := $(TARGET_PATH)/$(MK_DEFBASE).edf
351 endif
352
353
354 ifeq ($(MK_MODE),user)
355   MK_DEFBASE := 0x400000
356   ifneq ($(TARGET_SDKLIBS),)
357     MK_LIBS := $(addprefix $(SDK_PATH_LIB)/, $(TARGET_SDKLIBS))
358   else
359     MK_LIBS := $(addprefix $(SDK_PATH_LIB)/, $(MK_SDKLIBS))
360   endif
361 endif
362
363
364 ifeq ($(MK_MODE),kernel)
365   MK_DEFBASE := 0x10000
366   MK_LIBS := $(addprefix $(DDK_PATH_LIB)/, $(MK_DDKLIBS) $(TARGET_DDKLIBS))
367 endif
368
369
370 ifeq ($(TARGET_BASE),)
371   TARGET_BASE := $(MK_DEFBASE)
372 endif
373
374
375 ifeq ($(TARGET_ENTRY),)
376   TARGET_ENTRY := $(MK_DEFENTRY)
377 endif
378
379
380 #
381 # Include details of the OS configuration
382 #
383 include $(PATH_TO_TOP)/config
384
385
386 TARGET_CFLAGS += $(MK_CFLAGS)
387 TARGET_CFLAGS += -pipe -march=$(ARCH)
388 ifeq ($(DBG),1)
389 TARGET_ASFLAGS += -g
390 TARGET_CFLAGS += -g
391 TARGET_LFLAGS += -g
392 endif
393
394 TARGET_CPPFLAGS += $(MK_CPPFLAGS)
395 TARGET_CPPFLAGS += -pipe -march=$(ARCH)
396
397 TARGET_RCFLAGS += $(MK_RCFLAGS)
398
399 TARGET_ASFLAGS += $(MK_ASFLAGS)
400 TARGET_ASFLAGS += -pipe -march=$(ARCH)
401
402 TARGET_NFLAGS += $(MK_NFLAGS)
403
404
405 MK_GCCLIBS := $(addprefix -l, $(TARGET_GCCLIBS))
406
407 MK_FULLNAME := $(MK_BASENAME)$(MK_EXT)
408 MK_IMPLIB_FULLNAME := $(MK_BASENAME)$(MK_IMPLIB_EXT)
409
410 MK_NOSTRIPNAME := $(MK_BASENAME).nostrip$(MK_EXT)
411
412 # We don't want to link header files
413 MK_OBJECTS := $(filter-out %.h,$(TARGET_OBJECTS))
414 MK_STRIPPED_OBJECT := $(MK_BASENAME).stripped.o
415
416 ifeq ($(MK_IMPLIBONLY),yes)
417
418 TARGET_CLEAN += $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME)
419
420 all: $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME)
421
422 $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME): $(TARGET_OBJECTS)
423         $(DLLTOOL) \
424                 --dllname $(MK_FULLNAME) \
425                 --def $(MK_DEFNAME) \
426                 --output-lib $(MK_IMPLIBPATH)/$(MK_BASENAME).a \
427                 --kill-at
428
429 else # MK_IMPLIBONLY
430
431
432 all: $(MK_FULLNAME) $(MK_NOSTRIPNAME)
433
434
435 ifeq ($(MK_IMPLIB),yes)
436   MK_EXTRACMD := --def $(MK_EDFNAME)
437 else
438   MK_EXTRACMD :=
439 endif
440
441 # User mode targets
442 ifeq ($(MK_MODE),user)
443
444 ifeq ($(MK_EXETYPE),dll)
445   TARGET_LFLAGS += -mdll -Wl,--image-base,$(TARGET_BASE)
446   MK_EXTRACMD2 := -Wl,temp.exp
447 else
448   MK_EXTRACMD2 :=
449 endif
450
451 $(MK_NOSTRIPNAME): $(MK_FULLRES) $(TARGET_OBJECTS) $(MK_LIBS)
452 ifeq ($(MK_EXETYPE),dll)
453         $(CC) -Wl,--base-file,base.tmp \
454                 -Wl,--entry,$(TARGET_ENTRY) \
455                 $(TARGET_LFLAGS) \
456                 -o junk.tmp \
457                 $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS)
458         - $(RM) junk.tmp
459         $(DLLTOOL) --dllname $(MK_FULLNAME) \
460                 --base-file base.tmp \
461                 --output-exp temp.exp $(MK_EXTRACMD)
462         - $(RM) base.tmp
463 endif
464         $(CC) $(TARGET_LFLAGS) \
465                 -Wl,--entry,$(TARGET_ENTRY) $(MK_EXTRACMD2) \
466           -o $(MK_NOSTRIPNAME) \
467           $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS)
468         - $(RM) temp.exp
469         - $(RSYM) $(MK_NOSTRIPNAME) $(MK_BASENAME).sym
470
471 $(MK_FULLNAME): $(MK_NOSTRIPNAME)
472          $(CP) $(MK_NOSTRIPNAME) $(MK_FULLNAME)
473 #        $(STRIP) --strip-debug $(MK_FULLNAME)
474
475 endif # KM_MODE
476
477 # Kernel mode targets
478 ifeq ($(MK_MODE),kernel)
479
480 ifeq ($(MK_IMPLIB),yes)
481   MK_EXTRACMD := --def $(MK_EDFNAME)
482 else
483   MK_EXTRACMD :=
484 endif
485
486 $(MK_NOSTRIPNAME): $(MK_FULLRES) $(TARGET_OBJECTS) $(MK_LIBS)
487         $(CC) -Wl,--base-file,base.tmp \
488                 -Wl,--entry,$(TARGET_ENTRY) \
489                 $(TARGET_LFLAGS) \
490                 -nostartfiles -nostdlib \
491                 -o junk.tmp \
492                 $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS)
493         - $(RM) junk.tmp
494         $(DLLTOOL) --dllname $(MK_FULLNAME) \
495                 --base-file base.tmp \
496                 --output-exp temp.exp $(MK_EXTRACMD)
497         - $(RM) base.tmp
498         $(CC) $(TARGET_LFLAGS) \
499                 -Wl,--subsystem,native \
500                 -Wl,--image-base,$(TARGET_BASE) \
501                 -Wl,--file-alignment,0x1000 \
502                 -Wl,--section-alignment,0x1000 \
503                 -Wl,--entry,$(TARGET_ENTRY) \
504                 -Wl,temp.exp \
505                 -mdll -nostartfiles -nostdlib \
506                 -o $(MK_NOSTRIPNAME) \
507           $(MK_FULLRES) $(MK_OBJECTS) $(MK_LIBS) $(MK_GCCLIBS)
508         - $(RM) temp.exp
509         $(RSYM) $(MK_NOSTRIPNAME) $(MK_BASENAME).sym
510
511 $(MK_FULLNAME): $(MK_FULLRES) $(TARGET_OBJECTS) $(MK_LIBS) $(MK_NOSTRIPNAME)
512         $(LD) -r -o $(MK_STRIPPED_OBJECT) $(MK_OBJECTS)
513         $(STRIP) --strip-debug $(MK_STRIPPED_OBJECT)
514         $(CC) -Wl,--base-file,base.tmp \
515                 -Wl,--entry,$(TARGET_ENTRY) \
516                 $(TARGET_LFLAGS) \
517                 -nostartfiles -nostdlib \
518                 -o junk.tmp \
519                 $(MK_FULLRES) $(MK_STRIPPED_OBJECT) $(MK_LIBS) $(MK_GCCLIBS)
520         - $(RM) junk.tmp
521         $(DLLTOOL) --dllname $(MK_FULLNAME) \
522                 --base-file base.tmp \
523                 --output-exp temp.exp $(MK_EXTRACMD)
524         - $(RM) base.tmp
525         $(CC) $(TARGET_LFLAGS) \
526                 -Wl,--subsystem,native \
527                 -Wl,--image-base,$(TARGET_BASE) \
528                 -Wl,--file-alignment,0x1000 \
529                 -Wl,--section-alignment,0x1000 \
530                 -Wl,--entry,$(TARGET_ENTRY) \
531                 -Wl,temp.exp \
532                 -mdll -nostartfiles -nostdlib \
533                 -o $(MK_FULLNAME) \
534           $(MK_FULLRES) $(MK_STRIPPED_OBJECT) $(MK_LIBS) $(MK_GCCLIBS)
535         - $(RM) temp.exp
536
537 endif # MK_MODE
538
539 # Static library target
540 ifeq ($(MK_MODE),static)
541
542 $(MK_FULLNAME): $(TARGET_OBJECTS)
543         $(AR) -r $(MK_FULLNAME) $(TARGET_OBJECTS)
544
545 endif # MK_MODE
546
547 endif # MK_IMPLIBONLY
548
549
550 $(MK_FULLRES): $(PATH_TO_TOP)/include/reactos/buildno.h $(TARGET_PATH)/$(MK_RES_BASE).rc
551
552 ifeq ($(MK_IMPLIB),yes)
553 $(MK_IMPLIBPATH)/$(MK_BASENAME).a: $(MK_DEFNAME)
554         $(DLLTOOL) --dllname $(MK_FULLNAME) \
555                 --def $(MK_DEFNAME) \
556                 --output-lib $(MK_IMPLIBPATH)/$(MK_BASENAME).a \
557                 --kill-at
558
559 implib: $(MK_IMPLIBPATH)/$(MK_BASENAME).a
560 else
561 implib:
562 endif
563
564 # Be carefull not to clean non-object files
565 MK_CLEANFILES := $(filter %.o,$(MK_OBJECTS))
566
567 clean:
568         - $(RM) *.o $(MK_BASENAME).sym $(MK_BASENAME).a $(TARGET_PATH)/$(MK_RES_BASE).coff \
569           $(MK_FULLNAME) $(MK_NOSTRIPNAME) $(MK_CLEANFILES) \
570           junk.tmp base.tmp temp.exp \
571           $(TARGET_CLEAN)
572
573 ifneq ($(TARGET_HEADERS),)
574 $(TARGET_OBJECTS): $(TARGET_HEADERS)
575 endif
576
577 # install and dist rules
578
579 ifeq ($(MK_IMPLIBONLY),yes)
580
581 # Don't install import libraries
582
583 install:
584
585 dist:
586
587 else # MK_IMPLIBONLY
588
589
590 install: $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_FULLNAME)
591
592 $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_FULLNAME): $(MK_FULLNAME) $(MK_BASENAME).sym
593         $(CP) $(MK_FULLNAME) $(INSTALL_DIR)/$(MK_INSTALLDIR)/$(MK_FULLNAME)
594         $(CP) $(MK_BASENAME).sym $(INSTALL_DIR)/symbols/$(MK_BASENAME).sym
595
596
597 dist: $(DIST_DIR)/$(MK_DISTDIR)/$(MK_FULLNAME)
598
599 $(DIST_DIR)/$(MK_DISTDIR)/$(MK_FULLNAME): $(MK_FULLNAME)
600         $(CP) $(MK_FULLNAME) $(DIST_DIR)/$(MK_DISTDIR)/$(MK_FULLNAME)
601         $(CP) $(MK_BASENAME).sym $(DIST_DIR)/symbols/$(MK_BASENAME).sym
602
603
604 endif # MK_IMPLIBONLY
605
606
607 .phony: all implib clean install dist
608
609
610 %.o: %.c
611         $(CC) $(TARGET_CFLAGS) -c $< -o $@
612 %.o: %.cc
613         $(CC) $(TARGET_CPPFLAGS) -c $< -o $@
614 %.o: %.cpp
615         $(CC) $(TARGET_CPPFLAGS) -c $< -o $@
616 %.o: %.S
617         $(AS) $(TARGET_ASFLAGS) -c $< -o $@
618 %.o: %.s
619         $(AS) $(TARGET_ASFLAGS) -c $< -o $@
620 %.o: %.asm
621         $(NASM_CMD) $(NFLAGS) $(TARGET_NFLAGS) $< -o $@
622 %.coff: %.rc
623         $(RC) $(TARGET_RCFLAGS) $(RCINC) $< -o $@
624
625
626 # Compatibility
627 CFLAGS := $(TARGET_CFLAGS)
628
629 # EOF