12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- override CPPFLAGS += --std=c++1z
- override CPPFLAGS += -MMD -MP
- override CPPFLAGS += -I./include
- override CPPFLAGS += $(shell cat .cxxflags 2> /dev/null | xargs)
- override LDFLAGS += $(shell cat .ldflags 2> /dev/null | xargs)
- override LDLIBS += $(shell cat .ldlibs 2> /dev/null | xargs)
- override LDFLAGS += -L./lib
- PREFIX ?= $(DESTDIR)/usr/local
- BINDIR := $(PREFIX)/bin
- SOURCES := $(shell echo *.cpp)
- SCRIPTS := $(shell echo *.sh)
- TEMPDIR := temp
- DISTDIR := out
- OUT := $(SOURCES:%.cpp=$(DISTDIR)/f%)
- TARGET := $(OUT:$(DISTDIR)/%=$(BINDIR)/%)
- TARGET += $(SCRIPTS:%.sh=$(BINDIR)/%)
- OBJECTS := $(SOURCES:%.cpp=$(TEMPDIR)/%.o)
- LOCALIB := $(wildcard lib/*.a)
- DEPENDS := $(OBJECTS:.o=.d)
- build: $(OUT)
- test: build
- ./tests/basic.sh
- $(DISTDIR)/f%: $(TEMPDIR)/%.o $(LOCALIB) | $(DISTDIR)
- $(CXX) $(LDFLAGS) $< $(LOCALIB) $(LDLIBS) -o $@
- $(TEMPDIR)/%.o: %.cpp | $(TEMPDIR)
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
- $(TEMPDIR):
- @mkdir $@
- $(DISTDIR):
- @mkdir $@
- clean:
- @rm $(DEPENDS) 2> /dev/null || true
- @rm $(OBJECTS) 2> /dev/null || true
- @rmdir $(TEMPDIR) 2> /dev/null || true
- @echo Temporaries cleaned!
- distclean: clean
- @rm $(OUT) 2> /dev/null || true
- @rmdir $(DISTDIR) 2> /dev/null || true
- @echo All clean!
- install: $(TARGET)
- @echo Install complete!
- $(BINDIR)/%: $(DISTDIR)/% | $(BINDIR)
- install --strip $< $@
- $(BINDIR)/%: ./%.sh | $(BINDIR)
- install $< $@
- $(BINDIR):
- @mkdir $@
- uninstall:
- -rm $(TARGET)
- @rmdir -p $(BINDIR) 2> /dev/null || true
- @echo Uninstall complete!
- -include $(DEPENDS)
- .PRECIOUS : $(OBJECTS)
- .PHONY : test clean distclean uninstall
|