Added 'install' target.

The 'install' target primarily aims to support pacaking tools. Therefore...
- It just presumes a "capable" install program to be present.
- There's intentionally no 'uninstall' target.
This commit is contained in:
Oliver Schmidt 2014-01-29 21:42:26 +01:00
parent 4452156d1a
commit e320fe3db8
3 changed files with 42 additions and 17 deletions

View File

@ -1,4 +1,4 @@
all mostlyclean clean:
all mostlyclean clean install:
@$(MAKE) -C src --no-print-directory $@
@$(MAKE) -C libsrc --no-print-directory $@
@ -14,6 +14,6 @@ lib:
%:
@$(MAKE) -C libsrc --no-print-directory $@
.PHONY: all mostlyclean clean avail unavail bin lib
.PHONY: all mostlyclean clean install avail unavail bin lib
.SUFFIXES:

View File

@ -50,10 +50,18 @@ endif
.SUFFIXES:
.PHONY: all lib $(TARGETS) mostlyclean clean
.PHONY: all lib $(TARGETS) mostlyclean clean install
ifndef TARGET
datadir = $(prefix)/share/cc65
INSTALLDIRS = ../asminc ../cfg ../include \
$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)) \
../lib ../targetutil $(addprefix ../,$(DRVTYPES))
INSTALL = install
all lib: $(TARGETS)
$(TARGETS):
@ -65,6 +73,21 @@ mostlyclean:
clean:
$(call RMDIR,../wrk ../lib ../targetutil $(addprefix ../,$(DRVTYPES)))
install:
$(foreach dir,$(INSTALLDIRS),$(INSTALL_recipe))
##########
define INSTALL_recipe
$(if $(prefix),,$(error variable `prefix' must be set))
$(INSTALL) -d $(subst ..,$(DESTDIR)$(datadir),$(dir))
$(INSTALL) -m644 $(dir)/* $(subst ..,$(DESTDIR)$(datadir),$(dir))
endef
##########
else # TARGET
CA65FLAGS =

View File

@ -12,19 +12,14 @@ PROGS = ar65 \
sim65 \
sp65
ifdef prefix
CA65_INC = $(prefix)/lib/cc65/asminc
CC65_INC = $(prefix)/lib/cc65/include
LD65_LIB = $(prefix)/lib/cc65/lib
LD65_OBJ = $(prefix)/lib/cc65/lib
LD65_CFG = $(prefix)/lib/cc65/cfg
else
CA65_INC := $(abspath ../asminc)
CC65_INC := $(abspath ../include)
LD65_LIB := $(abspath ../lib)
LD65_OBJ := $(abspath ../lib)
LD65_CFG := $(abspath ../cfg)
endif
bindir := $(prefix)/bin
datadir := $(if $(prefix),$(prefix)/share/cc65,$(abspath ..))
CA65_INC = $(datadir)/asminc
CC65_INC = $(datadir)/include
LD65_LIB = $(datadir)/lib
LD65_OBJ = $(datadir)/lib
LD65_CFG = $(datadir)/cfg
CFLAGS += -MMD -MP -O -std=c89 -I common \
-Wall -Wextra -Wno-char-subscripts -Werror $(USER_CFLAGS) \
@ -33,9 +28,11 @@ CFLAGS += -MMD -MP -O -std=c89 -I common \
LDLIBS += -lm
INSTALL = install
.SUFFIXES:
.PHONY: all bin $(PROGS) mostlyclean clean avail unavail
.PHONY: all bin $(PROGS) mostlyclean clean install avail unavail
all bin: $(PROGS)
@ -45,6 +42,11 @@ mostlyclean:
clean:
$(RM) -r ../wrk ../bin
install:
$(if $(prefix),,$(error variable `prefix' must be set))
$(INSTALL) -d $(DESTDIR)$(bindir)
$(INSTALL) ../bin/* $(DESTDIR)$(bindir)
avail:
$(foreach prog,$(PROGS),$(AVAIL_recipe))