Add installation target to makefile
This commit is contained in:
parent
0d4a741186
commit
e0fc6e5740
28
makefile
28
makefile
@ -1,6 +1,8 @@
|
|||||||
TARGET = $(notdir $(CURDIR))
|
TARGET = $(notdir $(CURDIR))
|
||||||
|
|
||||||
SRCEXT = .c
|
INSTALL = /usr/local/bin
|
||||||
|
|
||||||
|
SRCEXT = .c
|
||||||
INCEXT = .h
|
INCEXT = .h
|
||||||
OBJEXT = .o
|
OBJEXT = .o
|
||||||
|
|
||||||
@ -9,24 +11,30 @@ INCDIR = .
|
|||||||
OBJDIR = bin
|
OBJDIR = bin
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LD = gcc
|
LD = gcc
|
||||||
|
|
||||||
LDFLAGS = -lm -lpthread
|
LDFLAGS = -lm -lpthread
|
||||||
CCFLAGS = -std=gnu99 -g -ggdb -Og -Wall -Wextra -pedantic -Wno-unused-parameter
|
CCFLAGS = -std=gnu99 -g -ggdb -Og -Wall -Wextra -pedantic -Wno-unused-parameter
|
||||||
|
|
||||||
SRCTREE = $(shell find $(SRCDIR) -type d)
|
SRCTREE = $(shell find $(SRCDIR) -type d)
|
||||||
INCS = $(shell find $(INCDIR) -type f -name '*$(INCEXT)')
|
INCS = $(shell find $(INCDIR) -type f -name '*$(INCEXT)')
|
||||||
SRCS = $(shell find $(SRCDIR) -type f -name '*$(SRCEXT)')
|
SRCS = $(shell find $(SRCDIR) -type f -name '*$(SRCEXT)')
|
||||||
OBJTREE = $(foreach D,$(SRCTREE),$(shell echo $(D) | sed 's/$(SRCDIR)/$(OBJDIR)/'))
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user