annotate Makefile @ 912:f4f5132d5ac7

Stat cleanup. From the mailing list: Ok, first thing: clean up the help text. I realize what's there is copied verbatim from the man page, but that man page sucks. ("modification time" vs "change time"?) Took a bit of finagling to fit it in 80x24, but just made it. GLOBALS() indent was still tab, change to two spaces. And I tend to put a blank line between options lib/args.c automatically fills out and normal globals. We never do anything with date_stat_format() but immediately print it, might as well make the function do it. The types[] array in do_stat() is a rough edge. Hmmm... there's no else case that sets the type in case it was unknown (such as 0). In theory, this never happens. In practice it means I can cheat slightly, given this observation: $ find linux -name stat.h | xargs grep 'S_IF[A-Z]*[ \t]' linux/include/uapi/linux/stat.h:#define S_IFMT 00170000 linux/include/uapi/linux/stat.h:#define S_IFSOCK 0140000 linux/include/uapi/linux/stat.h:#define S_IFLNK 0120000 linux/include/uapi/linux/stat.h:#define S_IFREG 0100000 linux/include/uapi/linux/stat.h:#define S_IFBLK 0060000 linux/include/uapi/linux/stat.h:#define S_IFDIR 0040000 linux/include/uapi/linux/stat.h:#define S_IFCHR 0020000 linux/include/uapi/linux/stat.h:#define S_IFIFO 0010000 I.E. the only place the I_IFBLAH constants occur a stat.h header in current linux code is in the generic stuff, it doesn't vary per target. (The access permission bits are actually subtly standardized in posix due to the command line arguments to chmod, although I'm sure cygwin finds a way to break. But the type fields, not so much. But linux has to be binary compatible with itself foreverish, and that's all I really care about.) So, we have ALMOST have this going by twos, except there's no 8 and there is a 1. so let's make the 1 the default, feed a blank string into the 8... No, duh: octal. So it's actually 2, 4, 6, 8, 10, 12. So make the loop look like: filetype = statf->st_mode & S_IFMT; TT.ftname = types; for (i = 1; filetype != (i*8192) && i < 7; i++) TT.ftname += strlen(TT.ftname)+1; Yes that's linux-specific, and I think I'm ok with that. Printing all zeroes and pretending that's nanosecond resolution... either support it or don't. Let's see, supporting it is stat->st_atim.tv_nsec and similar... no mention of nanoseconds in strftime() (et tu, posix2008?) so pass it as a second argument and append it by hand... (Need to test that against musl...) When we hit an unknown type in print_it() we print the literal character, which is right for %% but what about an unknown option? $ stat -c %q / ? Eh, I guess that's a "don't care". It didn't die with an error, that's the important thing. I have a horrible idea for compressing the switch/case blocks, but should probably check this in and get some sleep for right now...
author Rob Landley <rob@landley.net>
date Tue, 28 May 2013 00:28:45 -0500
parents 2986aa63a021
children 0af2375a8ef8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
1 # Makefile for toybox.
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
2 # Copyright 2006 Rob Landley <rob@landley.net>
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
3
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
4 all: toybox
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
5
653
2986aa63a021 Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents: 603
diff changeset
6 toybox toybox_unstripped: .config *.[ch] lib/*.[ch] toys/*.h toys/*/*.c scripts/*.sh
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 232
diff changeset
7 scripts/make.sh
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 232
diff changeset
8
274
5b948171e495 Add uninstall and uninstall_flat.
Rob Landley <rob@landley.net>
parents: 273
diff changeset
9 .PHONY: clean distclean baseline bloatcheck install install_flat \
276
e711e375e9c6 Wow is make stupid. (Ahem, full of "magic, implicit rules". Which are stupid.)
Rob Landley <rob@landley.net>
parents: 275
diff changeset
10 uinstall uninstall_flat test tests help scripts/test
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
11
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
12 include kconfig/Makefile
1
59d58fab67c6 Next snapshot. Tries to grab something out of lib in order to build, I have
landley@driftwood
parents:
diff changeset
13
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 232
diff changeset
14 $(KCONFIG_TOP): generated/Config.in
653
2986aa63a021 Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents: 603
diff changeset
15 generated/Config.in: toys/*/*.c scripts/genconfig.sh
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 232
diff changeset
16 scripts/genconfig.sh
19
414625f97667 Better dependencies, and feed the linker --gc-sections. (Which is not an
Rob Landley <rob@landley.net>
parents: 14
diff changeset
17
484
4099d3026e56 Set HOSTCC only if it isn't already set as an environment variable.
Rob Landley <rob@landley.net>
parents: 429
diff changeset
18 HOSTCC?=cc
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
19
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
20 # Development targets
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
21 baseline: toybox_unstripped
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
22 @cp toybox_unstripped toybox_old
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
23
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
24 bloatcheck: toybox_old toybox_unstripped
492
f3169b2492f1 Replace GPL python debug script with BSD shell script.
Rob Landley <rob@landley.net>
parents: 484
diff changeset
25 @scripts/bloatcheck toybox_old toybox_unstripped
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
26
89
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
27 instlist: toybox
603
150a6d81bd02 Replace CCFLAGS with description of how to add flags to HOSTCC.
Rob Landley <rob@landley.net>
parents: 506
diff changeset
28 $(HOSTCC) -I . scripts/install.c -o instlist
89
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
29
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
30 install_flat: instlist
273
e589555d6416 Add install target, and make install_flat use scripts/install.sh
Rob Landley <rob@landley.net>
parents: 265
diff changeset
31 scripts/install.sh --symlink --force
e589555d6416 Add install target, and make install_flat use scripts/install.sh
Rob Landley <rob@landley.net>
parents: 265
diff changeset
32
e589555d6416 Add install target, and make install_flat use scripts/install.sh
Rob Landley <rob@landley.net>
parents: 265
diff changeset
33 install:
e589555d6416 Add install target, and make install_flat use scripts/install.sh
Rob Landley <rob@landley.net>
parents: 265
diff changeset
34 scripts/install.sh --long --symlink --force
89
4f5cdc6552da Add make install_flat.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
35
274
5b948171e495 Add uninstall and uninstall_flat.
Rob Landley <rob@landley.net>
parents: 273
diff changeset
36 uninstall_flat: instlist
5b948171e495 Add uninstall and uninstall_flat.
Rob Landley <rob@landley.net>
parents: 273
diff changeset
37 scripts/install.sh --uninstall
5b948171e495 Add uninstall and uninstall_flat.
Rob Landley <rob@landley.net>
parents: 273
diff changeset
38
5b948171e495 Add uninstall and uninstall_flat.
Rob Landley <rob@landley.net>
parents: 273
diff changeset
39 uninstall:
5b948171e495 Add uninstall and uninstall_flat.
Rob Landley <rob@landley.net>
parents: 273
diff changeset
40 scripts/install.sh --long --uninstall
5b948171e495 Add uninstall and uninstall_flat.
Rob Landley <rob@landley.net>
parents: 273
diff changeset
41
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
42 clean::
265
c7645fab8d73 Don't delete testdir after running test.sh. Add it to make clean instead.
Rob Landley <rob@landley.net>
parents: 260
diff changeset
43 rm -rf toybox toybox_unstripped generated/config.h generated/Config.in \
506
12c21dc8ad04 Now that generated/Config.probed is its own file, add it to build dependencies.
Rob Landley <rob@landley.net>
parents: 492
diff changeset
44 generated/newtoys.h generated/globals.h instlist testdir \
12c21dc8ad04 Now that generated/Config.probed is its own file, add it to build dependencies.
Rob Landley <rob@landley.net>
parents: 492
diff changeset
45 generated/Config.probed
14
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
46
f8e628f61f16 Make the config generate gen_config.h with CFG_ and USE() macros.
Rob Landley <rob@landley.net>
parents: 7
diff changeset
47 distclean: clean
232
cd4d5630c978 Move some generated files into the "generated" subdirectory.
Rob Landley <rob@landley.net>
parents: 196
diff changeset
48 rm -f toybox_old .config* generated/help.h
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
49
133
a459c6b39645 Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents: 123
diff changeset
50 test: tests
a459c6b39645 Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents: 123
diff changeset
51
a459c6b39645 Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents: 123
diff changeset
52 tests:
275
005af6006ce3 Update help, move test.sh to scripts, and fix "make test" to call right script.
Rob Landley <rob@landley.net>
parents: 274
diff changeset
53 scripts/test.sh
133
a459c6b39645 Fix makefile to defconfig properly, and leak in a bit of the new test
Rob Landley <rob@landley.net>
parents: 123
diff changeset
54
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
55 help::
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 232
diff changeset
56 @echo ' toybox - Build toybox.'
41
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
57 @echo ' baseline - Create busybox_old for use by bloatcheck.'
a43bdc6f53af Add bloat-o-meter, make bloatcheck, and scripts/showasm.
Rob Landley <rob@landley.net>
parents: 38
diff changeset
58 @echo ' bloatcheck - Report size differences between old and current versions'
233
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 232
diff changeset
59 @echo ' test - Run test suite against compiled commands.'
d4176f3f3835 Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents: 232
diff changeset
60 @echo ' clean - Delete temporary files.'
400
a5ceeeae7f43 Fix "make help".
Rob Landley <rob@landley.net>
parents: 349
diff changeset
61 @echo " distclean - Delete everything that isn't shipped."
a5ceeeae7f43 Fix "make help".
Rob Landley <rob@landley.net>
parents: 349
diff changeset
62 @echo ' install_flat - Install toybox into $$PREFIX directory.'
a5ceeeae7f43 Fix "make help".
Rob Landley <rob@landley.net>
parents: 349
diff changeset
63 @echo ' install - Install toybox into subdirectories of $$PREFIX.'
a5ceeeae7f43 Fix "make help".
Rob Landley <rob@landley.net>
parents: 349
diff changeset
64 @echo ' uninstall_flat - Remove toybox from $$PREFIX directory.'
a5ceeeae7f43 Fix "make help".
Rob Landley <rob@landley.net>
parents: 349
diff changeset
65 @echo ' uninstall - Remove toybox from subdirectories of $$PREFIX.'
429
27104029d771 Add a basic README and an example to "make help".
Rob Landley <rob@landley.net>
parents: 426
diff changeset
66 @echo ''
27104029d771 Add a basic README and an example to "make help".
Rob Landley <rob@landley.net>
parents: 426
diff changeset
67 @echo 'example: CFLAGS="--static" CROSS_COMPILE=armv5l- make defconfig toybox install'
27104029d771 Add a basic README and an example to "make help".
Rob Landley <rob@landley.net>
parents: 426
diff changeset
68 @echo ''