aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-02-10 23:27:55 -0600
committerRob Landley <rob@landley.net>2016-02-10 23:27:55 -0600
commitdf07fb73be98dc1087346c184877666970a88f4a (patch)
tree32771caccb0008ccced29c99dbeeab0cef88f5ec
parent187649de817b618c967d234f0707008e90e52504 (diff)
downloadtoybox-df07fb73be98dc1087346c184877666970a88f4a.tar.gz
Wean scripts/install.c off toys.h so cross compiling less brittle.
-rw-r--r--Makefile2
-rw-r--r--configure1
-rw-r--r--lib/lsm.h4
-rw-r--r--lib/toyflags.h27
-rw-r--r--scripts/install.c16
-rw-r--r--toys.h23
6 files changed, 36 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index 92176a2b..39d44fcf 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ install_flat:
install:
scripts/install.sh --long --symlink --force
-uninstall_flat: generated/instlist
+uninstall_flat:
scripts/install.sh --uninstall
uninstall:
diff --git a/configure b/configure
index ff1aaf24..7b10f6e5 100644
--- a/configure
+++ b/configure
@@ -23,4 +23,3 @@ CFLAGS="$CFLAGS -funsigned-char"
# If HOSTCC needs CFLAGS or LDFLAGS, just add them to the variable
# ala HOSTCC="blah-cc --static"
[ -z "$HOSTCC" ] && HOSTCC=cc
-HOSTCC="$HOSTCC -DBUILD_FOR_HOST"
diff --git a/lib/lsm.h b/lib/lsm.h
index aacabe08..d7e7de9c 100644
--- a/lib/lsm.h
+++ b/lib/lsm.h
@@ -3,8 +3,6 @@
* Copyright 2015 Rob Landley <rob@landley.net>
*/
-#ifndef BUILD_FOR_HOST
-
#if CFG_TOYBOX_SELINUX
#include <selinux/selinux.h>
#else
@@ -115,5 +113,3 @@ static inline int lsm_fget_context(int file, char **context)
return smack_new_label_from_file(file, XATTR_NAME_SMACK, context);
return fgetfilecon(file, context);
}
-
-#endif // BUILD_FOR_HOST
diff --git a/lib/toyflags.h b/lib/toyflags.h
new file mode 100644
index 00000000..963295cc
--- /dev/null
+++ b/lib/toyflags.h
@@ -0,0 +1,27 @@
+/* Flags values for the third argument of NEWTOY()
+ *
+ * Included from both main.c (runs in toys.h context) and scripts/install.c
+ * (which may build on crazy things like macosx when cross compiling).
+ */
+
+// Flags describing command behavior.
+
+#define TOYFLAG_USR (1<<0)
+#define TOYFLAG_BIN (1<<1)
+#define TOYFLAG_SBIN (1<<2)
+#define TOYMASK_LOCATION ((1<<4)-1)
+
+// This is a shell built-in function, running in the same process context.
+#define TOYFLAG_NOFORK (1<<4)
+
+// Start command with a umask of 0 (saves old umask in this.old_umask)
+#define TOYFLAG_UMASK (1<<5)
+
+// This command runs as root.
+#define TOYFLAG_STAYROOT (1<<6)
+#define TOYFLAG_NEEDROOT (1<<7)
+#define TOYFLAG_ROOTONLY (TOYFLAG_STAYROOT|TOYFLAG_NEEDROOT)
+
+// Call setlocale to listen to environment variables.
+// This invalidates sprintf("%.*s", size, string) as a valid length constraint.
+#define TOYFLAG_LOCALE (1<<8)
diff --git a/scripts/install.c b/scripts/install.c
index a9a05500..3ffb867d 100644
--- a/scripts/install.c
+++ b/scripts/install.c
@@ -3,28 +3,26 @@
* Copyright 2006 Rob Landley <rob@landley.net>
*/
-#include "toys.h"
+#include <stdio.h>
+#include "generated/config.h"
+#include "lib/toyflags.h"
-#undef NEWTOY
-#undef OLDTOY
-#define NEWTOY(name, opts, flags) {#name, 0, 0, flags},
-#define OLDTOY(name, oldname, flags) {#name, 0, 0, flags},
+#define NEWTOY(name, opts, flags) {#name, flags},
+#define OLDTOY(name, oldname, flags) {#name, flags},
// Populate toy_list[].
-struct toy_list toy_list[] = {
+struct {char *name; int flags;} toy_list[] = {
#include "generated/newtoys.h"
};
-#define TOY_LIST_LEN (sizeof(toy_list)/sizeof(struct toy_list))
-
int main(int argc, char *argv[])
{
static char *toy_paths[]={"usr/","bin/","sbin/",0};
int i, len = 0;
// Output list of applets.
- for (i=1; i<TOY_LIST_LEN; i++) {
+ for (i=1; i<sizeof(toy_list)/sizeof(*toy_list); i++) {
int fl = toy_list[i].flags;
if (fl & TOYMASK_LOCATION) {
if (argc>1) {
diff --git a/toys.h b/toys.h
index 4bfccb15..8a29730b 100644
--- a/toys.h
+++ b/toys.h
@@ -69,6 +69,7 @@
#include "lib/lib.h"
#include "lib/lsm.h"
+#include "lib/toyflags.h"
#include "toys/e2fs.h"
// Get list of function prototypes for all enabled command_main() functions.
@@ -86,28 +87,6 @@ struct toy_list *toy_find(char *name);
void toy_init(struct toy_list *which, char *argv[]);
void toy_exec(char *argv[]);
-// Flags describing command behavior.
-
-#define TOYFLAG_USR (1<<0)
-#define TOYFLAG_BIN (1<<1)
-#define TOYFLAG_SBIN (1<<2)
-#define TOYMASK_LOCATION ((1<<4)-1)
-
-// This is a shell built-in function, running in the same process context.
-#define TOYFLAG_NOFORK (1<<4)
-
-// Start command with a umask of 0 (saves old umask in this.old_umask)
-#define TOYFLAG_UMASK (1<<5)
-
-// This command runs as root.
-#define TOYFLAG_STAYROOT (1<<6)
-#define TOYFLAG_NEEDROOT (1<<7)
-#define TOYFLAG_ROOTONLY (TOYFLAG_STAYROOT|TOYFLAG_NEEDROOT)
-
-// Call setlocale to listen to environment variables.
-// This invalidates sprintf("%.*s", size, string) as a valid length constraint.
-#define TOYFLAG_LOCALE (1<<8)
-
// Array of available commands
extern struct toy_list {