Code cleanup & factoring of commands module.
[rpn.git] / Makefile
blob0c09b74c784286d89f0834e066cd6d78b8c8d414
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 # Git command to make a distribution tarball.
16 GIT_ARCHIVE = git archive --format=tar --prefix=rpn-$(VERSION)/ HEAD | \
17 bzip2 >rpn-$(VERSION).tar.bz2
19 ifdef RELEASE
20 CXXFLAGS = -Wall -Weffc++ -pedantic -O2 -DRPN_CONSOLE -DRPN_LONG_DOUBLE \
21 -DGIT_BUILD="\"$(GIT_BUILD)\""
22 LFLAGS = -s -lm -o
23 endif
24 ifdef DEBUG
25 CXXFLAGS = -Wall -Weffc++ -pedantic -g -DRPN_CONSOLE -DRPN_LONG_DOUBLE \
26 -DGIT_BUILD=$(GIT_BUILD)
27 LFLAGS = -lm -o
28 endif
30 OBJDIR = obj/console/
31 SRCDIR = src/
32 TARGET = bin/console/rpn
33 OBJECTS = \
34 $(OBJDIR)Calculator.o $(OBJDIR)Commands.o $(OBJDIR)Help.o \
35 $(OBJDIR)History.o $(OBJDIR)Main.o $(OBJDIR)Operators.o \
36 $(OBJDIR)Variables.o $(OBJDIR)console/Arguments.o
38 # make the program by default
39 .PHONY: all
40 all: $(TARGET)
42 # rule to clean-up the objects and the target, if they exist
43 .PHONY: clean
44 clean:
45 @echo Cleaning objects and executables...
46 @$(RM) $(OBJECTS) $(TARGET)
48 # General rule for compiling.
49 $(OBJDIR)%.o: $(SRCDIR)%.cpp $(SRCDIR)rpn.h
50 @echo Compiling $(notdir $<)
51 @$(CXX) $(CXXFLAGS) -c -o $@ $<
53 # rule to make the program
54 $(TARGET): $(OBJECTS)
55 @echo Linking $(TARGET)...
56 @$(CXX) $(OBJECTS) $(LFLAGS) $@
58 # rule to make tarball for distribution.
59 .PHONY: dist
60 dist:
61 $(GIT_ARCHIVE)
63 # rule to make documentation
64 .PHONY: doc
65 doc:
66 doxygen Doxyfile
68 # PSP compilation.
69 PSP_TARGET = EBOOT.PBP
70 PSP_MAKEFILE = Makefile.psp
72 # Call the PSP makefile to do the work.
73 $(PSP_TARGET): $(PSP_MAKEFILE)
74 @$(MAKE) -f $<
76 # Make the executable.
77 .PHONY: psp
78 psp: $(PSP_TARGET)
80 # Cleanup.
81 .PHONY: psp-clean
82 psp-clean:
83 @$(MAKE) -f $(PSP_MAKEFILE) clean
85 .PHONY: psp-install
86 psp-install:
87 @$(MAKE) -f $(PSP_MAKEFILE) install
89 # Wii compilation.
90 WII_MAKEFILE = Makefile.wii
92 .PHONY: wii
93 wii: $(WII_MAKEFILE)
94 @$(MAKE) -f $(WII_MAKEFILE)
96 .PHONY: wii-clean
97 wii-clean: $(WII_MAKEFILE)
98 @$(MAKE) -f $(WII_MAKEFILE) clean
100 .PHONY: wii-run
101 wii-run: $(WII_MAKEFILE)
102 @$(MAKE) -f $(WII_MAKEFILE) run
104 # An easter egg, just for the hell of it.
105 .PHONY: love
106 love:
107 @echo Not war?