xref: /netbsd/sys/lib/libkern/Makefile (revision bf9ec67e)
1#	$NetBSD: Makefile,v 1.64 2002/05/28 10:09:24 itojun Exp $
2
3LIB=	kern
4NOPIC=	# defined
5
6.include <bsd.own.mk>
7
8.if defined(MACHINE_ARCH) && !empty(MACHINE_ARCH) && \
9    exists(${KERNDIR}/arch/${MACHINE_ARCH})
10ARCHSUBDIR=     ${MACHINE_ARCH}
11.elif defined(MACHINE_CPU) && !empty(MACHINE_CPU) && \
12    exists(${KERNDIR}/arch/${MACHINE_CPU})
13ARCHSUBDIR=     ${MACHINE_CPU}
14.else
15.BEGIN:
16	@echo no ARCHSUBDIR for ${MACHINE_ARCH} nor ${MACHINE_CPU}
17	@false
18.endif
19
20M= ${KERNDIR}/arch/${ARCHSUBDIR}
21
22CPPFLAGS=	-I$M ${KERNCPPFLAGS} ${KERNMISCCPPFLAGS}
23
24.PATH.c: ${KERNDIR}
25.if exists ($M/Makefile.inc)
26.PATH.c: $M
27.PATH.S: $M
28.include "$M/Makefile.inc"
29.endif
30
31.if (${MACHINE_ARCH} != "alpha")
32# Quad support
33SRCS+=	adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
34	lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
35	subdi3.c  ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
36.endif
37
38# Other stuff
39SRCS+=	__cmsg_alignbytes.c inet_addr.c intoa.c md4c.c md5c.c sha1.c pmatch.c
40SRCS+=	_que.c arc4random.c
41
42# Files to clean up
43CLEANFILES+= lib${LIB}.o lib${LIB}.po
44
45#
46# Special rules for certain objects
47#
48
49# mcount cannot be compiled with profiling
50mcount.po: mcount.o
51	cp mcount.o mcount.po
52
53# XXX these stub builds should be cleaned up even further.
54
55# if no machine specific memcpy(3), build one out of bcopy(3) based stub.
56.if empty(SRCS:Mmemcpy.S)
57SRCS+=	memcpy.c
58.endif
59
60# if no machine specific memmove(3), build one out of bcopy(3) based stub.
61.if empty(SRCS:Mmemmove.S)
62SRCS+=	memmove.c
63.endif
64
65# if no machine specific strchr(3), build one out of index(3) based stub.
66.if empty(SRCS:Mstrchr.S)
67SRCS+=	strchr.c
68.endif
69
70# if no machine specific strrchr(3), build one out of rindex(3) based stub.
71.if empty(SRCS:Mstrrchr.S)
72SRCS+=	strrchr.c
73.endif
74
75POBJS+=	mcount.po
76
77# only needed during build
78libinstall::
79
80.undef DESTDIR
81.include <bsd.lib.mk>
82
83lib${LIB}.o:: ${OBJS}
84	@echo building standard ${LIB} library
85	@rm -f lib${LIB}.o
86	@${LD} -r -o lib${LIB}.o `NM=${NM} ${LORDER} ${OBJS} | ${TSORT}`
87
88lib${LIB}.po:: ${POBJS}
89	@echo building profiled ${LIB} library
90	@rm -f lib${LIB}.po
91	@${LD} -r -o lib${LIB}.po `NM=${NM} ${LORDER} ${POBJS} | ${TSORT}`
92