1 | # $Id: Makefile.kmk 2965 2007-02-13 21:04:40Z bird $# $Id: Makefile.kmk 2965 2007-02-13 21:04:40Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild Makefile for the kLdr.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2006 knut st. osmundsen <bird@anduin.net>
|
---|
7 | #
|
---|
8 | #
|
---|
9 | # This file is part of kLdr.
|
---|
10 | #
|
---|
11 | # kLdr is free software; you can redistribute it and/or modify
|
---|
12 | # it under the terms of the GNU General Public License as published by
|
---|
13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
14 | # (at your option) any later version.
|
---|
15 | #
|
---|
16 | # kLdr 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
|
---|
19 | # GNU General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU General Public License
|
---|
22 | # along with kLdr; if not, write to the Free Software
|
---|
23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | #
|
---|
25 | #
|
---|
26 |
|
---|
27 |
|
---|
28 | DEPTH = ..
|
---|
29 | include $(PATH_KBUILD)/header.kmk
|
---|
30 |
|
---|
31 | DEFAULT_PASSES := $(filter-out PACKING, $(DEFAULT_PASSES)) # annoying on windows.
|
---|
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 = .
|
---|
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 = .
|
---|
117 | kLdr_SOURCES = \
|
---|
118 | kLdr.c \
|
---|
119 | kLdrDyld.c \
|
---|
120 | kLdrDyldFind.c \
|
---|
121 | kLdrDyldMod.c \
|
---|
122 | kLdrDyldOS.c \
|
---|
123 | kLdrErr.c \
|
---|
124 | kLdrHlp.c \
|
---|
125 | kLdrHlpHeap.c \
|
---|
126 | kLdrHlpMem.c \
|
---|
127 | kLdrHlpPath.c \
|
---|
128 | kLdrHlpSem.c \
|
---|
129 | kLdrHlpStr.c \
|
---|
130 | kLdrMisc.c \
|
---|
131 | kLdrRdr.c \
|
---|
132 | kLdrRdrFile.c \
|
---|
133 | kLdrMod.c \
|
---|
134 | kLdrModLX.c \
|
---|
135 | kLdrModMachO.c \
|
---|
136 | kLdrModNative.c \
|
---|
137 | kLdrModPE.c
|
---|
138 | kLdr_SOURCES.os2 = \
|
---|
139 | kLdr-os2.def \
|
---|
140 | kLdr-os2.c \
|
---|
141 | kLdrHlp-gcc.c \
|
---|
142 | kLdrA-os2.asm
|
---|
143 | kLdr_SOURCES.win = \
|
---|
144 | kLdr-win.def \
|
---|
145 | kLdr-win.c
|
---|
146 |
|
---|
147 | kLdrErr.c_DEPS = $(PATH_TARGET)/kldrErrConsts.h
|
---|
148 | kLdrErr.c_INCS = $(PATH_TARGET)
|
---|
149 |
|
---|
150 | #
|
---|
151 | # The OS/2 stub program.
|
---|
152 | #
|
---|
153 | PROGRAMS.os2 = kLdrExeStub-os2
|
---|
154 | kLdrExeStub-os2_TOOL = GCC3OMF
|
---|
155 | kLdrExeStub-os2_ASTOOL = NASM
|
---|
156 | kLdrExeStub-os2_ASFLAGS = -f obj
|
---|
157 | #kLdrExeStub-os2_LDFLAGS = -nostdlib
|
---|
158 | kLdrExeStub-os2_LDFLAGS = -nostdlib -Zstack 64
|
---|
159 | kLdrExeStub-os2_LIBS = $(TARGET_kLdr)
|
---|
160 | #kLdrExeStub-os2_SOURCES = kLdrExeStub-os2.asm
|
---|
161 | kLdrExeStub-os2_SOURCES = kLdrExeStub-os2A.asm kLdrExeStub-os2.c
|
---|
162 |
|
---|
163 | #
|
---|
164 | # The Windows stub program.
|
---|
165 | #
|
---|
166 | PROGRAMS.win = kLdrExeStub-win
|
---|
167 | kLdrExeStub-win_TOOL.win.x86 = VCC70
|
---|
168 | kLdrExeStub-win_TOOL.win.amd64 = VCC80AMD64
|
---|
169 | kLdrExeStub-win_SDKS.x86 = WIN32SDK
|
---|
170 | kLdrExeStub-win_SDKS.amd64 = WIN64SDK
|
---|
171 | kLdrExeStub-win_INCS = .
|
---|
172 | kLdrExeStub-win_DEFS = __WIN__
|
---|
173 | kLdrExeStub-win_CFLAGS = -W3 -Zl
|
---|
174 | kLdrExeStub-win_CFLAGS.debug = -Zi
|
---|
175 | kLdrExeStub-win_LDFLAGS = -Entry:WindowsMain -SubSystem:Console -FIXED:NO
|
---|
176 | kLdrExeStub-win_LIBS = $(TARGET_kLdr:.dll=.lib)
|
---|
177 | kLdrExeStub-win_SOURCES = kLdrExeStub-win.c
|
---|
178 |
|
---|
179 |
|
---|
180 | ##
|
---|
181 | ## The (stub) utility.
|
---|
182 | ##
|
---|
183 | #PROGRAMS = kLdrUtil
|
---|
184 |
|
---|
185 |
|
---|
186 | #
|
---|
187 | # Heap testcase.
|
---|
188 | #
|
---|
189 | PROGRAMS += tstkLdrHeap
|
---|
190 | tstkLdrHeap_TEMPLATE = TST
|
---|
191 | tstkLdrHeap_SOURCES = \
|
---|
192 | tstkLdrHeap.c \
|
---|
193 | kLdrHlp.c \
|
---|
194 | kLdrHlpHeap.c \
|
---|
195 | kLdrHlpMem.c \
|
---|
196 | kLdrHlpPath.c \
|
---|
197 | kLdrHlpSem.c \
|
---|
198 | kLdrHlpStr.c \
|
---|
199 |
|
---|
200 | #
|
---|
201 | # Heap testcase.
|
---|
202 | #
|
---|
203 | PROGRAMS += tstkLdrMod
|
---|
204 | tstkLdrMod_TEMPLATE = TST
|
---|
205 | tstkLdrMod_SOURCES = \
|
---|
206 | tstkLdrMod.c
|
---|
207 | ifeq ($(BUILD_TARGET),win)
|
---|
208 | tstkLdrMod_LIBS = $(TARGET_kLdr:.dll=.lib)
|
---|
209 | else
|
---|
210 | tstkLdrMod_LIBS = $(TARGET_kLdr)
|
---|
211 | endif
|
---|
212 |
|
---|
213 |
|
---|
214 |
|
---|
215 | # Generate rules.
|
---|
216 | include $(PATH_KBUILD)/footer.kmk
|
---|
217 |
|
---|
218 |
|
---|
219 | #
|
---|
220 | # Generate case statements for kLdrErrStr().
|
---|
221 | #
|
---|
222 | $(PATH_TARGET)/kldrErrConsts.h: kLdr.h Makefile.kmk | $(call DIRDEP,$(PATH_TARGET))
|
---|
223 | $(RM) -f $@
|
---|
224 | $(SED) \
|
---|
225 | -e '/^#define *\(KLDR_ERR_[^ ()]*\) .*$$/!d' \
|
---|
226 | -e 's/^#define *\(KLDR_ERR_[^ ()]*\) .*$$/ERR_CONST(\1)/' \
|
---|
227 | -e '/KLDR_ERR_BASE/d' \
|
---|
228 | -e '/KLDR_ERR_[^_]*_BASE/d' \
|
---|
229 | kLdr.h > $@
|
---|
230 |
|
---|