Removed trailing whitespace.
[rpn.git] / Makefile
blob9165064acfa091fc4f189613d0b7843d7dc2e5c1
1 # Makefile for rpn.
2 # Should be fairly portable for the various *nix systems. The rules
3 # themselves shouldn't need to be changed; only the variables may need to
4 # change.
6 # Automatically default to a release build.
7 ifndef DEBUG
8 RELEASE = 1
9 endif
11 # Version
12 VERSION = $(shell cat VERSION)
13 GIT_BUILD = $(shell git describe)
15 # Programs
16 MKF = make -f
17 CC = gcc
18 RM = rm -f
19 CP = cp
21 # object code
22 SRCDIR = src/
23 OBJDIR = obj/generic/
24 SOURCES = src/console/arguments.c src/calculator.c src/commands.c \
25 src/console/error.c src/console/help.c src/history.c src/operators.c \
26 src/parser.c src/console/main.c src/stack.c src/tokens.c \
27 src/variables.c
28 OBJECTS = $(subst .c,.o,$(subst $(SRCDIR),$(OBJDIR),$(SOURCES)))
30 # Git command to make a distribution tarball.
31 GIT_ARCHIVE = git archive --format=tar --prefix=rpn-$(VERSION)/ HEAD | \
32 bzip2 >rpn-$(VERSION).tar.bz2
34 # Installation directory
35 INSTALL_DIR = /usr/bin
37 # Executable generation directory
38 BIN_DIR = bin/generic
40 # Compilation options
41 ifdef RELEASE
42 CFLAGS = -c -s -Wall -O2 -DRPN_CONSOLE -DRPN_LONG_DOUBLE -D_GNU_SOURCE \
43 -DHASH_FUNCTION=HASH_JSW -DGIT_BUILD="\"$(GIT_BUILD)\"" -Isrc/include -o
44 LFLAGS = -s -lm -o
45 endif
46 ifdef DEBUG
47 CFLAGS = -c -Wall -g -DRPN_CONSOLE -DRPN_LONG_DOUBLE -DRPN_DEBUG -D_GNU_SOURCE \
48 -DHASH_FUNCTION=HASH_JSW -DGIT_BUILD="\"$(GIT_BUILD)\"" -Isrc/include -o
49 LFLAGS = -lm -o
50 endif
51 TARGET = $(BIN_DIR)/rpn
53 # General rule for compiling.
54 $(OBJDIR)%.o: $(SRCDIR)%.c
55 @echo Compiling $(notdir $<)
56 @$(CC) $< $(CFLAGS) $@
58 # rule to make the program
59 $(TARGET): $(OBJECTS)
60 @echo Linking $(TARGET)...
61 @$(CC) $(OBJECTS) $(LFLAGS) $@
63 # make the program by default
64 .PHONY: all
65 all: $(TARGET)
67 # rule to clean-up the objects and the target, if they exist
68 .PHONY: clean
69 clean:
70 @echo Cleaning objects and executables...
71 @$(RM) $(OBJECTS)
72 @$(RM) $(TARGET)
74 # rule to install program
75 .PHONY: install
76 install: $(TARGET)
77 $(CP) $< $(INSTALL_DIR)
79 # rule to make tarball for distribution.
80 .PHONY: dist
81 dist:
82 $(GIT_ARCHIVE)
84 # rule to make documentation
85 .PHONY: doc
86 doc:
87 doxygen Doxyfile
89 # PSP compilation.
90 PSP_TARGET = EBOOT.PBP
91 PSP_MAKEFILE = Makefile.psp
93 # Call the PSP makefile to do the work.
94 $(PSP_TARGET): $(PSP_MAKEFILE)
95 @$(MKF) $<
97 # Make the executable.
98 .PHONY: psp
99 psp: $(PSP_TARGET)
101 # Cleanup.
102 .PHONY: psp-clean
103 psp-clean:
104 @$(MKF) $(PSP_MAKEFILE) clean
106 .PHONY: psp-install
107 psp-install:
108 @$(MKF) $(PSP_MAKEFILE) install
110 # Wii compilation.
111 WII_MAKEFILE = Makefile.wii
113 .PHONY: wii
114 wii: $(WII_MAKEFILE)
115 @$(MKF) $(WII_MAKEFILE)
117 .PHONY: wii-clean
118 wii-clean: $(WII_MAKEFILE)
119 @$(MKF) $(WII_MAKEFILE) clean
121 .PHONY: wii-run
122 wii-run: $(WII_MAKEFILE)
123 @$(MKF) $(WII_MAKEFILE) run
125 # GUI compilation.
126 GUI_TARGET = $(BIN_DIR)/rpn-gui
127 GUI_MAKEFILE = Makefile.gui
129 $(GUI_TARGET): $(GUI_MAKEFILE)
130 @$(MKF) $<
132 .PHONY: gui
133 gui: $(GUI_TARGET)
135 .PHONY: gui-clean
136 gui-clean:
137 @$(MKF) $(GUI_MAKEFILE) clean
139 .PHONY: love
140 love:
141 @echo Not war?