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