1#	$NetBSD: Makefile.inc,v 1.5 2018/05/27 01:14:50 christos Exp $
2#
3#	Configuration variables (default values are below):
4#
5#	S	must be set to the top of the 'sys' tree.
6#	GNUEFIDST	may be set to the location of the directory where library
7#		objects are to be built.  Defaults to ${.OBJDIR}/lib/gnuefi.
8#	GNUEFI_AS	may be set to 'obj' to build a object from the library's
9#		object files.  (Otherwise, a library will be built.)
10#		Defaults to 'library'.
11#	GNUEFIMISCCPPFLAGS
12#		Miscellaneous cpp flags to be passed to the library's Makefile
13#		when building.
14#	GNUEFIMISCMAKEFLAGS
15#		Miscellaneous flags to be passed to the library's Makefile when
16#		building.  See library's Makefile for more details about
17#		supported flags and their default values.
18
19# Default values:
20GNUEFIDST?=		${.OBJDIR}/lib/gnuefi
21GNUEFI_AS?=		library
22GNUEFIDOTDIR?= ../../.
23
24CWARNFLAGS.clang+=	-Wno-format-extra-args
25
26GNUEFIDIR=		${S:S@^.@${GNUEFIDOTDIR}@:q}/lib/libgnuefi
27.if (${GNUEFI_AS} == "obj")
28GNUEFILIB=		${GNUEFIDST}/libgnuefi.o
29GNUEFILIB_PROF=	${GNUEFIDST}/libgnuefi.po
30.else
31GNUEFILIB=		${GNUEFIDST}/libgnuefi.a
32GNUEFILIB_PROF=	${GNUEFIDST}/libgnuefi_p.a
33.endif
34ZLIBSRCDIR:=	${.PARSEDIR}/../../../common/dist/zlib
35GNUEFIMISCCPPFLAGS+=-I${ZLIBSRCDIR}
36
37GNUEFIMAKE= \
38	cd ${GNUEFIDST} && ${MAKE} -f ${GNUEFIDIR:q}/Makefile \
39	    GNUEFIDIR=${GNUEFIDIR:q} \
40	    CC=${CC:q} CFLAGS=${CFLAGS:q} CPUFLAGS= \
41	    AS=${AS:q} AFLAGS=${AFLAGS:q} \
42	    LORDER=${LORDER:q} \
43	    TSORT=${TSORT:q} \
44	    LD=${LD:q} STRIP=${STRIP:q} \
45	    AR=${AR:q} NM=${NM:q} \
46	    RANLIB=${RANLIB:q} SIZE=${SIZE:q} \
47	    MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH:q} \
48	    GNUEFICPPFLAGS=${CPPFLAGS:S@^-I.@-I${GNUEFIDOTDIR}@g:q} \
49	    GNUEFIMISCCPPFLAGS=${GNUEFIMISCCPPFLAGS:q} \
50	    LIBGNUEFI_ARCH=${LIBGNUEFI_ARCH:q} \
51	    ${GNUEFIMISCMAKEFLAGS}
52
53${GNUEFILIB}:		.NOTMAIN .MAKE __always_make_gnuefilib
54	@echo making sure the gnuefi library is up to date...
55.if (${GNUEFI_AS} == "library")
56	@${GNUEFIMAKE} libgnuefi.a
57.else
58	@${GNUEFIMAKE} libgnuefi.o
59.endif
60
61${GNUEFILIB_PROF}:		.NOTMAIN .MAKE __always_make_gnuefilib
62	@echo making sure the profiled gnuefi library is up to date...
63.if (${GNUEFI_AS} == "library")
64	@${GNUEFIMAKE} libgnuefi_p.a
65.else
66	@${GNUEFIMAKE} libgnuefi.po
67.endif
68
69clean:			.NOTMAIN cleangnuefilib
70cleangnuefilib:		.NOTMAIN
71	@echo cleaning the gnuefi library objects
72	@if [ -d "${GNUEFIDST}" ]; then ${GNUEFIMAKE} clean; fi
73
74cleandir distclean:	.NOTMAIN cleandirgnuefilib
75cleandirgnuefilib:		.NOTMAIN
76	@echo cleandiring the gnuefi library objects
77	@if [ -d "${GNUEFIDST}" ]; then ${GNUEFIMAKE} cleandir; fi
78
79dependall depend:	.NOTMAIN dependgnuefilib
80dependgnuefilib:		.NOTMAIN .MAKE __always_make_gnuefilib
81	@echo depending the gnuefi library objects
82	@${GNUEFIMAKE} depend
83
84__always_make_gnuefilib:	.NOTMAIN
85	@mkdir -p ${GNUEFIDST}
86
87.PHONY: __always_make_gnuefilib
88.PHONY: cleangnuefilib cleandirgnuefilib dependgnuefilib
89