Worked on making portability easier.
[rpn.git] / Makefile
blobb920fe8c30bc122048abd4f16268815ce2590f50
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 -pedantic -O2 -DRPN_CONSOLE
21 LFLAGS = -s -lm -o
22 endif
23 ifdef DEBUG
24 CXXFLAGS = -Wall -pedantic -g -DRPN_CONSOLE
25 LFLAGS = -lm -o
26 endif
28 SRCDIR = src/
29 TARGET = bin/rpn
30 OBJECTS = \
31 $(SRCDIR)Calculator.o $(SRCDIR)Commands.o $(SRCDIR)History.o \
32 $(SRCDIR)Main.o $(SRCDIR)Operators.o $(SRCDIR)Variables.o
34 # make the program by default
35 .PHONY: all
36 all: $(TARGET)
38 # rule to clean-up the objects and the target, if they exist
39 .PHONY: clean
40 clean:
41 @echo Cleaning objects and executables...
42 @$(RM) $(OBJECTS) $(TARGET)
44 # General rule for compiling.
45 $(SRCDIR)%.o: $(SRCDIR)%.cpp $(SRCDIR)rpn.h
46 @echo Compiling $(notdir $<)
47 @$(CXX) $(CXXFLAGS) -c -o $@ $<
49 # rule to make the program
50 $(TARGET): $(OBJECTS)
51 @echo Linking $(TARGET)...
52 @$(CXX) $(OBJECTS) $(LFLAGS) $@
54 # rule to make tarball for distribution.
55 .PHONY: dist
56 dist:
57 $(GIT_ARCHIVE)
59 # rule to make documentation
60 .PHONY: doc
61 doc:
62 doxygen Doxyfile
64 # An easter egg, just for the hell of it.
65 .PHONY: love
66 love:
67 @echo Not war?