51 lines
1.2 KiB
Makefile
51 lines
1.2 KiB
Makefile
SED ?= sed
|
|
|
|
DESTDIR ?=
|
|
PREFIX ?= /usr/local
|
|
EXEC_PREFIX ?= $(PREFIX)
|
|
BINDIR ?= $(EXEC_PREFIX)/bin
|
|
LIBEXECDIR ?= $(EXEC_PREFIX)/libexec
|
|
DATAROOTDIR ?= $(PREFIX)/share
|
|
MANDIR ?= $(DATAROOTDIR)/man
|
|
BCDATADIR ?= $(DATAROOTDIR)/bc
|
|
|
|
BINS := dc/dc bc/bc
|
|
MAN1S := dc/dc.1 bc/bc.1
|
|
BCDATAS := bc/lib.b
|
|
|
|
.SUFFIXES:
|
|
.SUFFIXES: .c .o
|
|
|
|
.PHONY: all install uninstall clean distclean
|
|
|
|
all: $(BINS)
|
|
|
|
dc/dc: dc/dc.c dc/dc.h
|
|
$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $< $(LDFLAGS)
|
|
|
|
bc/bc: bc/bc.c
|
|
$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -DDC='"$(BINDIR)/dc"' -DLIBB='"$(BCDATADIR)/lib.b"' $< $(LDFLAGS)
|
|
|
|
bc/bc.c: bc/y.tab.c bc/yyval.sed
|
|
$(SED) -f bc/yyval.sed $< > $@
|
|
|
|
bc/y.tab.c: bc/bc.y
|
|
cd bc && $(YACC) bc.y
|
|
|
|
.c.o:
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
|
|
|
|
install: $(BINS) $(MAN1S) $(BCDATAS)
|
|
install -D -m 755 -t '$(DESTDIR)$(BINDIR)' $(BINS)
|
|
install -D -m 644 -t '$(DESTDIR)$(MANDIR)/man1' $(MAN1S)
|
|
install -D -m 644 -t '$(DESTDIR)$(BCDATADIR)' $(BCDATAS)
|
|
|
|
uninstall:
|
|
cd '$(DESTDIR)$(BINDIR)' && for i in $(BINS); do rm "$$(basename "$$i")"; done
|
|
cd '$(DESTDIR)$(MANDIR)/man1' && for i in $(MAN1S); do rm "$$(basename "$$i")"; done
|
|
cd '$(DESTDIR)$(BCDATADIR)' && for i in $(BCDATAS); do rm "$$(basename "$$i")"; done
|
|
|
|
clean:
|
|
rm -f $(BINS) bc/y.tab.c bc/bc.c
|
|
|
|
distclean: clean
|