Blame Makefile

Kylie McClain 6597c1
topdir          :=$(dir $(realpath $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))))
Kylie McClain 6597c1
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
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 6597c1
BINS            := $(notdir $(basename $(wildcard $(topdir)/bin/*.c)))
Kylie McClain 6597c1
BINS_SH         := $(notdir $(basename $(basename $(wildcard $(topdir)/bin/*.sh.in))))
Kylie McClain 6597c1
INCLUDES        := $(shell find "$(topdir)/include" -type f -name '*.h')
Kylie McClain 6597c1
INCLUDES        := $(INCLUDES:$(topdir)/include/%=%)
Kylie McClain b61f59
Kylie McClain b665b3
VERSION         =5
Kylie McClain b61f59
Kylie McClain 6597c1
build:	$(foreach b,$(BINS),$(topdir)/bin/$(b).o) $(foreach b,$(BINS_SH),$(topdir)/bin/$(b).sh)
Kylie McClain b61f59
Kylie McClain 6597c1
$(topdir)/bin/%.sh: $(topdir)/bin/%.sh.in
Kylie McClain 6597c1
	cp "$<" "$@"
Kylie McClain b61f59
	chmod +x "$@"
Kylie McClain b61f59
Kylie McClain 6597c1
$(topdir)/bin/%.o: $(topdir)/bin/%.c
Kylie McClain 6597c1
	$(CC) -I"$(topdir)/include" $(CFLAGS) $(LDFLAGS) "$<" -o "$@"
Kylie McClain b61f59
Kylie McClain 6597c1
$(DESTDIR)$(bindir)/%: $(topdir)/bin/$(notdir %)
Kylie McClain 6597c1
	install -D -m 755 "$<" "$(basename $@)"
Kylie McClain b61f59
Kylie McClain 6597c1
$(DESTDIR)$(includedir)/%: $(topdir)/include/$(notdir %)
Kylie McClain 6597c1
	install -D -m 644 "$<" "$@"
Kylie McClain b61f59
3549c8
install: $(foreach b,$(BINS),$(DESTDIR)$(bindir)/$(b).o) $(foreach b,$(BINS_SH),$(DESTDIR)$(bindir)/$(b).sh) $(foreach i,$(INCLUDES),$(DESTDIR)$(includedir)/$(i))
Kylie McClain b61f59
Kylie McClain b61f59
clean:
Kylie McClain 6597c1
	rm -rf $(foreach b,$(BINS),$(topdir)/bin/$(b).o) $(foreach b,$(BINS_SH),$(topdir)/bin/$(b).sh)
Kylie McClain b61f59
Kylie McClain b61f59
.PHONY:	all build clean install