xref: /freebsd/stand/kshim/kshim.mk (revision eb69d1f144a6fcc765d1b9d44a5ae8082353e70b)
1#
2# $FreeBSD$
3#
4# Copyright (c) 2013 Hans Petter Selasky.
5# Copyright (c) 2014 SRI International
6# All rights reserved.
7#
8# This software was developed by SRI International and the University of
9# Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
10# ("CTSRD"), as part of the DARPA CRASH research programme.
11#
12# Redistribution and use in source and binary forms, with or without
13# modification, are permitted provided that the following conditions
14# are met:
15# 1. Redistributions of source code must retain the above copyright
16#    notice, this list of conditions and the following disclaimer.
17# 2. Redistributions in binary form must reproduce the above copyright
18#    notice, this list of conditions and the following disclaimer in the
19#    documentation and/or other materials provided with the distribution.
20#
21# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31# SUCH DAMAGE.
32#
33
34KSHIM_DIR:=	${.PARSEDIR}
35.PATH:		${KSHIM_DIR}
36
37CFLAGS+=	-I${KSHIM_DIR}
38CFLAGS+=	-I${KSHIM_DIR}/../..
39CFLAGS+=	-DUSB_GLOBAL_INCLUDE_FILE=\"bsd_global.h\"
40CFLAGS+=	-DHAVE_ENDIAN_DEFS
41
42#
43# Single threaded BSD kernel
44#
45KSRCS+=	bsd_kernel.c
46
47#
48# BUSSPACE implementation
49#
50KSRCS+=	bsd_busspace.c
51
52SRCS+=	sysinit_data.c
53SRCS+=	sysuninit_data.c
54
55CLEANFILES+= sysinit.bin
56CLEANFILES+= sysinit_data.c
57CLEANFILES+= sysuninit_data.c
58
59SRCS+=	${KSRCS}
60SYSINIT_OBJS=	${KSRCS:R:C/$/.osys/}
61CLEANFILES+=	${SYSINIT_OBJS}
62
63#
64# SYSINIT() and SYSUNINIT() handling
65#
66
67sysinit_data.c: sysinit.bin
68	sysinit -i sysinit.bin -o ${.TARGET} -k sysinit -s sysinit_data
69
70sysuninit_data.c: sysinit.bin
71	sysinit -i sysinit.bin -o ${.TARGET} -R -k sysuninit -s sysuninit_data
72
73.for KSRC in ${KSRCS:R}
74${KSRC}.osys: ${KSRC}.o
75	${OBJCOPY} -j ".debug.sysinit" -O binary ${KSRC}.o ${KSRC}.osys
76.endfor
77
78sysinit.bin: ${SYSINIT_OBJS}
79	cat ${.ALLSRC} > sysinit.bin
80