Improve the Makefile: allow user‐defined variables.

This commit is contained in:
Anthony J. Bentley
2012-10-18 20:22:47 -06:00
parent a2dc23c55c
commit 39d8674a93
2 changed files with 37 additions and 15 deletions

View File

@@ -1,5 +1,9 @@
CFLAGS += -Wall -Iinclude -Iinclude/asm/gameboy -g -std=c99 CFLAGS += -Wall -Iinclude -Iinclude/asm/gameboy -g -std=c99
PREFIX ?= /usr/local
# User-defined variables
PREFIX = /usr/local
BINPREFIX = ${PREFIX}/bin
MANPREFIX = ${PREFIX}/man
yacc_pre := \ yacc_pre := \
src/asm/yaccprt1.y\ src/asm/yaccprt1.y\
@@ -47,19 +51,19 @@ clean:
@rm -rf src/asm/asmy.c @rm -rf src/asm/asmy.c
install: all install: all
@install -s -o root -g bin -m 555 rgbasm ${PREFIX}/bin/rgbasm @install -s -m 555 rgbasm ${BINPREFIX}/rgbasm
@install -s -o root -g bin -m 555 rgbfix ${PREFIX}/bin/rgbfix @install -s -m 555 rgbfix ${BINPREFIX}/rgbfix
@install -s -o root -g bin -m 555 rgblink ${PREFIX}/bin/rgblink @install -s -m 555 rgblink ${BINPREFIX}/rgblink
@install -s -o root -g bin -m 555 rgblib ${PREFIX}/bin/rgblib @install -s -m 555 rgblib ${BINPREFIX}/rgblib
@install -o root -g bin -m 444 src/rgbds.7 ${PREFIX}/man/cat7/rgbds.7 @install -m 444 src/rgbds.7 ${MANPREFIX}/man7/rgbds.7
@install -o root -g bin -m 444 src/asm/rgbasm.1 \ @install -m 444 src/asm/rgbasm.1 \
${PREFIX}/man/cat1/rgbasm.1 ${MANPREFIX}/man1/rgbasm.1
@install -o root -g bin -m 444 src/fix/rgbfix.1 \ @install -m 444 src/fix/rgbfix.1 \
${PREFIX}/man/cat1/rgbfix.1 ${MANPREFIX}/man1/rgbfix.1
@install -o root -g bin -m 444 src/link/rgblink.1 \ @install -m 444 src/link/rgblink.1 \
${PREFIX}/man/cat1/rgblink.1 ${MANPREFIX}/man1/rgblink.1
@install -o root -g bin -m 444 src/lib/rgblib.1 \ @install -m 444 src/lib/rgblib.1 \
${PREFIX}/man/cat1/rgblib.1 ${MANPREFIX}/man1/rgblib.1
rgbasm: $(rgbasm_obj) rgbasm: $(rgbasm_obj)
@${CC} $(CFLAGS) -o $@ $(rgbasm_obj) -lm @${CC} $(CFLAGS) -o $@ $(rgbasm_obj) -lm

20
README
View File

@@ -26,10 +26,28 @@ privileges):
make install make install
You can read the manuals with the man(1) command. E.g., After installation, you can read the manuals with the man(1) command. E.g.,
man 1 rgbasm man 1 rgbasm
Note: the variables described below can affect installation behavior when given
on the make command line. For example, to install rgbds in your home directory
instead of systemwide, run the following:
mkdir -p $HOME/{bin,man/man1,man/man7}
make install PREFIX=$HOME
PREFIX: Location where RGBDS will be installed. Defaults to /usr/local.
BINPREFIX: Location where the RGBDS programs will be installed. Defaults
to ${PREFIX}/bin.
MANPREFIX: Location where the RGBDS man pages will be installed. Defaults
to ${PREFIX}/man.
Installing RGBDS (Windows) Installing RGBDS (Windows)
============================ ============================