xref: /dragonfly/share/mk/bsd.hostprog.mk (revision 19fe1c42)
1# $DragonFly: src/share/mk/bsd.hostprog.mk,v 1.8 2008/05/19 10:26:02 corecode Exp $
2
3.include <bsd.init.mk>
4
5.SUFFIXES: .out .nx .no .c .cc .cpp .cxx .C .m .y .l .s .S
6
7.if defined(PROG_CXX)
8PROG=	${PROG_CXX}
9.endif
10
11.if !defined(SRCS)
12.if defined(PROG_CXX)
13SRCS=	${PROG}.cc
14.else
15SRCS=	${PROG}.c
16.endif
17.endif
18
19all: objwarn ${PROG}.nx
20
21.if defined(PROG)
22
23# If there are Objective C sources, link with Objective C libraries.
24.if ${SRCS:M*.m} != ""
25OBJCLIBS?= -lobjc
26LDADD+=	${OBJCLIBS}
27.endif
28
29OBJS+=  ${SRCS:N*.h:N*.patch:R:S/$/.no/g}
30.for _PATCH in ${SRCS:T:N*.h.patch:M*.patch}
31.for _OBJ in ${_PATCH:R:R:S/$/.no/}
32OBJS:=	${OBJS:N${_OBJ}} ${_OBJ}
33.endfor
34.endfor
35
36${PROG}.nx: ${OBJS}
37.if defined(PROG_CXX)
38	${NXCXX_LINK} ${NXCXXFLAGS} ${NXLDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
39.else
40	${NXCC_LINK} ${NXCFLAGS} ${NXLDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
41.endif
42.endif
43
44CLEANFILES+= ${PROG}.nx ${OBJS}
45
46all: ${PROG}.nx
47
48_EXTRADEPEND:
49	sed -i '' -Ee 's/^([^.]+)\.o:/\1.no:/' ${DEPENDFILE}
50	echo ${PROG}.nx: ${LIBC} ${DPADD} >> ${DEPENDFILE}
51.if defined(PROG_CXX)
52	echo ${PROG}.nx: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
53.endif
54
55# header files are often generated by .nx binaries.  All .nx binaries must
56# be built in the depend stage so the related header files can be generated
57#
58afterdepend: all
59
60.include <bsd.dep.mk>
61
62.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
63${OBJS}: ${SRCS:M*.h}
64.endif
65
66.include <bsd.obj.mk>
67
68.include <bsd.sys.mk>
69