Blob Blame History Raw
CC				?=cc
CFLAGS			?=-O2 -g

prefix			?=/usr/local
exec_prefix		?=$(prefix)
bindir			?=$(exec_prefix)/bin
includedir		?=$(exec_prefix)/include
libdir			?=$(exec_prefix)/lib
datarootdir		?=$(prefix)/share
datadir			?=$(datarootdir)
docdir			?=$(datarootdir)/doc/musl-compat-$(VERSION)
mandir			?=$(datarootdir)/man

BINS			:= $(notdir $(basename $(wildcard bin/*.c)))
BINS_SH			:= $(notdir $(basename $(wildcard bin/*.sh)))
INCLUDES		:= $(shell find include/ -type f -name '*.h')
INCLUDES        := $(INCLUDES:include/%=%)
LIBS			:= $(notdir $(wildcard lib/*.a))

VERSION			=2

build:	bin/getconf.o bin/getent.o bin/ldconfig.sh

bin/%.sh: bin/%.sh.in
	cp $< $@
	chmod +x "$@"

bin/%.o: bin/%.c
	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@

$(DESTDIR)$(bindir)/%: bin/$(notdir %)
	install -D -m 755 $< $(basename $@)

$(DESTDIR)$(includedir)/%: include/$(notdir %)
	install -D -m 644 $< $@

$(DESTDIR)$(libdir)/%: lib/$(notdir %)
	install -D -m 755 $< $@

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))

clean:
	rm -rf $(foreach b,$(BINS),bin/$(b).o) $(foreach b,$(BINS_SH),bin/$(b).sh)

.PHONY:	all build clean install