mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 03:08:31 +00:00
Make build hermetic without shell scripts
- Fix some minor issues in ar.com - Have execve() look for `ape` command - Rewrite NT paths using /c/ rather /??/c:/ - Replace broken GCC symlinks with .sym files - Rewrite $PATH environment variables on startup - Make $(APE_NO_MODIFY_SELF) the default bootloader - Add all build command dependencies to build/bootstrap - Get the repository mostly building from source on non-Linux
This commit is contained in:
parent
d44ff6ce1f
commit
d230a01222
160 changed files with 2754 additions and 1342 deletions
82
tool/build/mkdir.c
Normal file
82
tool/build/mkdir.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
|
||||
#define USAGE \
|
||||
" [-p] [-m MODE] DIR...\n\
|
||||
Utility for creating directories.\n\
|
||||
\n\
|
||||
FLAGS\n\
|
||||
\n\
|
||||
-h Help\n\
|
||||
-m MODE Octal mode\n\
|
||||
-p Make parent directories\n"
|
||||
|
||||
const char *prog;
|
||||
|
||||
wontreturn void PrintUsage(int rc, FILE *f) {
|
||||
fputs("Usage: ", f);
|
||||
fputs(prog, f);
|
||||
fputs(USAGE, f);
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i, mode = 0755;
|
||||
int (*mkdirp)(const char *, unsigned) = mkdir;
|
||||
prog = argc > 0 ? argv[0] : "mkdir.com";
|
||||
|
||||
while ((i = getopt(argc, argv, "?hpm:")) != -1) {
|
||||
switch (i) {
|
||||
case 'p':
|
||||
mkdirp = makedirs;
|
||||
break;
|
||||
case 'm':
|
||||
mode = strtol(optarg, 0, 8);
|
||||
break;
|
||||
case '?':
|
||||
case 'h':
|
||||
PrintUsage(0, stdout);
|
||||
default:
|
||||
PrintUsage(EX_USAGE, stderr);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc) {
|
||||
fputs(prog, stderr);
|
||||
fputs(": missing argument\n", stderr);
|
||||
fputs("Try '", stderr);
|
||||
fputs(prog, stderr);
|
||||
fputs(" -h' for more information.\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = optind; i < argc; ++i) {
|
||||
if (mkdirp(argv[i], mode) == -1) {
|
||||
fputs(prog, stderr);
|
||||
fputs(": cannot create directory '", stderr);
|
||||
fputs(argv[i], stderr);
|
||||
fputs("' ", stderr);
|
||||
fputs(strerdoc(errno), stderr);
|
||||
fputc('\n', stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue