Updated makefiles for Win32 builds using MinGW/STLPort.
[jben.git] / Makefile
blob7f3609b8e2ccc327d2e00a42aa3a794b3cd072fa
1 # J-Ben Makefile for Linux and Windows
3 ### User-editable options ###
4 # PLATFORM: either windows or gtk20
5 PLATFORM = gtk20
6 # BUILD: either release, debug, or profile
7 BUILD = release
8 # MAKE: change the make command, if needed
10 # WINDOWS-SPECIFIC
11 ifeq ($(PLATFORM),windows)
12 # CHANGE THESE 4 VARIABLES
13 MAKE = mingw32-make
14 mingwbase = C:/dev/MinGW
15 boostbase = C:/dev/boost_1_34_1
16 wxbase = C:/dev/wxMSW-2.8.7
17 wxbuildflags = -DWXUSINGDLL -DwxUSE_UNICODE
18 stlportbase = C:/dev/STLport-5.1.5
19 iconvbase = C:/dev/libiconv
20 mkdircmd = C:/progra~1/gnuwin32/bin/mkdir -p
21 # NOTE: wxWidgets is assumed to be built with wxUSINGDLL and wxUSE_UNICODE.
22 # Also, I'm currently using a release build of wxWidgets regardless of
23 # whether a debug or release build is chosen. I may change this later.
25 # The following variables probably should NOT be changed.
26 wxplatformflags = -D__GNUWIN32__ -D__WXMSW__
27 # STLPort specifies -pthreads - does -mthreads work fine for this???
28 wincxxflags = -pipe -mthreads
29 winlinkflags = -mwindows
31 wxinclude = $(wxbase)/include
32 wxcontribinc = $(wxbase)/contrib/include
33 wxlibinc = $(wxbase)/lib/gcc_dll/mswu
35 wxliblink = $(wxbase)/lib/gcc_dll
36 SharedCXXFLAGS = $(wincxxflags)
37 SharedCPPFLAGS = -I$(stlportbase)/stlport $(wxbuildflags) \
38 $(wxplatformflags) -I$(wxinclude) -I$(wxcontribinc) -I$(wxlibinc) \
39 -I$(boostbase) -I$(mingwbase)/include -I$(iconvbase)/include
40 libs = -L$(stlportbase)/lib -L$(wxliblink) -L$(mingwbase)/lib -L$(iconvbase)/lib \
41 -lwxmsw28u_html -lwxmsw28u_core -lwxbase28u $(winlinkflags) -liconv -lstlport.5.1.dll
42 endif
44 ##################################
45 # DO NOT EDIT BEYOND THIS POINT! #
46 ##################################
48 # make options
49 SHELL = /bin/sh
50 OBJDIR = obj/$(PLATFORM)/$(BUILD)
51 BINDIR = bin/$(PLATFORM)/$(BUILD)
52 DEPDIR = dep/$(PLATFORM)/$(BUILD)
54 # Get flags/libs for GTK builds
55 ifeq ($(PLATFORM),gtk20)
56 MAKE = make
57 SharedCXXFLAGS = `wx-config --cxxflags` `pkg-config --cflags gtk+-2.0`
58 SharedCPPFLAGS = `wx-config --cppflags`
59 libs = `wx-config --libs` `pkg-config --libs gtk+-2.0`
60 mkdircmd = mkdir -p
61 endif
63 # C++ options
64 CXX = g++
65 ifeq ($(BUILD),release)
66 CXXFLAGS = -Wall -s -O2 $(SharedCXXFLAGS)
67 CPPFLAGS = $(SharedCPPFLAGS)
68 endif
69 ifeq ($(BUILD),debug)
70 CXXFLAGS = -Wall -g $(SharedCXXFLAGS)
71 CPPFLAGS = -DDEBUG $(SharedCPPFLAGS)
72 endif
73 ifeq ($(BUILD),profile)
74 # Profiling mode: DEBUG flags, plus -pg, but without -DDEBUG
75 CXXFLAGS = -Wall -g $(SharedCXXFLAGS) -pg
76 CPPFLAGS = $(SharedCPPFLAGS)
77 endif
79 sources = $(shell ls -t *.cpp) # Compile most recently edited files first.
81 # Build object configuration
82 ifeq ($(PLATFORM),windows)
83 objects = $(sources:%.cpp=$(OBJDIR)/%.o) $(OBJDIR)/jben.res
84 target = $(BINDIR)/jben.exe
85 else
86 objects = $(sources:%.cpp=$(OBJDIR)/%.o)
87 target = $(BINDIR)/jben
88 endif
90 # Select build environment type
91 ifeq ($(CANUCK),1)
92 buildenv = posix
93 else
95 ifeq ($(PLATFORM),windows)
96 buildenv = windows
97 else
98 buildenv = posix
99 endif
101 endif
103 ### Targets ###
105 all: $(target) kpengine
107 .PHONY : kpengine clean cleandep cleanall
109 $(target) : $(objects)
110 $(mkdircmd) $(BINDIR)
111 $(CXX) $(CXXFLAGS) -o $(target) $(objects) $(libs)
114 $(OBJDIR)/jben.res:
115 $(mkdircmd) $(OBJDIR)
116 windres.exe -i jben.rc -J rc -o $(OBJDIR)/jben.res -O coff -I$(wxinclude) -I$(wxlibinc) -I$(mingwbase)/include
118 kpengine:
119 cd kanjipad && $(MAKE) && cd ..
121 clean:
122 cd kanjipad && make clean && cd ..
123 rm -rfv bin obj jben.res
125 cleandep:
126 rm -rfv dep
128 cleanall : clean cleandep
130 $(OBJDIR)/%.o : %.cpp
131 $(mkdircmd) $(OBJDIR)
132 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $(@F:%.o=%.cpp)
134 # Object dependency tracking
135 include $(sources:%.cpp=$(DEPDIR)/%.d)
136 $(DEPDIR)/%.d : %.cpp
137 @echo Recreating $@...
138 @$(mkdircmd) $(DEPDIR)
139 @$(CXX) -MM $(CPPFLAGS) $< > $@.mktmp
140 ifeq ($(buildenv),windows)
141 @sed "s,\($*\)\.o[ :]*,$(OBJDIR)/\1.o $@ : ,g" < $@.mktmp > $@
142 else
143 # @sed 's,\($*\)\.o[ :]*,$(OBJDIR)/\1.o $@ : $(OBJDIR) ,g' < $@.mktmp > $@
144 @sed 's,\($*\)\.o[ :]*,$(OBJDIR)/\1.o $@ : ,g' < $@.mktmp > $@
145 endif
146 @rm $@.mktmp