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