-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
52 lines (37 loc) · 1.35 KB
/
Makefile
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
CC = gcc
CFLAGS = -Oz -flto -g -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-unused-result -Iinclude -DVERSION=\"$(VERSION)\"
LDFLAGS = -flto
EXEC = minibox_unstripped
PROGS = wc cp cat sync yes update sleep whoami true false ls echo init cmp rm \
rmdir mkdir mknod hostname free xxd od hexdump w vmstat cut grep tr sort uniq \
uptime ps kill tty link unlink nohup dirname basename cal clear env expand \
unexpand fold factor touch head tail paste arch date
SRCS = $(addprefix src/, $(PROGS:=.c)) src/help.c src/minibox.c
OBJS = $(SRCS:.c=.o)
VERSION=0.3.1
all: subdir_all $(EXEC) strip
subdir_all:
$(MAKE) -C libmb
$(EXEC): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
strip: $(EXEC)
# Lets reduce the executable size even more by removing useless sections
$@ -s -R .note -R .comment -R .symtab -R.strtab $^ -o minibox
ls -l minibox
size minibox
tags:
ls src/*.c | xargs ctags -a
dist:
tar czvf ../minibox-${VERSION}.tar.gz --exclude='.git' \
--exclude='.gitignore' ../minibox
links:
@for i in ${PROGS}; do \
ln -s minibox $$i > /dev/null 2>&1; done
clean:
rm -rf minibox $(EXEC) $(OBJS) tags install_dir
distclean: clean
rm -f include/config.h compile_commands.json
./scripts/toggle_ifdef.sh -D > /dev/null 2>&1
.PHONY: all strip tags dist links install clean distclean