From e320fe3db8ddb316eeb5e68e9af9aef75dd71628 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Wed, 29 Jan 2014 21:42:26 +0100 Subject: [PATCH] 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. --- Makefile | 4 ++-- libsrc/Makefile | 25 ++++++++++++++++++++++++- src/Makefile | 30 ++++++++++++++++-------------- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index d5a522871..b4882cc31 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/libsrc/Makefile b/libsrc/Makefile index fb716067b..cbc778f11 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -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 = diff --git a/src/Makefile b/src/Makefile index 7e6964579..051c7eb1f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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)) -- 2.39.5