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