-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.end
More file actions
140 lines (119 loc) · 4.85 KB
/
Makefile.end
File metadata and controls
140 lines (119 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# -*- makefile-bsdmake -*-
#
# Makefile.end - This should be included at the end of your Makefile
# (after Makefile.main)
#
# Copyright (C) 2025 Greg A. Woods - This work is licensed under the Creative
# Commons Attribution-ShareAlike 4.0 International License. To view a copy of
# the license, visit <URL:http://creativecommons.org/licenses/by-sa/4.0/>, or
# send a letter to: Creative Commons, PO Box 1866, Mountain View, CA 94042, USA
#
# The rest is just default boilerplate for stand-alone builds....
# XXX this is a very crude hack -- but the only real fix is probably to wait for
# everyone to pick up <auto.obj.mk> so this can just use MKOBJDIRS=auto...
#
bmake-test-obj: .PHONY bmake-do-obj
@if [ $$(pwd) = ${.CURDIR:Q} -a ! -z "${MAKEOBJDIRPREFIX}" -a ! -d "${MAKEOBJDIRPREFIX}" ]; then echo "You must create ${MAKEOBJDIRPREFIX} first!"; false; fi
# XXX because simple projects use <bsd.prog.mk> at a top level, we must have the
# ${.OBJDIR} present __BEFORE__ make is run since make will try to chdir(2) to
# ${.OBJDIR} before doing anything else, but if that doesn't exist then it will
# simply stay in ${.CURDIR} to run commands.... However we can have this depend
# on bmake-test-obj and thus that's dependency on bmake-do-obj will cause "obj"
# to be made and the user can just run "MAKEOBJDIRPREFIX=build make" again and
# everything will finally procede in the right ${.OBJDIR}.
#
# On FreeBSD (since 12?) if WITH_AUTO_OBJ=yes is set in the environment then the
# need to run an extra "make obj" step can be avoided.
#
bmake-test-obj-again: .PHONY bmake-test-obj
@if [ $$(pwd) = ${.CURDIR:Q} ]; then echo "Not yet working in ${MAKEOBJDIRPREFIX:U'objdir'}, try again!"; false; fi
.for targ in ${BUILDTARGETS:S/.WAIT//g}
${targ}: .PHONY ${targ:S/bmake-do-//}
.endfor
# most implementations do not make 'regress' depend on first building everything
# but we need to build everything before we can do any testing
#
regress: .PHONY all
# For stand-alone build & install we will also need to make the installation
# directories:
#
bmake_install_dirs += ${BINDIR}
bmake_install_dirs += ${INCSDIR}
bmake_install_dirs += ${LIBDIR}
bmake_install_dirs += ${PKGCONFIGDIR}
# the DEBUGDIR ones could/should maybe depend on MKDEBUGLIB
bmake_install_dirs += ${DEBUGDIR}
bmake_install_dirs += ${DEBUGDIR}/${PREFIX}/bin
bmake_install_dirs += ${DOCDIR}/${PACKAGE}
bmake_install_dirs += ${MANDIR}
bmake_install_dirs += ${MANDIR}/man1
# (in general though it is safest to always make them all)
beforeinstall: _bmake_install_dirs
# many BSD system mk files will not make directories on demand
_bmake_install_dirs: .PHONY
.for instdir in ${bmake_install_dirs}
${INSTALL} -d ${DESTDIR}${instdir}
.endfor
.if !target(docs)
docs: .PHONY
.endif
afterinstall: .PHONY install-docs
install-docs: .PHONY beforeinstall .WAIT docs
.for docfile in ${DOCS}
cp ${.CURDIR:Q}/${docfile} ${DESTDIR}${SHAREDIR}/doc/${PACKAGE}/
.endfor
-cp -R $(MAKEOBJDIRPREFIX:Q)/man ${DESTDIR}${SHAREDIR}/
#
# for NetBSD integration:
#
# XXX this is just the most common transformation needed....
SRCINSTDIR ?= ${BSDSRCDIR}/${BINDIR:S|/bin|usr.|g}
SRCUPDATEDIR ?= ${SRCINSTDIR}/${PACKAGE_NAME}
RCS_ID_EDITS = -E -e 's/\$$Name: ([^$$]*)\$$/\1/' \
-e 's/\$$Id: ([^$$]*)\$$/\1/'
${PACKAGE_NAME}-to-netbsd: .PHONY ${SRCS} ${HEADERS} ${DOCS} ${MAN} ${FILES} ${OTHER}
${INSTALL_DIR} ${SRCUPDATEDIR}
rm -f ${SRCUPDATEDIR}/Makefile
sed ${RCS_ID_EDITS} < Makefile.main > ${SRCUPDATEDIR}/Makefile
.for _file_ in ${SRCS} ${HEADERS} ${DOCS} ${MAN} ${FILES} ${OTHER}
rm -f ${SRCUPDATEDIR}/${_file_}
if [ ! -d $$(basename ${SRCUPDATEDIR}/${_file_}) ]; then \
mkdir -p $$(basename ${SRCUPDATEDIR}/${_file_}); \
fi
sed ${RCS_ID_EDITS} < ${_file_} > ${SRCUPDATEDIR}/${_file_}
chmod ${FILESMODE} ${SRCUPDATEDIR}/${_file_}
.endfor
TMPDIR ?= ${HOME}/tmp
TARBASE ?= ${PACKAGE_NAME}-${PACKAGE_VERSION}
${TARBASE}: .PHONY
pax -wvz -s '|^|$@/|' -f ${TMPDIR}/[email protected] *
tar: .PHONY ${TARBASE}
# finally include the compiler settings helpers
#
.include "${.CURDIR}/Makefile.compiler"
#
# "make help" support, inspired by Julio Merino
#
obj: # make object directories (set MAKEOBJDIRPREFIX in env!)
all: # make all targets
install:# install all targets
# n.b.: those are tabs after the backslashes, and for "column -s"
.PHONY: help
help: # Shows interactive help.
help: Makefile Makefile.main Makefile.inc Makefile.end
# @cat README.adoc
@echo
@echo "make variables:"
@echo
@sed -Ene 's/^([^# \ ]{1,})[ \ ]*\?=[^#]{1,}#[ \ ]*(.*)$$/\1:\ \2/p' $> | column -s ' ' -t | sort
@echo
@echo "make targets:"
@echo
@sed -Ene 's/^([^#: \ ]{1,}):.*#(.*)$$/\1:\ \2/p' $> | column -s ' ' -t | sort
@echo
#
# Local Variables:
# eval: (make-local-variable 'compile-command)
# compile-command: (concat "BUILD_DIR=build-$(uname -s)-$(uname -p); mkdir -p ${BUILD_DIR}; MAKEOBJDIRPREFIX=$(pwd -P)/${BUILD_DIR} " (default-value 'compile-command) " -j 8 LDSTATIC=-static obj depend all")
# End:
#