Add installation target to makefile

This commit is contained in:
Artur Tamborski 2019-01-02 00:55:12 +01:00
parent 0d4a741186
commit e0fc6e5740

View File

@ -1,5 +1,7 @@
TARGET = $(notdir $(CURDIR)) TARGET = $(notdir $(CURDIR))
INSTALL = /usr/local/bin
SRCEXT = .c SRCEXT = .c
INCEXT = .h INCEXT = .h
OBJEXT = .o OBJEXT = .o
@ -21,12 +23,18 @@ OBJTREE = $(foreach D,$(SRCTREE),$(shell echo $(D) | sed 's/$(SRCDIR)/$(OBJDIR)/
OBJSTMP = $(foreach F,$(SRCS),$(shell echo $(F) | sed -e 's/$(SRCDIR)/$(OBJDIR)/')) OBJSTMP = $(foreach F,$(SRCS),$(shell echo $(F) | sed -e 's/$(SRCDIR)/$(OBJDIR)/'))
OBJS = $(foreach O,$(OBJSTMP),$(shell echo $(O) | sed -e 's/\$(SRCEXT)/\$(OBJEXT)/')) OBJS = $(foreach O,$(OBJSTMP),$(shell echo $(O) | sed -e 's/\$(SRCEXT)/\$(OBJEXT)/'))
all: $(TARGET) build: $(TARGET)
@echo Done. @echo Done.
run: $(TARGET) run: build
@./$(TARGET) @./$(TARGET)
install: build
@cp $(TARGET) $(INSTALL)
uninstall:
@rm -f $(INSTALL)/$(TARGET)
clean: clean:
@rm -r $(TARGET) $(OBJS) $(OBJDIR) 2>/dev/null || true @rm -r $(TARGET) $(OBJS) $(OBJDIR) 2>/dev/null || true
@ -39,4 +47,4 @@ $(OBJS): $(OBJDIR)/%$(OBJEXT) : $(SRCDIR)/%$(SRCEXT) | $(OBJDIR)
$(OBJDIR): $(OBJDIR):
@mkdir -p $(OBJDIR) $(OBJTREE) @mkdir -p $(OBJDIR) $(OBJTREE)
.PHONY: all run clean .PHONY: build run install clean