From 9fece990bea6525bec5afd8b60d1c731a4d13839 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 28 Apr 2013 22:30:18 +0200 Subject: [PATCH] Replaced elaborate install logic with just a bunch of symlinks. Maybe I'm naive but even after thinking about it for quite some time I can't see why it should hurt to just build the cc65 binaries from the sources "in place" and have 'make install' simply create some symlinks in usr/local/bin. The new Makfile builds the binaries with builtin search paths matching their build location. So the symlinks in usr/local/bin allow to allow to use them out-of-the-box without additional environment variables. --- make/gcc.mak | 207 ------------------------------------------------ make/install-sh | 87 -------------------- src/Makefile | 24 +++++- 3 files changed, 23 insertions(+), 295 deletions(-) delete mode 100644 make/gcc.mak delete mode 100755 make/install-sh diff --git a/make/gcc.mak b/make/gcc.mak deleted file mode 100644 index 703cbd0b3..000000000 --- a/make/gcc.mak +++ /dev/null @@ -1,207 +0,0 @@ -#! /usr/bin/make -f -# -*- make -*- -# -# Main gcc Makefile. -# This makefile is maintained by Greg King . - -# Goals that are supported by the cc65 package -.PHONY: all bins libs docs samples tests clean zap -.PHONY: uninstall install install-bins install-libs install-docs install-samps - -# If SYS is defined on this makefile's command-line, then we want it to go -# to "samples" and "tests", but not to the other rules. So, we disable a -# feature of GNU make that would have given ${SYS} to every sub-make. -#MAKEOVERRIDES= -# (That trick has been disabled.) - -# To compile with custom make-options, set them here; for example: -#MAKEOPTS = -j 2 CFLAGS=-O4 CC=clang -MAKEOPTS = - -# The install prefix and directories -prefix = /usr/local -exec_prefix = $(prefix) - -bindir = $(exec_prefix)/bin -datadir = $(prefix)/share -docdir = $(datadir)/doc -libdir = $(exec_prefix)/lib - -CC65_DOC = $(docdir)/cc65 -CC65_HOME = $(libdir)/cc65 - -CA65_INC = $(CC65_HOME)/asminc -CC65_INC = $(CC65_HOME)/include -LD65_CFG = $(CC65_HOME)/cfg -LD65_LIB = $(CC65_HOME)/lib -LD65_OBJ = $(CC65_HOME)/obj - -# Programs - -MKDIR = mkdir -m 755 - -# BSD-like install-script/-program -INSTALL = make/install-sh - -INSTALL_DATA = $(INSTALL) -c -m 644 -INSTALL_PROG = $(INSTALL) -c -m 755 -INSTALL_STRIP = $(INSTALL_PROG) -s - -# This file-name extension is needed on DOS/Windows systems. -ifdef COMSPEC -EXT = .exe -endif - -# Rules - -# The sample and library-test programs must be compiled for only one platform -# at a time. So, those rules are done automatically only when a user names -# a system on the command-line. (A user can do those rules with their -# defaults by putting "all samples tests" on the command-line.) -# -all: bins libs docs $(SYS:%=samples tests) - -bins: - @$(MAKE) -C src -f make/gcc.mak $(MAKEOPTS) \ - CA65_INC=\\\"${CA65_INC}/\\\" CC65_INC=\\\"${CC65_INC}/\\\" \ - LD65_CFG=\\\"${LD65_CFG}/\\\" LD65_LIB=\\\"${LD65_LIB}/\\\" \ - LD65_OBJ=\\\"${LD65_OBJ}/\\\" - -libs: - @$(MAKE) -C libsrc - -# This rule won't try to generate HTML files -# if a host system doesn't have LinuxDoc Tools. -docs: - @if linuxdoc -B check doc/index >/dev/null 2>&1; \ - then $(MAKE) -C doc $(MAKEOPTS) html; \ - else echo '"LinuxDoc Tools" is not installed; skipping HTML documentation.'; \ - fi - -# Some platforms cannot compile all of the sample and library-test programs. -# So, these rules ignore errors. - -samples: - -@$(MAKE) -k -C samples prefix=$(prefix) $(SYS:%=SYS=%) - -tests: - -@$(MAKE) -k -C testcode/lib prefix=$(prefix) $(SYS:%=SYS=%) - -clean zap: - @$(MAKE) -C src -f make/gcc.mak $@ - @$(MAKE) -C libsrc $@ - @$(MAKE) -C doc $@ - @$(MAKE) -C samples $@ -# @$(MAKE) -C testcode/lib $@ $(SYS:%=SYS=%) - -uninstall: install-test - cd $(bindir) && $(RM) ar65${EXT} ca65${EXT} cc65${EXT} cl65${EXT} \ - co65${EXT} da65${EXT} ld65${EXT} od65${EXT} grc65${EXT} ca65html - $(RM) -R $(CC65_HOME) $(CC65_DOC) - -install: install-test install-dirs install-bins install-libs install-docs - @echo - @echo 'If you installed the files into non-default directories, then' - @echo 'you might need to export some shell environment variables:' - @echo - @echo 'CC65_HOME=$(CC65_HOME)' - @echo ' or' - @echo 'CA65_INC=$(CA65_INC)' - @echo 'CC65_INC=$(CC65_INC)' - @echo 'LD65_CFG=$(LD65_CFG)' - @echo 'LD65_LIB=$(LD65_LIB)' - @echo 'LD65_OBJ=$(LD65_OBJ)' - @echo - @if [ -x $(bindir)/grc${EXT} ]; then \ - echo 'grc was renamed to grc65; but, a grc command is in your binaries directory.'; \ - echo "If that command is an old copy of CC65's program,"; \ - echo 'then you should use a "${MAKE} erase-grc" command to remove it.'; \ - fi - -.PHONY: install-test -install-test: - @if [ `id -u` != 0 ]; then \ - echo; \ - echo 'If you are denied permission to install or uninstall this package,'; \ - echo 'then you will need to do "make/gcc.mak install" or "make/gcc.mak uninstall"'; \ - echo 'as either the root user or an administrator.'; \ - echo; \ - fi 2>/dev/null - -.PHONY: install-dirs -install-dirs: $(bindir) $(datadir) $(docdir) $(libdir) \ - $(CC65_DOC) $(CC65_HOME) \ - $(CA65_INC) $(CC65_INC) \ - $(CC65_INC)/em $(CC65_INC)/geos $(CC65_INC)/joystick \ - $(CC65_INC)/mouse $(CC65_INC)/sys $(CC65_INC)/tgi \ - $(LD65_CFG) $(LD65_LIB) $(LD65_OBJ) \ - $(CC65_HOME)/emd $(CC65_HOME)/joy $(CC65_HOME)/mou \ - $(CC65_HOME)/ser $(CC65_HOME)/tgi - -$(bindir) $(datadir) $(docdir) $(libdir) \ -$(CC65_DOC) $(CC65_HOME) \ -$(CA65_INC) $(CC65_INC) \ -$(LD65_CFG) $(LD65_LIB) $(LD65_OBJ): - $(MKDIR) -p $@ || $(MKDIR) $@ - -$(CC65_HOME)/% $(CC65_INC)/% $(CC65_DOC)/%: - $(MKDIR) $@ - -install-bins: - for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc65; \ - do $(INSTALL_STRIP) src/$$f/$$f${EXT} $(bindir) || exit $$?; \ - done - $(INSTALL_PROG) src/ca65html/ca65html $(bindir) - -install-libs: - for f in asminc/*.inc; \ - do $(INSTALL_DATA) $$f $(CA65_INC) || exit $$?; \ - done - for f in include/*.h; \ - do $(INSTALL_DATA) $$f $(CC65_INC) || exit $$?; \ - done - for d in em geos joystick mouse sys tgi; \ - do for f in include/$$d/*.h; \ - do $(INSTALL_DATA) $$f $(CC65_INC)/$$d || exit $$?; \ - done || exit $$?; \ - done - for f in libsrc/*.lib; \ - do $(INSTALL_DATA) $$f $(LD65_LIB) || exit $$?; \ - done - for f in libsrc/*-*.o; \ - do $(INSTALL_DATA) $$f $(LD65_OBJ) || exit $$?; \ - done - for f in src/ld65/cfg/[!g]*-*.cfg; \ - do $(INSTALL_DATA) $$f $(LD65_CFG) || exit $$?; \ - done - for d in emd joy mou ser tgi; \ - do for f in libsrc/*.$$d; \ - do $(INSTALL_DATA) $$f $(CC65_HOME)/$$d || exit $$?; \ - done || exit $$?; \ - done - -install-docs: - for f in src/ca65/macpack/*.mac; \ - do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \ - done - for f in readme.1st compile.txt CREDITS BUGS internal.txt newvers.txt; \ - do $(INSTALL_DATA) doc/$$f $(CC65_DOC) || exit $$?; \ - done - if [ -f doc/index.htm* ]; \ - then for f in doc/*.htm*; \ - do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \ - done; \ - fi - -install-samps: ${addprefix $(CC65_DOC)/, $(shell find samples -type d)} - @$(MAKE) -C samples zap - for d in `find samples -type d`; \ - do for f in $$d/*; \ - do if [ -f $$f ]; \ - then $(INSTALL_DATA) $$f $(CC65_DOC)/$$d || exit $$?; \ - fi; \ - done || exit $$?; \ - done - -erase-grc: - $(RM) $(bindir)/grc${EXT} diff --git a/make/install-sh b/make/install-sh deleted file mode 100755 index 3fe6c2665..000000000 --- a/make/install-sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh -# -# install-sh -- install a program, script, or data-file. -# -# This isn't a full install-script; it does only what is needed by the cc65 -# package. It can install only one file at a time. - -# If the system has an "install" command, then use it; otherwise, emulate it. -if type install >/dev/null 2>&1 -then exec install "$@" -fi - -# Don't use ":-" because 4.3BSD and earlier shells don't like it. -# Put in absolute paths if you don't have these commands in your PATH; -# or, set these upper-case variables in your environment. -cpprog="${CPPROG-cp}" -mvprog="${MVPROG-mv}" -rmprog="${RMPROG-rm}" -stripprog="${STRIPPROG-strip}" -chmodprog="${CHMODPROG-chmod}" - -instcmd="$cpprog" -stripcmd="" -chmodcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" - -while [ x"$1" != x ]; do - case $1 in - -c) ;; - - -m) chmodcmd="$chmodprog $2" - shift - ;; - - -s) stripcmd="$stripprog" - ;; - - # The first name is the source; the last name is the destination. - *) if [ x"$src" = x ] - then src="$1" - else dst="$1" - fi - esac - shift - done - -[ x"$src" != x ] || { echo "$0: no input file was named." >&2; exit 1;} -[ x"$dst" != x ] || { echo "$0: no destination was named." >&2; exit 1;} - -[ -e "$src" ] || { echo "$0: \"$src\" doesn't exist." >&2; exit 1;} - -# Make a temporary file-name in the proper directory. -dsttmp="$dst/#inst.$$#" - -# Append the input filename to the destination directory. -dst="$dst"/`basename "$src"` - -# Trap to remove the temporary file if it isn't renamed. -trap 'status=$?; $rmcmd "$dsttmp" && exit $status' 0 -trap '(exit $?); exit' 1 2 3 13 15 - -# Copy the source file to the temporary name. -$instcmd "$src" "$dsttmp" && - -if [ x"$stripcmd" != x ] - then $stripcmd "$dsttmp" - fi && -if [ x"$chmodcmd" != x ] - then $chmodcmd "$dsttmp" - fi && - -# Remove an old file (only if the temporary file was created successfully). -if [ -f "$dst" ] - then $rmcmd "$dst" 2>/dev/null || - { echo "$0: can't remove \"$dst\"" >&2 - (exit 1); exit - } - fi && - -# Rename the temporary file to the real name. -$mvcmd "$dsttmp" "$dst" && - -# The final little trick to pass "correctly" the exit status to exit traps. -{ (exit 0); exit;} diff --git a/src/Makefile b/src/Makefile index 31223e5d1..976dd40df 100644 --- a/src/Makefile +++ b/src/Makefile @@ -28,7 +28,29 @@ mostlyclean: clean: mostlyclean $(RM) -r ../bin -.PHONY: all $(PROGS) mostlyclean clean +install: all + $(foreach prog,$(PROGS),$(INSTALL_recipe)) + +uninstall: + $(foreach prog,$(PROGS),$(UNINSTALL_recipe)) + +.PHONY: all $(PROGS) mostlyclean clean install uninstall + +########## + +define INSTALL_recipe = + +ln -s $(abspath ../bin/$(prog)) /usr/local/bin/$(prog) + +endef + +########## + +define UNINSTALL_recipe = + +$(RM) /usr/local/bin/$(prog) + +endef ########## -- 2.39.5