Fixed bug that caused "rpn -e" not to finish with a newline.
[rpn.git] / Makefile
blob8f88d8070f76575ba04b424d6e8b947aecabb73a
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 \
45 LFLAGS = -s -lm -o
46 endif
47 ifdef DEBUG
48 CFLAGS = -c -Wall -g -DRPN_CONSOLE -DRPN_LONG_DOUBLE -DRPN_DEBUG -D_GNU_SOURCE \
49 -DHASH_FUNCTION=HASH_JSW -DGIT_BUILD="\"$(GIT_BUILD)\"" -Isrc/include \
51 LFLAGS = -lm -o
52 endif
53 TARGET = $(BIN_DIR)/rpn
55 # General rule for compiling.
56 $(OBJDIR)%.o: $(SRCDIR)%.c
57 @echo Compiling $(notdir $<)
58 @$(CC) $< $(CFLAGS) $@
60 # rule to make the program
61 $(TARGET): $(OBJECTS)
62 @echo Linking $(TARGET)...
63 @$(CC) $(OBJECTS) $(LFLAGS) $@
65 # make the program by default
66 .PHONY: all
67 all: $(TARGET)
69 # rule to clean-up the objects and the target, if they exist
70 .PHONY: clean
71 clean:
72 @echo Cleaning objects and executables...
73 @$(RM) $(OBJECTS)
74 @$(RM) $(TARGET)
76 # rule to install program
77 .PHONY: install
78 install: $(TARGET)
79 $(CP) $< $(INSTALL_DIR)
81 # rule to make tarball for distribution.
82 .PHONY: dist
83 dist:
84 $(GIT_ARCHIVE)
86 # rule to make documentation
87 .PHONY: doc
88 doc:
89 doxygen Doxyfile
91 # PSP compilation.
92 PSP_TARGET = EBOOT.PBP
93 PSP_MAKEFILE = Makefile.psp
95 # Call the PSP makefile to do the work.
96 $(PSP_TARGET): $(PSP_MAKEFILE)
97 @$(MKF) $<
99 # Make the executable.
100 .PHONY: psp
101 psp: $(PSP_TARGET)
103 # Cleanup.
104 .PHONY: psp-clean
105 psp-clean:
106 @$(MKF) $(PSP_MAKEFILE) clean
108 .PHONY: psp-install
109 psp-install:
110 @$(MKF) $(PSP_MAKEFILE) install
112 # Wii compilation.
113 WII_MAKEFILE = Makefile.wii
115 .PHONY: wii
116 wii: $(WII_MAKEFILE)
117 @$(MKF) $(WII_MAKEFILE)
119 .PHONY: wii-clean
120 wii-clean: $(WII_MAKEFILE)
121 @$(MKF) $(WII_MAKEFILE) clean
123 .PHONY: wii-run
124 wii-run: $(WII_MAKEFILE)
125 @$(MKF) $(WII_MAKEFILE) run
127 # GUI compilation.
128 GUI_TARGET = $(BIN_DIR)/rpn-gui
129 GUI_MAKEFILE = Makefile.gui
131 $(GUI_TARGET): $(GUI_MAKEFILE)
132 @$(MKF) $<
134 .PHONY: gui
135 gui: $(GUI_TARGET)
137 .PHONY: gui-clean
138 gui-clean:
139 @$(MKF) $(GUI_MAKEFILE) clean
141 # An easter egg, just for the hell of it.
142 .PHONY: love
143 love:
144 @echo Not war?