tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
cross-building dtrace from Mac OS X - echo vs. \n
Trying to cross-build -current with dtrace on OS X Snow Leopard fails.
src/external/cddl/osnet/lib/libdtrace/Makefile creates a dt_errtags.c file
that has (literally):
/*\n * Copyright 2003 Sun Microsystems, Inc. All rights reserved.\n * Use is subject
to license terms.\n */\n\n#pragma ident\t"%Z%%M%\t%I%\t%E% SMI"\n\n#include
<dt_errtags.h>
\nstatic const char *const _dt_errtags[] = {
...
The problem here is that
src/external/cddl/osnet/dist/lib/libdtrace/common/mkerrtags.sh tries to be
smart about "echo", but fails. On OS X, it runs plain "echo", but as Sonw
Leopard's echo apparently prints out "\n" literally, the above output
results. IIRC this was different with Mac OS X Leopard.
FWIW, "uname -s" here says "10.2.0".
A similar problem also exists with the mknames.sh script in the same dir,
and the resulting dt_names.c file.
What to do? Options that I see:
1) Make NetBSD's echo(1) or sh(1) (for its echo-builtin) a tool
2) Fix the mkerrtags.sh and mknames.sh to use e.g. printf(1)?
I understand this makes us diverge from the upstream...
3) Ignore
FWIW, A patch for #2 is appended below, which gets libdtrace built.
- Hubert
Index: mkerrtags.sh
===================================================================
RCS file:
/cvsroot/src/external/cddl/osnet/dist/lib/libdtrace/common/mkerrtags.sh,v
retrieving revision 1.4
diff -u -r1.4 mkerrtags.sh
--- mkerrtags.sh 5 Mar 2010 01:34:35 -0000 1.4
+++ mkerrtags.sh 28 Mar 2010 04:23:45 -0000
@@ -26,30 +26,25 @@
#
#ident "%Z%%M% %I% %E% SMI"
-if [[ $(uname) = "Darwin" ]]; then
- BSDECHO=
-else
- BSDECHO=-e
-fi
-
-echo ${BSDECHO} "\
+printf "\
/*\n\
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.\n\
* Use is subject to license terms.\n\
*/\n\
\n\
-#pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n\
+#pragma ident\t\"%%Z%%%%M%%\t%%I%%\t%%E%% SMI\"\n\
\n\
#include <dt_errtags.h>
\n\
-static const char *const _dt_errtags[] = {"
+static const char *const _dt_errtags[] = {
+"
pattern='^ \(D_[A-Z0-9_]*\),*'
replace=' "\1",'
sed -n "s/$pattern/$replace/p" || exit 1
-echo ${BSDECHO} "\
+printf "\
};\n\
\n\
static const int _dt_ntag = sizeof (_dt_errtags) / sizeof (_dt_errtags[0]);\n\
@@ -58,6 +53,7 @@
dt_errtag(dt_errtag_t tag)
{
return (_dt_errtags[(tag > 0 && tag < _dt_ntag) ? tag : 0]);
-}"
+}
+"
exit 0
Index: mknames.sh
===================================================================
RCS file:
/cvsroot/src/external/cddl/osnet/dist/lib/libdtrace/common/mknames.sh,v
retrieving revision 1.4
diff -u -r1.4 mknames.sh
--- mknames.sh 5 Mar 2010 01:34:35 -0000 1.4
+++ mknames.sh 28 Mar 2010 04:23:45 -0000
@@ -26,19 +26,13 @@
#
#ident "%Z%%M% %I% %E% SMI"
-if [[ $(uname) = "Darwin" ]]; then
- BSDECHO=
-else
- BSDECHO=-e
-fi
-
-echo ${BSDECHO} "\
+printf "\
/*\n\
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.\n\
* Use is subject to license terms.\n\
*/\n\
\n\
-#pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n\
+#pragma ident\t\"%%Z%%%%M%%\t%%I%%\t%%E%% SMI\"\n\
\n\
#include <dtrace.h>\n\
\n\
@@ -46,14 +40,16 @@
const char *\n\
dtrace_subrstr(dtrace_hdl_t *dtp, int subr)\n\
{\n\
- switch (subr) {"
+ switch (subr) {
+"
awk '
/^#define[ ]*DIF_SUBR_/ && $2 != "DIF_SUBR_MAX" {
printf("\tcase %s: return (\"%s\");\n", $2, tolower(substr($2, 10)));
}'
-echo ${BSDECHO} "\
+printf "\
default: return (\"unknown\");\n\
}\n\
-}"
+}
+"
Home |
Main Index |
Thread Index |
Old Index