1 # $Id: prog.mk,v 1.32 2017/05/06 17:30:09 sjg Exp $
3 .if
!target
(__
${.PARSEFILE
}__
)
8 # FreeBSD at least expects MAN8 etc.
9 .if defined
(MAN
) && !empty
(MAN
)
14 .SUFFIXES
: .out .o .c .
cc .C .y .l .s
.8 .7 .6 .5 .4 .3 .2 .1 .0
18 .if
${MACHINE_ARCH} == "sparc64"
19 CFLAGS
+= -mcmodel
=medlow
22 # ELF platforms depend on crtbegin.o and crtend.o
23 .if
${OBJECT_FMT} == "ELF"
25 LIBCRTBEGIN
= ${DESTDIR}/usr
/lib
/crti.o
29 LIBCRTEND
= ${DESTDIR}/usr
/lib
/crtn.o
32 _SHLINKER
= ${SHLINKDIR}/ld.elf_so
36 _SHLINKER
= ${SHLINKDIR}/ld.so
40 LIBCRT0
= ${DESTDIR}/usr
/lib
/crt1.o
44 # here is where you can define what LIB* are
45 .
-include <libnames.mk
>
46 .if
${MK_DPADD_MK} == "yes"
47 # lots of cool magic, but might not suit everyone.
51 .if
${MK_GPROF} == "yes"
52 CFLAGS
+= ${CC_PG} ${PROFFLAGS}
54 .if
${MK_DPADD_MK} == "no"
56 LDADD_LAST
+= ${LDADD_LIBC_P}
60 .if defined
(SHAREDSTRINGS
)
63 ${CC} -E
${CFLAGS} ${.IMPSRC
} | xstr
-c
-
64 @
${CC} ${CFLAGS} -c x.c
-o
${.TARGET
}
67 ${CXX_SUFFIXES
:%=%.o
}:
68 ${CXX} -E
${CXXFLAGS} ${.IMPSRC
} | xstr
-c
-
70 @
${CXX} ${CXXFLAGS} -c x.
cc -o
${.TARGET
}
76 BINDIR ?
= ${prefix}/bin
79 .for s in
${SRCS
:N
*.h
:N
*.sh
:M
*/*}
80 ${.o .po .lo
:L
:@o@
${s
:T
:R
}$o@
}: $s
82 .if
!empty
(SRCS
:N
*.h
:N
*.sh
)
83 OBJS
+= ${SRCS
:T
:N
*.h
:N
*.sh
:R
:S
/$/.o
/g
}
84 LOBJS
+= ${LSRCS
:.c
=.ln
} ${SRCS
:M
*.c
:.c
=.ln
}
87 .if defined
(OBJS
) && !empty
(OBJS
)
88 .NOPATH
: ${OBJS} ${PROG} ${SRCS
:M
*.
[ly
]:C
/\..
$/.c
/} ${YHEADER
:D
${SRCS
:M
*.y
:.y
=.h
}}
90 # this is known to work for NetBSD 1.6 and FreeBSD 4.2
91 .if
${TARGET_OSNAME} == "NetBSD" ||
${TARGET_OSNAME} == "FreeBSD"
93 .if
${SHLINKDIR} != "/usr/libexec" # XXX: change or remove if ld.so moves
94 _PROGLDOPTS
+= -Wl
,-dynamic-linker
=${_SHLINKER}
96 .if defined
(LIBDIR
) && ${SHLIBDIR} != ${LIBDIR}
97 _PROGLDOPTS
+= -Wl
,-rpath-link
,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr
/lib \
98 -L
${DESTDIR}${SHLIBDIR}
100 _PROGLDOPTS
+= -Wl
,-rpath
,${SHLIBDIR}:/usr
/lib
102 .if defined
(PROG_CXX
)
104 _SUPCXX
= -lstdc
++ -lm
110 .if defined
(DESTDIR
) && exists
(${LIBCRT0}) && ${LIBCRT0} != "/dev/null"
112 ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
113 ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o
${.TARGET
} -nostdlib
${_PROGLDOPTS} -L
${DESTDIR}/usr
/lib
${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L
${DESTDIR}/usr
/lib
${_SUPCXX} -lgcc
-lc
-lgcc
${LIBCRTEND}
117 ${PROG}: ${OBJS} ${LIBC} ${DPADD}
118 ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o
${.TARGET
} ${_PROGLDOPTS} ${OBJS} ${LDADD}
120 .
endif # defined(DESTDIR)
121 .
endif # defined(OBJS) && !empty(OBJS)
125 .
endif # !defined(MAN)
126 .
endif # defined(PROG)
128 .if
!defined
(_SKIP_BUILD
)
136 rm -f a.out
[Ee
]rrs mklog core
*.core \
137 ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES}
139 clean: _SUBDIRUSE cleanprog
140 cleandir
: _SUBDIRUSE cleanprog
142 cleandir
: _SUBDIRUSE
clean
145 .if defined
(SRCS
) && (!defined
(MKDEP
) ||
${MKDEP} != autodep
)
147 @
(TMP
=/tmp
/_depend
$$$$; \
148 sed
-e
's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
154 .if
!target
(beforeinstall
)
157 .if
!target
(afterinstall
)
162 PROG_INSTALL_OWN ?
= -o
${BINOWN} -g
${BINGRP}
165 .if
!target
(realinstall
)
166 realinstall
: proginstall
168 .if
!target
(proginstall
)
171 ${INSTALL} -d
${PROG_INSTALL_OWN} -m
755 ${DESTDIR}${BINDIR}
172 ${INSTALL} ${COPY} ${STRIP_FLAG} ${PROG_INSTALL_OWN} -m
${BINMODE} \
173 ${PROG} ${DESTDIR}${BINDIR}/${PROG_NAME}
175 .if defined
(HIDEGAME
)
176 (cd
${DESTDIR}/usr
/games
; rm -f
${PROG}; ln
-s dm
${PROG})
182 install: maninstall install_links _SUBDIRUSE
186 @set
${SYMLINKS}; ${_SYMLINKS_SCRIPT}
189 @set
${LINKS}; ${_LINKS_SCRIPT}
192 maninstall
: afterinstall
193 afterinstall
: realinstall
194 install_links
: realinstall
195 proginstall
: beforeinstall
196 realinstall
: beforeinstall
200 .if defined
(OBJS
) && !empty
(OBJS
)
204 .if defined
(FILES
) || defined
(FILESGROUPS
)
208 .if
${MK_MAN} != "no"
212 .if
${MK_NLS} != "no"
216 BUILDAFTER
+= ${PROG} ${OBJS}
222 .if
!empty
(PROG
) && ${MK_STAGING_PROG} == "yes"
223 STAGE_BINDIR ?
= ${STAGE_OBJTOP}${BINDIR}
224 STAGE_DIR.prog ?
= ${STAGE_BINDIR}
225 .if
${PROG_NAME
:U
${PROG}} != ${PROG}
226 STAGE_AS_SETS
+= prog
227 STAGE_AS_
${PROG} = ${PROG_NAME}
228 stage_as.prog
: ${PROG}
231 stage_files.prog
: ${PROG}