1 | # $Id: Makefile.kmk 29 2009-07-01 20:30:29Z bird $
|
---|
2 | ## @file
|
---|
3 | # kLdr - The Dynamic Loader, sub-makefile.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (c) 2006-2007 Knut St. Osmundsen <[email protected]>
|
---|
8 | #
|
---|
9 | # Permission is hereby granted, free of charge, to any person
|
---|
10 | # obtaining a copy of this software and associated documentation
|
---|
11 | # files (the "Software"), to deal in the Software without
|
---|
12 | # restriction, including without limitation the rights to use,
|
---|
13 | # copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
14 | # copies of the Software, and to permit persons to whom the
|
---|
15 | # Software is furnished to do so, subject to the following
|
---|
16 | # conditions:
|
---|
17 | #
|
---|
18 | # The above copyright notice and this permission notice shall be
|
---|
19 | # included in all copies or substantial portions of the Software.
|
---|
20 | #
|
---|
21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
22 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
23 | # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
24 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
25 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
26 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
27 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
28 | # OTHER DEALINGS IN THE SOFTWARE.
|
---|
29 | #
|
---|
30 |
|
---|
31 | DEPTH ?= ..
|
---|
32 | SUB_DEPTH = ..
|
---|
33 | include $(PATH_KBUILD)/subheader.kmk
|
---|
34 |
|
---|
35 | #todo: include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
|
---|
36 |
|
---|
37 | #
|
---|
38 | # Template for testcases.
|
---|
39 | #
|
---|
40 | TEMPLATE_TST = Testcase template
|
---|
41 | ifeq ($(BUILD_TARGET),win)
|
---|
42 | ifeq ($(BUILD_TARGET_ARCH), x86)
|
---|
43 | TEMPLATE_TST_TOOL = VCC70
|
---|
44 | TEMPLATE_TST_CFLAGS = -W3 -Zi -Zl -MD
|
---|
45 | TEMPLATE_TST_LIBS = $(PATH_TOOL_VCC70_LIB)/msvcrt.lib
|
---|
46 | else
|
---|
47 | TEMPLATE_TST_TOOL = VCC80AMD64
|
---|
48 | TEMPLATE_TST_CFLAGS = -W3 -Zi -Zl -MD
|
---|
49 | TEMPLATE_TST_LIBS = $(PATH_TOOL_VCC80AMD64_LIB)/msvcrt.lib
|
---|
50 | endif
|
---|
51 | TEMPLATE_TST_CFLAGS.release = -O2
|
---|
52 | TEMPLATE_TST_ASFLAGS = -f win
|
---|
53 | TEMPLATE_TST_DEFS = __WIN__
|
---|
54 | TEMPLATE_TST_SDKS = WINPSDK W2K3DDK
|
---|
55 |
|
---|
56 | else
|
---|
57 | ifeq ($(BUILD_TARGET),os2)
|
---|
58 | TEMPLATE_TST_TOOL = GCC3OMF
|
---|
59 | TEMPLATE_TST_ASFLAGS = -f obj
|
---|
60 | TEMPLATE_TST_LIBS = os2 gcc end
|
---|
61 | else ifeq ($(BUILD_TARGET),darwin)
|
---|
62 | TEMPLATE_TST_TOOL = GCC4MACHO
|
---|
63 | TEMPLATE_TST_ASFLAGS = -f macho
|
---|
64 | TEMPLATE_TST_LIBS = #os2 gcc end
|
---|
65 | else
|
---|
66 | TEMPLATE_TST_TOOL = GCC3
|
---|
67 | TEMPLATE_TST_ASFLAGS = -f elf
|
---|
68 | TEMPLATE_TST_LIBS = gcc
|
---|
69 | endif
|
---|
70 | TEMPLATE_TST_CFLAGS = -Wall -pedantic -g -std=gnu99
|
---|
71 | TEMPLATE_TST_CFLAGS.release = -O2
|
---|
72 | TEMPLATE_TST_LDFLAGS =
|
---|
73 | endif
|
---|
74 | TEMPLATE_TST_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
|
---|
75 |
|
---|
76 |
|
---|
77 | #
|
---|
78 | # The kLdr DLL.
|
---|
79 | #
|
---|
80 | DLLS += kLdr
|
---|
81 | kLdr_ASTOOL = NASM
|
---|
82 | ifeq ($(BUILD_TARGET),win)
|
---|
83 | ifeq ($(BUILD_TARGET_ARCH),x86)
|
---|
84 | kLdr_TOOL = VCC70
|
---|
85 | kLdr_CFLAGS = -W3 -Zl -ML
|
---|
86 | kLdr_LDFLAGS = -Entry:DllMain@12 -Debug
|
---|
87 | kLdr_LIBS = \
|
---|
88 | $(PATH_TOOL_VCC70_LIB)/LIBC.lib \
|
---|
89 | $(PATH_SDK_W2K3DDKX86_LIB)/ntdll.lib
|
---|
90 | else
|
---|
91 | kLdr_TOOL = VCC80AMD64
|
---|
92 | kLdr_ASTOOL = YASM
|
---|
93 | kLdr_CFLAGS = -W3 -Zl -MT
|
---|
94 | kLdr_LDFLAGS = -Entry:DllMain -Debug
|
---|
95 | kLdr_LIBS = \
|
---|
96 | $(PATH_TOOL_VCC80AMD64_LIB)/LIBCMT.lib \
|
---|
97 | $(PATH_SDK_W2K3DDKAMD64_LIB)/ntdll.lib
|
---|
98 | endif
|
---|
99 | kLdr_ASFLAGS = -f win
|
---|
100 | kLdr_DEFS = __WIN__
|
---|
101 | kLdr_SDKS.x86 = WIN32SDK W2K3DDKX86
|
---|
102 | kLdr_SDKS.amd64 = WIN64SDK W2K3DDKAMD64
|
---|
103 | else
|
---|
104 | ifeq ($(BUILD_TARGET),os2)
|
---|
105 | kLdr_TOOL = GCC3OMF
|
---|
106 | kLdr_ASFLAGS = -f obj
|
---|
107 | kLdr_LIBS = os2 gcc end
|
---|
108 | else ifeq ($(BUILD_TARGET),darwin)
|
---|
109 | kLdr_TOOL = GCC4MACHO
|
---|
110 | kLdr_ASFLAGS = -f macho
|
---|
111 | kLdr_LIBS = #os2 gcc end
|
---|
112 | else
|
---|
113 | kLdr_TOOL = GCC3
|
---|
114 | kLdr_ASFLAGS = -f elf
|
---|
115 | kLdr_LIBS = gcc
|
---|
116 | endif
|
---|
117 | kLdr_CFLAGS = -Wall -pedantic
|
---|
118 | kLdr_LDFLAGS = -nostdlib
|
---|
119 | endif
|
---|
120 | kLdr_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
|
---|
121 | kLdr_SOURCES = \
|
---|
122 | kLdr.c \
|
---|
123 | kLdrDyld.c \
|
---|
124 | kLdrDyldFind.c \
|
---|
125 | kLdrDyldMod.c \
|
---|
126 | kLdrDyldOS.c \
|
---|
127 | kLdrDyLdSem.c \
|
---|
128 | kLdrMod.c \
|
---|
129 | kLdrModLX.c \
|
---|
130 | kLdrModMachO.c \
|
---|
131 | kLdrModNative.c \
|
---|
132 | kLdrModPE.c
|
---|
133 | kLdr_SOURCES.os2 = \
|
---|
134 | kLdr-os2.def \
|
---|
135 | kLdr-os2.c \
|
---|
136 | kLdrA-os2.asm
|
---|
137 | kLdr_SOURCES.win = \
|
---|
138 | kLdr-win.def \
|
---|
139 | kLdr-win.c
|
---|
140 | kLdr_LIBS += \
|
---|
141 | $(PATH_LIB)/kRdrStatic$(SUFF_LIB) \
|
---|
142 | $(PATH_LIB)/kCpuStatic$(SUFF_LIB) \
|
---|
143 | $(PATH_LIB)/kHlpBareStatic$(SUFF_LIB) \
|
---|
144 | $(PATH_LIB)/kErrStatic$(SUFF_LIB)
|
---|
145 |
|
---|
146 | #
|
---|
147 | # A static edition of kLdr.
|
---|
148 | #
|
---|
149 | LIBRARIES += kLdrStatic
|
---|
150 | kLdrStatic_TEMPLATE = kStuffLIB
|
---|
151 | kLdrStatic_SDKS.win = WINPSDK W2K3DDK
|
---|
152 | kLdrStatic_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
|
---|
153 | kLdrStatic_DEFS.darwin = __DARWIN__
|
---|
154 | kLdrStatic_DEFS.os2 = __OS2__
|
---|
155 | kLdrStatic_DEFS.win = __WIN__
|
---|
156 | kLdrStatic_SOURCES = $(kLdr_SOURCES)
|
---|
157 |
|
---|
158 | #
|
---|
159 | # The OS/2 stub program.
|
---|
160 | #
|
---|
161 | PROGRAMS.os2 = kLdrExeStub-os2
|
---|
162 | kLdrExeStub-os2_TOOL = GCC3OMF
|
---|
163 | kLdrExeStub-os2_ASTOOL = NASM
|
---|
164 | kLdrExeStub-os2_ASFLAGS = -f obj
|
---|
165 | #kLdrExeStub-os2_LDFLAGS = -nostdlib
|
---|
166 | kLdrExeStub-os2_LDFLAGS = -nostdlib -Zstack 64
|
---|
167 | kLdrExeStub-os2_LIBS = $(TARGET_kLdr)
|
---|
168 | #kLdrExeStub-os2_SOURCES = kLdrExeStub-os2.asm
|
---|
169 | kLdrExeStub-os2_SOURCES = kLdrExeStub-os2A.asm kLdrExeStub-os2.c
|
---|
170 |
|
---|
171 | #
|
---|
172 | # The Windows stub program.
|
---|
173 | #
|
---|
174 | PROGRAMS.win = kLdrExeStub-win
|
---|
175 | kLdrExeStub-win_TOOL.win.x86 = VCC70
|
---|
176 | kLdrExeStub-win_TOOL.win.amd64 = VCC80AMD64
|
---|
177 | kLdrExeStub-win_SDKS.x86 = WIN32SDK
|
---|
178 | kLdrExeStub-win_SDKS.amd64 = WIN64SDK
|
---|
179 | kLdrExeStub-win_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
|
---|
180 | kLdrExeStub-win_DEFS = __WIN__
|
---|
181 | kLdrExeStub-win_CFLAGS = -W3 -Zl
|
---|
182 | kLdrExeStub-win_CFLAGS.debug = -Zi
|
---|
183 | kLdrExeStub-win_LDFLAGS = -Entry:WindowsMain -SubSystem:Console -FIXED:NO
|
---|
184 | kLdrExeStub-win_LIBS = $(TARGET_kLdr:.dll=.lib)
|
---|
185 | kLdrExeStub-win_SOURCES = kLdrExeStub-win.c
|
---|
186 |
|
---|
187 |
|
---|
188 | ##
|
---|
189 | ## The (stub) utility.
|
---|
190 | ##
|
---|
191 | #PROGRAMS = kLdrUtil
|
---|
192 |
|
---|
193 |
|
---|
194 | #
|
---|
195 | # Heap testcase.
|
---|
196 | #
|
---|
197 | #PROGRAMS += tstkLdrHeap
|
---|
198 | tstkLdrHeap_TEMPLATE = TST
|
---|
199 | tstkLdrHeap_SOURCES = \
|
---|
200 | tstkLdrHeap.c \
|
---|
201 | kHlp.c \
|
---|
202 | kHlpHeap.c \
|
---|
203 | kHlpMem.c \
|
---|
204 | kHlpPath.c \
|
---|
205 | kHlpSem.c \
|
---|
206 | kHlpStr.c \
|
---|
207 |
|
---|
208 | #
|
---|
209 | # Heap testcase.
|
---|
210 | #
|
---|
211 | PROGRAMS += tstkLdrMod
|
---|
212 | tstkLdrMod_TEMPLATE = TST
|
---|
213 | tstkLdrMod_SOURCES = \
|
---|
214 | tstkLdrMod.c
|
---|
215 | ifeq ($(BUILD_TARGET),win)
|
---|
216 | tstkLdrMod_LIBS = $(TARGET_kLdr:.dll=.lib)
|
---|
217 | else
|
---|
218 | tstkLdrMod_LIBS = $(TARGET_kLdr)
|
---|
219 | endif
|
---|
220 |
|
---|
221 |
|
---|
222 | # Generate rules.
|
---|
223 | include $(PATH_KBUILD)/subfooter.kmk
|
---|
224 |
|
---|