Blame Makefile

Kylie McClain 4deba6
CC              ?=cc
Kylie McClain 4deba6
CFLAGS          ?=-O2 -g
Kylie McClain 4deba6
Kylie McClain 4deba6
prefix          ?=/usr/local
Kylie McClain 4deba6
exec_prefix     ?=$(prefix)
Kylie McClain 4deba6
bindir          ?=$(exec_prefix)/bin
Kylie McClain 4deba6
includedir      ?=$(exec_prefix)/include
Kylie McClain 4deba6
libdir          ?=$(exec_prefix)/lib
Kylie McClain 4deba6
datarootdir     ?=$(prefix)/share
Kylie McClain 4deba6
datadir         ?=$(datarootdir)
Kylie McClain 4deba6
docdir          ?=$(datarootdir)/doc/musl-compat-$(VERSION)
Kylie McClain 4deba6
mandir          ?=$(datarootdir)/man
Kylie McClain 4deba6
Kylie McClain 4deba6
BINS            := $(notdir $(basename $(wildcard bin/*.c)))
Kylie McClain 4deba6
BINS_SH         := $(notdir $(basename $(basename $(wildcard bin/*.sh.in))))
Kylie McClain 4deba6
INCLUDES        := $(shell find include/ -type f -name '*.h')
Kylie McClain 37edee
INCLUDES        := $(INCLUDES:include/%=%)
Kylie McClain 4deba6
LIBS            := $(notdir $(wildcard lib/*.a))
Kylie McClain b61f59
Kylie McClain e4df39
VERSION         =4
Kylie McClain b61f59
Kylie McClain 63f246
build:	$(foreach b,$(BINS),bin/$(b).o) $(foreach b,$(BINS_SH),bin/$(b).sh)
Kylie McClain b61f59
Kylie McClain b61f59
bin/%.sh: bin/%.sh.in
Kylie McClain b61f59
	cp $< $@
Kylie McClain b61f59
	chmod +x "$@"
Kylie McClain b61f59
Kylie McClain b61f59
bin/%.o: bin/%.c
Kylie McClain b61f59
	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
Kylie McClain b61f59
Kylie McClain b61f59
$(DESTDIR)$(bindir)/%: bin/$(notdir %)
Kylie McClain 1ce61e
	install -D -m 755 $< $(basename $@)
Kylie McClain b61f59
Kylie McClain b61f59
$(DESTDIR)$(includedir)/%: include/$(notdir %)
Kylie McClain 1ce61e
	install -D -m 644 $< $@
Kylie McClain b61f59
Kylie McClain b61f59
$(DESTDIR)$(libdir)/%: lib/$(notdir %)
Kylie McClain 1ce61e
	install -D -m 755 $< $@
Kylie McClain b61f59
Kylie McClain b61f59
install: build $(foreach b,$(BINS),$(DESTDIR)$(bindir)/$(b).o) $(foreach b,$(BINS_SH),$(DESTDIR)$(bindir)/$(b).sh) $(foreach i,$(INCLUDES),$(DESTDIR)$(includedir)/$(i)) $(foreach l,$(LIBS),$(DESTDIR)$(libdir)/$(l))
Kylie McClain b61f59
Kylie McClain b61f59
clean:
Kylie McClain b61f59
	rm -rf $(foreach b,$(BINS),bin/$(b).o) $(foreach b,$(BINS_SH),bin/$(b).sh)
Kylie McClain b61f59
Kylie McClain b61f59
.PHONY:	all build clean install