Merge from vendor branch WPA_SUPPLICANT:
[dragonfly.git] / share / mk / bsd.hostprog.mk
1 # $DragonFly: src/share/mk/bsd.hostprog.mk,v 1.6 2004/07/21 13:34:27 joerg 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)
8 PROG=   ${PROG_CXX}
9 .endif
10
11 .if !defined(SRCS)
12 .if defined(PROG_CXX)
13 SRCS=   ${PROG}.cc
14 .else
15 SRCS=   ${PROG}.c
16 .endif
17 .endif
18
19 all: 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} != ""
25 OBJCLIBS?= -lobjc
26 LDADD+= ${OBJCLIBS}
27 .endif
28
29 OBJS+=  ${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/}
32 OBJS:=  ${OBJS:N${_OBJ}} ${_OBJ}
33 .endfor
34 .endfor
35
36 ${PROG}.nx: ${OBJS}
37 .if defined(PROG_CXX)
38         ${NXCXX} ${NXCXXFLAGS} ${NXLDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
39 .else
40         ${NXCC} ${NXCFLAGS} ${NXLDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
41 .endif
42 .endif
43
44 CLEANFILES+= ${PROG}.nx ${OBJS}
45
46 all: ${PROG}.nx
47
48 # header files are often generated by .nx binaries.  All .nx binaries must
49 # be built in the depend stage so the related header files can be generated
50 #
51 _EXTRADEPEND: all
52         echo ${PROG}.nx: ${LIBC} ${DPADD} >> ${DEPENDFILE}
53 .if defined(PROG_CXX)
54         echo ${PROG}.nx: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
55 .endif
56
57 .include <bsd.dep.mk>
58
59 .if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE})
60 ${OBJS}: ${SRCS:M*.h}
61 .endif
62
63 .include <bsd.obj.mk>
64
65 .include <bsd.sys.mk>