1 | # $Id: Makefile.kmk 5 2008-02-03 20:56:09Z 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 | # This file is part of kStuff.
|
---|
10 | #
|
---|
11 | # kStuff is free software; you can redistribute it and/or
|
---|
12 | # modify it under the terms of the GNU Lesser General Public
|
---|
13 | # License as published by the Free Software Foundation; either
|
---|
14 | # version 2.1 of the License, or (at your option) any later version.
|
---|
15 | #
|
---|
16 | # kStuff is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | # Lesser General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU Lesser General Public
|
---|
22 | # License along with kStuff; if not, write to the Free Software
|
---|
23 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
24 | #
|
---|
25 | #
|
---|
26 |
|
---|
27 | DEPTH ?= ..
|
---|
28 | SUB_DEPTH = ..
|
---|
29 | include $(PATH_KBUILD)/subheader.kmk
|
---|
30 |
|
---|
31 | #todo: include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
|
---|
32 |
|
---|
33 | #
|
---|
34 | # Template for testcases.
|
---|
35 | #
|
---|
36 | TEMPLATE_TST = Testcase template
|
---|
37 | ifeq ($(BUILD_TARGET),win)
|
---|
38 | ifeq ($(BUILD_TARGET_ARCH), x86)
|
---|
39 | TEMPLATE_TST_TOOL = VCC70
|
---|
40 | TEMPLATE_TST_CFLAGS = -W3 -Zi -Zl -MD
|
---|
41 | TEMPLATE_TST_LIBS = $(PATH_TOOL_VCC70_LIB)/msvcrt.lib
|
---|
42 | else
|
---|
43 | TEMPLATE_TST_TOOL = VCC80AMD64
|
---|
44 | TEMPLATE_TST_CFLAGS = -W3 -Zi -Zl -MD
|
---|
45 | TEMPLATE_TST_LIBS = $(PATH_TOOL_VCC80AMD64_LIB)/msvcrt.lib
|
---|
46 | endif
|
---|
47 | TEMPLATE_TST_CFLAGS.release = -O2
|
---|
48 | TEMPLATE_TST_ASFLAGS = -f win
|
---|
49 | TEMPLATE_TST_DEFS = __WIN__
|
---|
50 | TEMPLATE_TST_SDKS = WINPSDK W2K3DDK
|
---|
51 |
|
---|
52 | else
|
---|
53 | ifeq ($(BUILD_TARGET),os2)
|
---|
54 | TEMPLATE_TST_TOOL = GCC3OMF
|
---|
55 | TEMPLATE_TST_ASFLAGS = -f obj
|
---|
56 | TEMPLATE_TST_LIBS = os2 gcc end
|
---|
57 | else ifeq ($(BUILD_TARGET),darwin)
|
---|
58 | TEMPLATE_TST_TOOL = GCC4MACHO
|
---|
59 | TEMPLATE_TST_ASFLAGS = -f macho
|
---|
60 | TEMPLATE_TST_LIBS = #os2 gcc end
|
---|
61 | else
|
---|
62 | TEMPLATE_TST_TOOL = GCC3
|
---|
63 | TEMPLATE_TST_ASFLAGS = -f elf
|
---|
64 | TEMPLATE_TST_LIBS = gcc
|
---|
65 | endif
|
---|
66 | TEMPLATE_TST_CFLAGS = -Wall -pedantic -g -std=gnu99
|
---|
67 | TEMPLATE_TST_CFLAGS.release = -O2
|
---|
68 | TEMPLATE_TST_LDFLAGS =
|
---|
69 | endif
|
---|
70 | TEMPLATE_TST_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
|
---|
71 |
|
---|
72 |
|
---|
73 | #
|
---|
74 | # The kLdr DLL.
|
---|
75 | #
|
---|
76 | DLLS += kLdr
|
---|
77 | kLdr_ASTOOL = NASM
|
---|
78 | ifeq ($(BUILD_TARGET),win)
|
---|
79 | ifeq ($(BUILD_TARGET_ARCH),x86)
|
---|
80 | kLdr_TOOL = VCC70
|
---|
81 | kLdr_CFLAGS = -W3 -Zl -ML
|
---|
82 | kLdr_LDFLAGS = -Entry:DllMain@12 -Debug
|
---|
83 | kLdr_LIBS = \
|
---|
84 | $(PATH_TOOL_VCC70_LIB)/LIBC.lib \
|
---|
85 | $(PATH_SDK_W2K3DDKX86_LIB)/ntdll.lib
|
---|
86 | else
|
---|
87 | kLdr_TOOL = VCC80AMD64
|
---|
88 | kLdr_ASTOOL = YASM
|
---|
89 | kLdr_CFLAGS = -W3 -Zl -MT
|
---|
90 | kLdr_LDFLAGS = -Entry:DllMain -Debug
|
---|
91 | kLdr_LIBS = \
|
---|
92 | $(PATH_TOOL_VCC80AMD64_LIB)/LIBCMT.lib \
|
---|
93 | $(PATH_SDK_W2K3DDKAMD64_LIB)/ntdll.lib
|
---|
94 | endif
|
---|
95 | kLdr_ASFLAGS = -f win
|
---|
96 | kLdr_DEFS = __WIN__
|
---|
97 | kLdr_SDKS.x86 = WIN32SDK W2K3DDKX86
|
---|
98 | kLdr_SDKS.amd64 = WIN64SDK W2K3DDKAMD64
|
---|
99 | else
|
---|
100 | ifeq ($(BUILD_TARGET),os2)
|
---|
101 | kLdr_TOOL = GCC3OMF
|
---|
102 | kLdr_ASFLAGS = -f obj
|
---|
103 | kLdr_LIBS = os2 gcc end
|
---|
104 | else ifeq ($(BUILD_TARGET),darwin)
|
---|
105 | kLdr_TOOL = GCC4MACHO
|
---|
106 | kLdr_ASFLAGS = -f macho
|
---|
107 | kLdr_LIBS = #os2 gcc end
|
---|
108 | else
|
---|
109 | kLdr_TOOL = GCC3
|
---|
110 | kLdr_ASFLAGS = -f elf
|
---|
111 | kLdr_LIBS = gcc
|
---|
112 | endif
|
---|
113 | kLdr_CFLAGS = -Wall -pedantic
|
---|
114 | kLdr_LDFLAGS = -nostdlib
|
---|
115 | endif
|
---|
116 | kLdr_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
|
---|
117 | kLdr_SOURCES = \
|
---|
118 | kLdr.c \
|
---|
119 | kLdrDyld.c \
|
---|
120 | kLdrDyldFind.c \
|
---|
121 | kLdrDyldMod.c \
|
---|
122 | kLdrDyldOS.c \
|
---|
123 | kLdrDyLdSem.c \
|
---|
124 | kLdrMod.c \
|
---|
125 | kLdrModLX.c \
|
---|
126 | kLdrModMachO.c \
|
---|
127 | kLdrModNative.c \
|
---|
128 | kLdrModPE.c
|
---|
129 | kLdr_SOURCES.os2 = \
|
---|
130 | kLdr-os2.def \
|
---|
131 | kLdr-os2.c \
|
---|
132 | kLdrA-os2.asm
|
---|
133 | kLdr_SOURCES.win = \
|
---|
134 | kLdr-win.def \
|
---|
135 | kLdr-win.c
|
---|
136 | kLdr_LIBS += \
|
---|
137 | $(PATH_LIB)/kRdrStatic$(SUFF_LIB) \
|
---|
138 | $(PATH_LIB)/kCpuStatic$(SUFF_LIB) \
|
---|
139 | $(PATH_LIB)/kHlpBareStatic$(SUFF_LIB) \
|
---|
140 | $(PATH_LIB)/kErrStatic$(SUFF_LIB)
|
---|
141 |
|
---|
142 | #
|
---|
143 | # A static edition of kLdr.
|
---|
144 | #
|
---|
145 | LIBRARIES += kLdrStatic
|
---|
146 | kLdrStatic_TEMPLATE = kStuffLIB
|
---|
147 | kLdrStatic_SDKS.win = WINPSDK W2K3DDK
|
---|
148 | kLdrStatic_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
|
---|
149 | kLdrStatic_DEFS.darwin = __DARWIN__
|
---|
150 | kLdrStatic_DEFS.os2 = __OS2__
|
---|
151 | kLdrStatic_DEFS.win = __WIN__
|
---|
152 | kLdrStatic_SOURCES = $(kLdr_SOURCES)
|
---|
153 |
|
---|
154 | #
|
---|
155 | # The OS/2 stub program.
|
---|
156 | #
|
---|
157 | PROGRAMS.os2 = kLdrExeStub-os2
|
---|
158 | kLdrExeStub-os2_TOOL = GCC3OMF
|
---|
159 | kLdrExeStub-os2_ASTOOL = NASM
|
---|
160 | kLdrExeStub-os2_ASFLAGS = -f obj
|
---|
161 | #kLdrExeStub-os2_LDFLAGS = -nostdlib
|
---|
162 | kLdrExeStub-os2_LDFLAGS = -nostdlib -Zstack 64
|
---|
163 | kLdrExeStub-os2_LIBS = $(TARGET_kLdr)
|
---|
164 | #kLdrExeStub-os2_SOURCES = kLdrExeStub-os2.asm
|
---|
165 | kLdrExeStub-os2_SOURCES = kLdrExeStub-os2A.asm kLdrExeStub-os2.c
|
---|
166 |
|
---|
167 | #
|
---|
168 | # The Windows stub program.
|
---|
169 | #
|
---|
170 | PROGRAMS.win = kLdrExeStub-win
|
---|
171 | kLdrExeStub-win_TOOL.win.x86 = VCC70
|
---|
172 | kLdrExeStub-win_TOOL.win.amd64 = VCC80AMD64
|
---|
173 | kLdrExeStub-win_SDKS.x86 = WIN32SDK
|
---|
174 | kLdrExeStub-win_SDKS.amd64 = WIN64SDK
|
---|
175 | kLdrExeStub-win_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include
|
---|
176 | kLdrExeStub-win_DEFS = __WIN__
|
---|
177 | kLdrExeStub-win_CFLAGS = -W3 -Zl
|
---|
178 | kLdrExeStub-win_CFLAGS.debug = -Zi
|
---|
179 | kLdrExeStub-win_LDFLAGS = -Entry:WindowsMain -SubSystem:Console -FIXED:NO
|
---|
180 | kLdrExeStub-win_LIBS = $(TARGET_kLdr:.dll=.lib)
|
---|
181 | kLdrExeStub-win_SOURCES = kLdrExeStub-win.c
|
---|
182 |
|
---|
183 |
|
---|
184 | ##
|
---|
185 | ## The (stub) utility.
|
---|
186 | ##
|
---|
187 | #PROGRAMS = kLdrUtil
|
---|
188 |
|
---|
189 |
|
---|
190 | #
|
---|
191 | # Heap testcase.
|
---|
192 | #
|
---|
193 | #PROGRAMS += tstkLdrHeap
|
---|
194 | tstkLdrHeap_TEMPLATE = TST
|
---|
195 | tstkLdrHeap_SOURCES = \
|
---|
196 | tstkLdrHeap.c \
|
---|
197 | kHlp.c \
|
---|
198 | kHlpHeap.c \
|
---|
199 | kHlpMem.c \
|
---|
200 | kHlpPath.c \
|
---|
201 | kHlpSem.c \
|
---|
202 | kHlpStr.c \
|
---|
203 |
|
---|
204 | #
|
---|
205 | # Heap testcase.
|
---|
206 | #
|
---|
207 | PROGRAMS += tstkLdrMod
|
---|
208 | tstkLdrMod_TEMPLATE = TST
|
---|
209 | tstkLdrMod_SOURCES = \
|
---|
210 | tstkLdrMod.c
|
---|
211 | ifeq ($(BUILD_TARGET),win)
|
---|
212 | tstkLdrMod_LIBS = $(TARGET_kLdr:.dll=.lib)
|
---|
213 | else
|
---|
214 | tstkLdrMod_LIBS = $(TARGET_kLdr)
|
---|
215 | endif
|
---|
216 |
|
---|
217 |
|
---|
218 | # Generate rules.
|
---|
219 | include $(PATH_KBUILD)/subfooter.kmk
|
---|
220 |
|
---|