Added recipes 'install' and 'uninstall' to Makefile.
This commit is contained in:
parent
50fdb142dd
commit
006725f4a3
19
Makefile
19
Makefile
@ -8,6 +8,8 @@ OBJDIR := objects
|
|||||||
MAINOD := $(OBJDIR)/main
|
MAINOD := $(OBJDIR)/main
|
||||||
BINDIR := build
|
BINDIR := build
|
||||||
|
|
||||||
|
INSTDIR := /usr/local/bin
|
||||||
|
|
||||||
REFACTOR := refactor.h
|
REFACTOR := refactor.h
|
||||||
|
|
||||||
HEADERS := $(wildcard $(INCDIR)/*.h)
|
HEADERS := $(wildcard $(INCDIR)/*.h)
|
||||||
@ -46,6 +48,23 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.c $(HEADERS) | $(OBJDIR)
|
|||||||
$(MAINOD)/%.o: $(MAINDIR)/%.c $(HEADERS) | $(MAINOD)
|
$(MAINOD)/%.o: $(MAINDIR)/%.c $(HEADERS) | $(MAINOD)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
# $| evaluates to the order-only prerequisites, in this case: $(TARGETS)
|
||||||
|
# The $(foreach ...) function will evaluate to a semicolon-separated list of 'cp <target> $instdir'
|
||||||
|
# Putting this $(foreach ...) into the recipe means that its result
|
||||||
|
# cp a /usr/local/bin; cp b /usr/local/bin;
|
||||||
|
# will be run as a shell command.
|
||||||
|
#
|
||||||
|
# Shamelessly derived from:
|
||||||
|
# https://stackoverflow.com/questions/7918511/make-execute-an-action-for-each-prerequisite
|
||||||
|
|
||||||
|
install: | $(TARGETS)
|
||||||
|
@echo "Installing executables to $(INSTDIR)"
|
||||||
|
@$(foreach target, $|, cp -v $(target) $(INSTDIR);)
|
||||||
|
|
||||||
|
uninstall: | $(TARGETS)
|
||||||
|
@echo "Removing executables from $(INSTDIR)"
|
||||||
|
$(foreach target, $(notdir $|), rm -v $(INSTDIR)/$(target);)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -rv $(BINDIR) $(OBJDIR)
|
$(RM) -rv $(BINDIR) $(OBJDIR)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user