| 1 | # $Id: Makefile.kmk 2967 2007-02-13 22:28:46Z bird $# $Id: Makefile.kmk 2967 2007-02-13 22:28:46Z 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 | # generate rules.
|
|---|
| 28 | DEPTH = ../..
|
|---|
| 29 | include $(PATH_KBUILD)/header.kmk
|
|---|
| 30 |
|
|---|
| 31 | DEFAULT_PASSES := $(filter-out PACKING, $(DEFAULT_PASSES))
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | #
|
|---|
| 35 | # Templates for the testcases.
|
|---|
| 36 | #
|
|---|
| 37 | TEMPLATE_TST = Testcase template
|
|---|
| 38 | ifeq ($(BUILD_TARGET),win)
|
|---|
| 39 | ifeq ($(BUILD_TARGET_ARCH),x86)
|
|---|
| 40 | TEMPLATE_TST_TOOL = VCC70
|
|---|
| 41 | TEMPLATE_TST_CFLAGS = -W3 -Zi -Zl -MD
|
|---|
| 42 | TEMPLATE_TST_CXXFLAGS = -W3 -Zi -Zl -MD
|
|---|
| 43 | TEMPLATE_TST_LIBS = \
|
|---|
| 44 | $(PATH_TOOL_VCC70_LIB)/oldnames.lib \
|
|---|
| 45 | $(PATH_TOOL_VCC70_LIB)/msvcrt.lib
|
|---|
| 46 | else
|
|---|
| 47 | TEMPLATE_TST_TOOL = VCC80AMD64
|
|---|
| 48 | TEMPLATE_TST_CFLAGS = -W3 -Zi -Zl -MD
|
|---|
| 49 | TEMPLATE_TST_CXXFLAGS = -W3 -Zi -Zl -MD
|
|---|
| 50 | TEMPLATE_TST_LIBS = \
|
|---|
| 51 | $(PATH_TOOL_VCC80AMD64_LIB)/oldnames.lib \
|
|---|
| 52 | $(PATH_TOOL_VCC80AMD64_LIB)/msvcrt.lib
|
|---|
| 53 | endif
|
|---|
| 54 | TEMPLATE_TST_CFLAGS.release = -O2
|
|---|
| 55 | TEMPLATE_TST_CXXFLAGS.release = -O2
|
|---|
| 56 | TEMPLATE_TST_ASFLAGS = -f win
|
|---|
| 57 | TEMPLATE_TST_DEFS = __WIN__
|
|---|
| 58 | TEMPLATE_TST_SDKS.x86 = WIN32SDK
|
|---|
| 59 | TEMPLATE_TST_SDKS.amd64 = WIN64SDK
|
|---|
| 60 |
|
|---|
| 61 | else
|
|---|
| 62 | TEMPLATE_TST_CFLAGS = -Wall -pedantic -g
|
|---|
| 63 | TEMPLATE_TST_CFLAGS.release = -O2
|
|---|
| 64 | TEMPLATE_TST_LDFLAGS =
|
|---|
| 65 | ifneq ($(filter os2,$(BUILD_TARGET)),)
|
|---|
| 66 | TEMPLATE_TST_TOOL = GCC3OMF
|
|---|
| 67 | TEMPLATE_TST_ASFLAGS = -f obj
|
|---|
| 68 | TEMPLATE_TST_LIBS = os2 gcc end
|
|---|
| 69 | else ifneq ($(filter darwin,$(BUILD_TARGET)),)
|
|---|
| 70 | TEMPLATE_TST_TOOL = GCC4MACHO
|
|---|
| 71 | TEMPLATE_TST_ASFLAGS = -f macho
|
|---|
| 72 | TEMPLATE_TST_DEFS = __DARWIN__
|
|---|
| 73 | TEMPLATE_TST_LIBS =
|
|---|
| 74 | else
|
|---|
| 75 | TEMPLATE_TST_TOOL = GCC3
|
|---|
| 76 | TEMPLATE_TST_ASFLAGS = -f elf
|
|---|
| 77 | TEMPLATE_TST_LIBS = gcc
|
|---|
| 78 | endif
|
|---|
| 79 | endif
|
|---|
| 80 | TEMPLATE_TST_INCS = . ..
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 | TEMPLATE_TSTPROG = Testcase program template
|
|---|
| 84 | TEMPLATE_TSTPROG_EXTENDS = TST
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | TEMPLATE_TSTDLL = Testcase dll template
|
|---|
| 88 | TEMPLATE_TSTDLL_EXTENDS = TST
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | TEMPLATE_TSTBARE = Bare bone testcase template
|
|---|
| 92 | ifeq ($(BUILD_TARGET),win)
|
|---|
| 93 | ifeq ($(BUILD_TARGET_ARCH),x86)
|
|---|
| 94 | TEMPLATE_TSTBARE_TOOL = VCC70
|
|---|
| 95 | else
|
|---|
| 96 | TEMPLATE_TSTBARE_TOOL = VCC80AMD64
|
|---|
| 97 | endif
|
|---|
| 98 | TEMPLATE_TSTBARE_CFLAGS = -W3 -Zi -Zl
|
|---|
| 99 | TEMPLATE_TSTBARE_CFLAGS.release = -O2
|
|---|
| 100 | TEMPLATE_TSTBARE_CXXFLAGS = -W3 -Zi -Zl
|
|---|
| 101 | TEMPLATE_TSTBARE_CXXFLAGS.release = -O2
|
|---|
| 102 | TEMPLATE_TSTBARE_ASFLAGS = -f win
|
|---|
| 103 | TEMPLATE_TSTBARE_DEFS = __WIN__
|
|---|
| 104 | TEMPLATE_TSTBARE_SDKS.x86 = WIN32SDK
|
|---|
| 105 | TEMPLATE_TSTBARE_SDKS.amd64 = WIN64SDK
|
|---|
| 106 |
|
|---|
| 107 | else
|
|---|
| 108 | TEMPLATE_TSTBARE_CFLAGS = -Wall -pedantic -g
|
|---|
| 109 | TEMPLATE_TSTBARE_CFLAGS.release = -O2
|
|---|
| 110 | TEMPLATE_TSTBARE_LDFLAGS = -nostdlib -lgcc
|
|---|
| 111 | ifeq ($(filter-out os2,$(BUILD_TARGET)),)
|
|---|
| 112 | TEMPLATE_TSTBARE_TOOL = GCC3OMF
|
|---|
| 113 | TEMPLATE_TSTBARE_ASFLAGS = -f obj
|
|---|
| 114 | TEMPLATE_TSTBARE_ASTOOL = NASM
|
|---|
| 115 | TEMPLATE_TSTBARE_DEFS = main=main_wrapped
|
|---|
| 116 | TEMPLATE_TSTBARE_LIBS = os2
|
|---|
| 117 | else ifeq ($(filter-out darwin,$(BUILD_TARGET)),)
|
|---|
| 118 | TEMPLATE_TSTBARE_TOOL = GCC4MACHO
|
|---|
| 119 | TEMPLATE_TSTBARE_ASFLAGS = -f macho
|
|---|
| 120 | TEMPLATE_TSTBARE_ASTOOL = NASM
|
|---|
| 121 | TEMPLATE_TSTBARE_DEFS = __DARWIN__
|
|---|
| 122 | TEMPLATE_TSTBARE_LIBS =
|
|---|
| 123 | TEMPLATE_TSTBARE_CFLAGS += -static -fno-common
|
|---|
| 124 | TEMPLATE_TSTBARE_LDFLAGS += -nostdlib -r
|
|---|
| 125 | else
|
|---|
| 126 | TEMPLATE_TSTBARE_TOOL = GCC3
|
|---|
| 127 | TEMPLATE_TSTBARE_ASFLAGS = -f elf
|
|---|
| 128 | TEMPLATE_TSTBARE_LIBS = gcc
|
|---|
| 129 | endif
|
|---|
| 130 | endif
|
|---|
| 131 | TEMPLATE_TSTBARE_INCS = . ..
|
|---|
| 132 |
|
|---|
| 133 | TEMPLATE_TSTBAREPROG = Bare bone testcase program template
|
|---|
| 134 | TEMPLATE_TSTBAREPROG_EXTENDS = TSTBARE
|
|---|
| 135 | ifneq ($(filter win win32 win64,$(BUILD_TARGET)),)
|
|---|
| 136 | TEMPLATE_TSTBAREPROG_LDFLAGS += -Entry:WindowsMain -FIXED:NO
|
|---|
| 137 | else
|
|---|
| 138 | TEMPLATE_TSTBAREPROG_LDFLAGS.nt += -FIXED:NO
|
|---|
| 139 | endif
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 | TEMPLATE_TSTBAREDLL = Bare bone testcase dll template
|
|---|
| 143 | TEMPLATE_TSTBAREDLL_EXTENDS = TSTBARE
|
|---|
| 144 | ifeq ($(BUILD_TARGET),win)
|
|---|
| 145 | TEMPLATE_TSTBAREDLL_LDFLAGS += -Entry:DllMain
|
|---|
| 146 | else ifeq ($(BUILD_TARGET),darwin)
|
|---|
| 147 | # TEMPLATE_TSTBAREDLL_CFLAGS += -dynamiclib
|
|---|
| 148 | # TEMPLATE_TSTBAREDLL_LDFLAGS += -dynamiclib
|
|---|
| 149 | endif
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 | #
|
|---|
| 155 | # tst-0: four dlls, three of which depends on the 4th and no external dependencies.
|
|---|
| 156 | # The purpose of this testcase is to debug the dynamic loader without
|
|---|
| 157 | # messing with the native loader at all.
|
|---|
| 158 | #
|
|---|
| 159 | PROGRAMS += tst-0 tst-0-driver
|
|---|
| 160 | DLLS += tst-0-a tst-0-b tst-0-c tst-0-d
|
|---|
| 161 |
|
|---|
| 162 | tst-0-driver_TEMPLATE = TSTPROG
|
|---|
| 163 | tst-0-driver_SOURCES = tst-0-driver.c
|
|---|
| 164 |
|
|---|
| 165 | tst-0-a_TEMPLATE = TSTBAREDLL
|
|---|
| 166 | tst-0-a_SOURCES = tst-0-a.c tstDllMainStub.c
|
|---|
| 167 | tst-0-a_SOURCES.os2= tstDllMainStub-os2.asm
|
|---|
| 168 |
|
|---|
| 169 | tst-0-b_TEMPLATE = TSTBAREDLL
|
|---|
| 170 | tst-0-b_SOURCES = tst-0-b.c tstDllMainStub.c
|
|---|
| 171 | tst-0-b_SOURCES.os2= tstDllMainStub-os2.asm
|
|---|
| 172 |
|
|---|
| 173 | tst-0-c_TEMPLATE = TSTBAREDLL
|
|---|
| 174 | tst-0-c_SOURCES = tst-0-c.c tstDllMainStub.c
|
|---|
| 175 | tst-0-c_SOURCES.os2= tstDllMainStub-os2.asm
|
|---|
| 176 |
|
|---|
| 177 | tst-0-d_TEMPLATE = TSTBAREDLL
|
|---|
| 178 | tst-0-d_SOURCES = tst-0-d.c tstDllMainStub.c
|
|---|
| 179 | tst-0-d_SOURCES.os2= tstDllMainStub-os2.asm
|
|---|
| 180 |
|
|---|
| 181 | tst-0_TEMPLATE = TSTBAREPROG
|
|---|
| 182 | tst-0_SOURCES = tst-0.c tstExeMainStub.c
|
|---|
| 183 | tst-0_SOURCES.os2= tstExeMainStub-os2.asm
|
|---|
| 184 |
|
|---|
| 185 | ifeq ($(BUILD_TARGET),win)
|
|---|
| 186 | tst-0-driver_LIBS= $(PATH_LIB)/kLdr.lib
|
|---|
| 187 | tst-0-a_LIBS = $(PATH_TARGET)/tst-0-d/tst-0-d.lib
|
|---|
| 188 | tst-0-b_LIBS = $(PATH_TARGET)/tst-0-d/tst-0-d.lib
|
|---|
| 189 | tst-0-c_LIBS = $(PATH_TARGET)/tst-0-d/tst-0-d.lib
|
|---|
| 190 | tst-0_LIBS = $(TARGET_tst-0-a:.dll=.lib) $(TARGET_tst-0-b:.dll=.lib) $(TARGET_tst-0-c:.dll=.lib)
|
|---|
| 191 | else
|
|---|
| 192 | tst-0-driver_LIBS= $(PATH_DLL)/kLdr$(SUFF_DLL)
|
|---|
| 193 | tst-0-a_LIBS = $(subst -a,-d,$(TARGET_tst-0-a))
|
|---|
| 194 | tst-0-b_LIBS = $(subst -b,-d,$(TARGET_tst-0-b))
|
|---|
| 195 | tst-0-c_LIBS = $(subst -c,-d,$(TARGET_tst-0-c))
|
|---|
| 196 | tst-0_LIBS = $(TARGET_tst-0-a) $(TARGET_tst-0-b) $(TARGET_tst-0-c)
|
|---|
| 197 | endif
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 | #
|
|---|
| 201 | # tst-1: four dlls, three of which depends on the 4th and the testcase depends on those three again.
|
|---|
| 202 | #
|
|---|
| 203 | PROGRAMS += tst-1
|
|---|
| 204 | DLLS += tst-1-a tst-1-b tst-1-c tst-1-d
|
|---|
| 205 |
|
|---|
| 206 | tst-1-a_TEMPLATE = TSTDLL
|
|---|
| 207 | tst-1-a_SOURCES = tst-1-a.c tstDllMain.c
|
|---|
| 208 |
|
|---|
| 209 | tst-1-b_TEMPLATE = TSTDLL
|
|---|
| 210 | tst-1-b_SOURCES = tst-1-b.c tstDllMain.c
|
|---|
| 211 |
|
|---|
| 212 | tst-1-c_TEMPLATE = TSTDLL
|
|---|
| 213 | tst-1-c_SOURCES = tst-1-c.c tstDllMain.c
|
|---|
| 214 |
|
|---|
| 215 | tst-1-d_TEMPLATE = TSTDLL
|
|---|
| 216 | tst-1-d_SOURCES = tst-1-d.c tstDllMain.c
|
|---|
| 217 |
|
|---|
| 218 | tst-1_TEMPLATE = TSTPROG
|
|---|
| 219 | tst-1_SOURCES = tst-1.c
|
|---|
| 220 |
|
|---|
| 221 | ifeq ($(BUILD_TARGET),win)
|
|---|
| 222 | tst-1-a_LIBS = $(PATH_TARGET)/tst-1-d/tst-1-d.lib
|
|---|
| 223 | tst-1-b_LIBS = $(PATH_TARGET)/tst-1-d/tst-1-d.lib
|
|---|
| 224 | tst-1-c_LIBS = $(PATH_TARGET)/tst-1-d/tst-1-d.lib
|
|---|
| 225 | tst-1_LIBS = $(TARGET_tst-1-a:.dll=.lib) $(TARGET_tst-1-b:.dll=.lib) $(TARGET_tst-1-c:.dll=.lib)
|
|---|
| 226 | else
|
|---|
| 227 | tst-1-a_LIBS = $(subst -a,-d,$(TARGET_tst-1-a))
|
|---|
| 228 | tst-1-b_LIBS = $(subst -b,-d,$(TARGET_tst-1-b))
|
|---|
| 229 | tst-1-c_LIBS = $(subst -c,-d,$(TARGET_tst-1-c))
|
|---|
| 230 | tst-1_LIBS = $(TARGET_tst-1-a) $(TARGET_tst-1-b) $(TARGET_tst-1-c)
|
|---|
| 231 | endif
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 | #
|
|---|
| 235 | # tst-2: four dlls, three of which depends on the 1st, and the testcase depends on those all of them.
|
|---|
| 236 | #
|
|---|
| 237 | PROGRAMS += tst-2
|
|---|
| 238 | DLLS += tst-2-a tst-2-b tst-2-c tst-2-d
|
|---|
| 239 |
|
|---|
| 240 | tst-2-a_TEMPLATE = TSTDLL
|
|---|
| 241 | tst-2-a_SOURCES = tst-2-a.c tstDllMain.c
|
|---|
| 242 |
|
|---|
| 243 | tst-2-b_TEMPLATE = TSTDLL
|
|---|
| 244 | tst-2-b_SOURCES = tst-2-b.c tstDllMain.c
|
|---|
| 245 |
|
|---|
| 246 | tst-2-c_TEMPLATE = TSTDLL
|
|---|
| 247 | tst-2-c_SOURCES = tst-2-c.c tstDllMain.c
|
|---|
| 248 |
|
|---|
| 249 | tst-2-d_TEMPLATE = TSTDLL
|
|---|
| 250 | tst-2-d_SOURCES = tst-2-d.c tstDllMain.c
|
|---|
| 251 |
|
|---|
| 252 | tst-2_TEMPLATE = TSTPROG
|
|---|
| 253 | tst-2_SOURCES = tst-2.c
|
|---|
| 254 |
|
|---|
| 255 | ifeq ($(BUILD_TARGET),win)
|
|---|
| 256 | tst-2-b_LIBS = $(PATH_TARGET)/tst-2-a/tst-2-a.lib
|
|---|
| 257 | tst-2-c_LIBS = $(PATH_TARGET)/tst-2-a/tst-2-a.lib
|
|---|
| 258 | tst-2-d_LIBS = $(PATH_TARGET)/tst-2-a/tst-2-a.lib
|
|---|
| 259 | tst-2_LIBS = $(TARGET_tst-2-b:.dll=.lib) $(TARGET_tst-2-c:.dll=.lib) $(TARGET_tst-2-d:.dll=.lib) $(TARGET_tst-2-a:.dll=.lib)
|
|---|
| 260 | else
|
|---|
| 261 | tst-2-b_LIBS = $(subst -b,-a,$(TARGET_tst-2-b))
|
|---|
| 262 | tst-2-c_LIBS = $(subst -c,-a,$(TARGET_tst-2-c))
|
|---|
| 263 | tst-2-d_LIBS = $(subst -d,-a,$(TARGET_tst-2-d))
|
|---|
| 264 | tst-2_LIBS = $(TARGET_tst-2-a) $(TARGET_tst-2-b) $(TARGET_tst-2-c) $(TARGET_tst-2-d)
|
|---|
| 265 | endif
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 | #
|
|---|
| 269 | # tst-3: Single module.
|
|---|
| 270 | #
|
|---|
| 271 | PROGRAMS += tst-3-driver
|
|---|
| 272 | ifeq ($(BUILD_TARGET),darwin)
|
|---|
| 273 | SYSMODS += tst-3
|
|---|
| 274 | else
|
|---|
| 275 | DLLS += tst-3
|
|---|
| 276 | LIBRARIES.win = tst-3-imp
|
|---|
| 277 | LIBRARIES.os2 = tst-3-imp
|
|---|
| 278 | endif
|
|---|
| 279 |
|
|---|
| 280 | tst-3_TEMPLATE = TSTBAREDLL
|
|---|
| 281 | tst-3_SOURCES = tst-3.c tst-3-ext.c tstDllMainStub.c
|
|---|
| 282 | tst-3_SOURCES.os2= tstDllMainStub-os2.asm
|
|---|
| 283 | tst-3_LIBS.os2 = $(TARGET_tst-3-imp)
|
|---|
| 284 | tst-3_LIBS.win = $(TARGET_tst-3-imp)
|
|---|
| 285 |
|
|---|
| 286 | tst-3-imp_TEMPLATE = TSTBAREDLL
|
|---|
| 287 | tst-3-imp_SOURCES.win = tst-3-imp-win.def
|
|---|
| 288 | tst-3-imp_SOURCES.os2 = tst-3-imp-os2.def
|
|---|
| 289 |
|
|---|
| 290 | tst-3-driver_TEMPLATE = TSTPROG
|
|---|
| 291 | tst-3-driver_SOURCES = tst-3-driver.c
|
|---|
| 292 |
|
|---|
| 293 | ifeq ($(BUILD_TARGET),win)
|
|---|
| 294 | tst-3-driver_LIBS = $(PATH_LIB)/kLdr.lib
|
|---|
| 295 | else
|
|---|
| 296 | tst-3-driver_LIBS = $(PATH_DLL)/kLdr$(SUFF_DLL)
|
|---|
| 297 | endif
|
|---|
| 298 |
|
|---|
| 299 |
|
|---|
| 300 | # generate rules.
|
|---|
| 301 | include $(PATH_KBUILD)/footer.kmk
|
|---|
| 302 |
|
|---|