aboutsummaryrefslogblamecommitdiffstats
path: root/Makefile
blob: 1d032bc1f0521a145c32ef6b4330cb3896ff1b88 (plain) (tree)
1
2
3
4
5
6
7
8
9
10






                      
                                      

                                                         






                                                                                                                          







                                                   
                                           

                                   
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

all: sctrace

sctrace: sctrace.c arg.h list-errnos.h
	$(CC) -o $@ $@.c $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)

list-errnos.h:
	printf '#define LIST_ERRNOS(_)\\\n\t' > $@
	cat /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
		| sed 's/\/\/.*$$//' | tr -d '$$' | sed 's/\*\//\$$/g' | sed 's/\/\*[^$$]*\$$//g' \
		| sed -n '/^[ \t]*#[ \t]*define[ \t].*[ \t][0-9]*[ \t]*$$/s/^[ \t#]*define[ \t]*\([^ \t]*\).*$$/_(\1)/p' \
		| sort | uniq | tr '\n' '#' | sed 's/#_/\\\n\t_/g' | tr '#' '\n' >> $@

install: sctrace
	mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
	cp -- sctrace "$(DESTDIR)$(PREFIX)/bin"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/bin/sctrace"

clean:
	-rm -f -- *.o list-errnos.h sctrace

.PHONY: all install uninstall clean