1 # J-Ben Makefile for Linux and Windows
3 ### User-editable options ###
4 # PLATFORM: either windows or gtk20
6 # BUILD: either release, debug, or profile
10 ifeq ($(PLATFORM
),windows
)
11 # CHANGE THESE 4 VARIABLES
13 boostbase
= D
:/boost_1_34_1
14 wxbase
= D
:/wxMSW-2.8
.7
15 wxbuildflags
= -DWXUSINGDLL
-DwxUSE_UNICODE
16 # NOTE: wxWidgets is assumed to be built with wxUSINGDLL and wxUSE_UNICODE.
17 # Also, I'm currently using a release build of wxWidgets regardless of
18 # whether a debug or release build is chosen. I may change this later.
20 # The following variables probably should NOT be changed.
21 wxplatformflags
= -D__GNUWIN32__
-D__WXMSW__
22 wincxxflags
= -pipe
-mthreads
23 winlinkflags
= -mwindows
25 wxinclude
= $(wxbase
)/include
26 wxcontribinc
= $(wxbase
)/contrib
/include
27 wxlibinc
= $(wxbase
)/lib
/gcc_dll
/mswu
29 wxliblink
= $(wxbase
)/lib
/gcc_dll
30 SharedCXXFLAGS
= $(wincxxflags
)
31 SharedCPPFLAGS
= $(wxbuildflags
) $(wxplatformflags
) \
32 -I
$(wxinclude
) -I
$(wxcontribinc
) -I
$(wxlibinc
) -I
$(boostbase
) -I
$(mingwbase
)/include
33 libs
= -L
$(wxliblink
) -L
$(mingwbase
)/lib
-lwxmsw28u_html
-lwxmsw28u_core \
34 -lwxbase28u
$(winlinkflags
)
37 ##################################
38 # DO NOT EDIT BEYOND THIS POINT! #
39 ##################################
43 OBJDIR
= obj
/$(PLATFORM
)/$(BUILD
)
44 BINDIR
= bin
/$(PLATFORM
)/$(BUILD
)
45 DEPDIR
= dep
/$(PLATFORM
)/$(BUILD
)
47 # Get flags/libs for GTK builds
48 ifeq ($(PLATFORM
),gtk20
)
49 SharedCXXFLAGS
= `wx-config --cxxflags` `pkg-config --cflags gtk+-2.0`
50 SharedCPPFLAGS
= `wx-config --cppflags`
51 libs
= `wx-config --libs` `pkg-config --libs gtk+-2.0`
56 ifeq ($(BUILD
),release
)
57 CXXFLAGS
= -Wall
-s
-O2
$(SharedCXXFLAGS
)
58 CPPFLAGS
= $(SharedCPPFLAGS
)
61 CXXFLAGS
= -Wall
-g
$(SharedCXXFLAGS
)
62 CPPFLAGS
= -DDEBUG
$(SharedCPPFLAGS
)
64 ifeq ($(BUILD
),profile
)
65 # Profiling mode: DEBUG flags, plus -pg, but without -DDEBUG
66 CXXFLAGS
= -Wall
-g
$(SharedCXXFLAGS
) -pg
67 CPPFLAGS
= $(SharedCPPFLAGS
)
70 sources
= $(shell ls
-t
*.
cpp) # Compile most recently edited files first.
72 # Build object configuration
73 ifeq ($(PLATFORM
),windows
)
74 objects
= $(sources
:%.
cpp=$(OBJDIR
)/%.o
) $(OBJDIR
)/jben.res
75 target
= $(BINDIR
)/jben.exe
77 objects
= $(sources
:%.
cpp=$(OBJDIR
)/%.o
)
78 target
= $(BINDIR
)/jben
81 # Select build environment type
86 ifeq ($(PLATFORM
),windows
)
94 # Define commands based on build environment
95 ifeq ($(buildenv
),windows
)
103 all: $(target
) kpengine
105 .PHONY
: kpengine
clean cleandep cleanall
107 $(target
) : $(objects
)
108 $(mkdircmd
) $(BINDIR
)
109 $(CXX
) $(CXXFLAGS
) -o
$(target
) $(objects
) $(libs
)
113 $(mkdircmd
) $(OBJDIR
)
114 windres.exe
-i jben.rc
-J rc
-o
$(OBJDIR
)/jben.res
-O coff
-I
$(wxinclude
) -I
$(wxlibinc
) -I
$(mingwbase
)/include
117 cd kanjipad
&& make
&& cd ..
120 cd kanjipad
&& make
clean && cd ..
121 rm -rfv bin obj jben.res
126 cleanall
: clean cleandep
128 $(OBJDIR
)/%.o
: %.
cpp
129 $(mkdircmd
) $(OBJDIR
)
130 $(CXX
) $(CXXFLAGS
) $(CPPFLAGS
) -c
-o
$@
$(@F
:%.o
=%.
cpp)
132 # Object dependency tracking
133 include $(sources
:%.
cpp=$(DEPDIR
)/%.d
)
134 $(DEPDIR
)/%.d
: %.
cpp
135 @echo Recreating
$@...
136 @
$(mkdircmd
) $(DEPDIR
)
137 @
$(CXX
) -MM
$(CPPFLAGS
) $< > $@.mktmp
138 ifeq ($(buildenv
),windows
)
139 @sed
"s,\($*\)\.o[ :]*,$(OBJDIR)/\1.o $@ : ,g" < $@.mktmp
> $@
141 # @sed 's,\($*\)\.o[ :]*,$(OBJDIR)/\1.o $@ : $(OBJDIR) ,g' < $@.mktmp > $@
142 @sed
's,\($*\)\.o[ :]*,$(OBJDIR)/\1.o $@ : ,g' < $@.mktmp
> $@