1 # J-Ben Makefile for Windows
2 # WARNING: Not for the faint of heart. Really, just download a precompiled
3 # binary if at all possible.
5 # Windows builds expect MinGW WITH MSys,
6 # a -not broken- gcc 4 compiler (for wstrings) (4.3.0 alpha does NOT work!),
7 # plus 7-Zip, NSIS and GTK binaries in your path for "make install".
8 # PKG_CONFIG_PATH must also be set appropriately.
10 # === NOTES FOR SUCCESSFUL BUILDING ===
12 # LAST SUCCESSFUL BUILD used:
14 # * MinGW-5.1.4.exe (automated installer), using current release install,
15 # minimum plus g++ install
16 # * update: gcc-{core,g++}-4.2.1-sjlj-2.tar.gz
17 # (updated GCC with wstrings and TR1 hash maps)
18 # ***IMPORTANT***: Compiled all code using "export CC=gcc-sjlj CXX=g++-sjlj".
19 # (Otherwise, the regular 3.x gcc would be used.)
21 # * Install MSYS-1.0.10.exe, then add in msysCORE-1.0.11-20080826.tar.gz.
22 # If you don't do this, then once you reach pangomm you'll have configure
24 # GTK+ package: gtk-2.14.1 all-in-one development bundle
25 # * Need to add the bin folder to your PATH, so pkg-config will work right!
26 # GTKmm-related packages
32 # (Built from source, -in the above order-. Refer to
33 # http://live.gnome.org/gtkmm/MSWindows/BuildingGtkmm for full details.
34 # Again, remember to "export CC=gcc-sjlj CXX=g++-sjlj" before building!)
35 # Boost: boost_1_37_0.7z
36 # * The Boost::Regex library must be built. See the note below.
37 # libxml2: libxml2-2.7.2.win32.zip
38 # libiconv: iconv-1.9.2-1-bin.zip and iconv-1.9.2-1-lib.zip
39 # (Extract to the same folder)
40 # zlib: zlib123-dll.zip
41 # Note: Ignore the part of the USAGE.txt file saying to rename the
42 # library. In this makefile, it shouldn't be necessary.
44 # Sources for these files:
45 # http://mingw.sourceforge.net/: MinGW homepage (MSys is here, too)
46 # http://www.gtk.org/: gtk+ all-in-one dev package
47 # http://www.gtkmm.org/: gtkmm source code
48 # http://www.boost.org/: Boost libraries
49 # http://www.zlatkovic.com/libxml.en.html: libxml2 for Windows
50 # http://gnuwin32.sourceforge.net/packages/libiconv.htm: libiconv for Windows
51 # http://www.zlib.net/: zlib library; look for "zlib compiled DLL"
53 # Building Boost::Regex:
54 # * If you have TMP or TEMP environmental variables with spaces in them
55 # (especially if they're for your specific user account), change them to
56 # something without spaces or you will encounter mysterious errors. :)
57 # * Get a bjam binary from http://sourceforge.net/projects/boost/
58 # * Add bjam.exe to your path
59 # * Open MSys and cd to the boost root folder
60 # * Run: bjam --build-dir=<build_dir> --toolset=gcc --build-type=complete stage
61 # (replacing <build_dir> with an output directory, obviously.)
62 # This procedure will take a LONG time, maybe over an hour.
63 # For more complete documentation, see the Boost "Getting Started on Windows"
64 # page in the official Boost documentation.
68 # On library/GUI split, these things will (eventually) need to be taken care of:
69 # 1. gettext: handled by GTKmm's i18n package, but will need to be handled
70 # manually when the core is separated into a dll.
73 # PKG_CONFIG_PATH must be set properly. Include both GTK's and libxml's
74 # pkgconfig files in the path.
75 # (Example: export PKG_CONFIG_PATH=/local/lib/pkgconfig:/c/devel/libxml2-2.7.2.win32/lib/pkgconfig)
77 # COMMAND TO EXECUTE BUILD: make -f Makefile.win CC=gcc-sjlj CXX=g++-sjlj
78 # (If CC/CXX are not explicitly specified like this, then don't expect to get
81 # === MAKEFILE BEGINS HERE ===
83 ### User-editable options ###
84 # BUILD: either release, debug, or profile
86 # JBEN_VERSION: Used for labeling release packages
87 JBEN_VERSION = `cat version.h | grep VERSION_STR | sed -e 's/^[^"]*"\([^"]*\)"/\1/'`
88 # PLATFORM: Used as a subdirectory name.
91 #===CHANGE THESE VARIABLES===
98 # Library base directories
99 gtkbase = C:/devel/gtk-2.14.1
100 zlibbase = C:/devel/zlib123-dll
101 iconvbase = C:/devel/libiconv-1.9.2-1
102 boostbase = C:/devel/boost_1_37_0
103 xmlbase = C:/devel/libxml2-2.7.2.win32
105 # No libxml-2.0.pc is included with the official libxml2 port.
106 # Follow the procedure on
107 # http://www.go-evolution.org/Building_Evolution_on_Windows#libxml2
108 # for writing the file, plus for making a proper ".a" link lib.
110 # Direct lib paths (for non-gcc-style names)
111 libzlib = $(zlibbase)/lib/zdll.lib
112 #libxml = $(xmlbase)/lib/libxml2.lib
113 # The below should be a direct path to the boost::regex library.
114 # Note: There's release/debug versions, with multithreading, static runtime
115 # linking, both, and neither. Lots of options! I -think- runtime link
116 # static does static linking to the C library or something like that... so
117 # let's link just the multithreaded, no linked runtime version.
118 # (Decision based on reading thread at
119 # http://osdir.com/ml/lib.boost.build/2002-12/msg00062.html)
120 libboost_regex = C:/devel/boost_bin_1_37_0/boost/bin.v2/libs/regex/build/gcc-mingw-4.2.1/release/link-static/threading-multi/libboost_regex-mgw42-mt-1_37.lib
122 # The below variables point towards the path to a configured,
123 # redistributable GTK/GTKmm environment. It's used by the Windows
124 # "make install" target. If you need help setting this up, see this article:
125 # http://live.gnome.org/gtkmm/MSWindows
126 gtkredist = C:/gtk-redist
128 #===LEAVE THESE ALONE===
129 SharedCXXFLAGS = -I$(zlibbase)/include -I$(iconvbase)/include -I$(boostbase) -I$(gtkbase)/include `pkg-config --cflags gtkmm-2.4 libxml-2.0`
130 SharedCPPFLAGS = -D__WIN32__
131 libs = $(libzlib) -L$(iconvbase)/lib -liconv.dll $(libboost_regex) `pkg-config --libs gtkmm-2.4 libxml-2.0` -mwindows
132 ##########################################
133 # DO NOT EDIT BEYOND THIS POINT! #
134 # (Unless you know what you're doing ;)) #
135 ##########################################
140 INSTALL_PROGRAM = $(INSTALL)
141 INSTALL_DATA = $(INSTALL) -m 644
142 # From GNU Make manual, section 14.4: Variables for Installation Directories
144 exec_prefix = $(prefix)
145 bindir = $(exec_prefix)/bin
146 datarootdir = $(prefix)/share
147 datadir = $(datarootdir)
148 docdir = $(datarootdir)/doc/jben
149 # I don't have a man page written yet, but I'll define the vars anyway.
150 mandir = $(datarootdir)/man
151 man1dir = $(mandir)/man1
154 build_depdir = ../dep/$(PLATFORM)/$(BUILD)
155 build_objdir = ../obj/$(PLATFORM)/$(BUILD)
156 build_bindir = ../bin/$(PLATFORM)/$(BUILD)
159 ifeq ($(BUILD),release)
160 CXXFLAGS = -Wall -s -O2
161 CPPFLAGS = -DNDEBUG #Added, used by assert
163 ifeq ($(BUILD),debug)
167 #Profiling mode: DEBUG-style CXXFLAGS plus -pg, with RELEASE-style CPPFLAGS
168 ifeq ($(BUILD),profile)
169 CXXFLAGS = -Wall -g -pg
170 CPPFLAGS = -DNDEBUG #Added, used by assert
173 sources = $(shell ls -t *.cpp) # Compile most recently edited files first.
174 objects = $(sources:%.cpp=$(build_objdir)/%.o) $(build_objdir)/jben-rc.o
179 all: $(build_bindir)/$(target) kpengine
180 @echo J-Ben was built successfully.
182 .PHONY : kpengine clean cleandep cleanall installprep install uninstall doc
184 $(build_bindir)/$(target) : $(objects)
185 mkdir -p $(build_bindir)
186 $(CXX) $(CXXFLAGS) $(SharedCXXFLAGS) -o $@ $(objects) $(libs)
189 cd kpengine && $(MAKE) BUILD=$(BUILD) -f Makefile.win && cd ..
192 cd kpengine && $(MAKE) clean && cd ..
193 rm -rfv ../bin ../obj ../jben.res
198 cleanall : clean cleandep
200 $(build_objdir)/jben-rc.o:
201 mkdir -p $(build_objdir)
202 windres.exe -o $@ jben.rc
204 $(build_objdir)/%.o : %.cpp
205 mkdir -p $(build_objdir)
206 $(CXX) -c $(CPPFLAGS) $(SharedCPPFLAGS) $(CXXFLAGS) $(SharedCXXFLAGS) -o \
209 # Object dependency tracking
210 include $(sources:%.cpp=$(build_depdir)/%.d)
211 $(build_depdir)/%.d : %.cpp
212 @echo Recreating $@...
213 @mkdir -p $(build_depdir)
214 @$(CXX) -MM $(CPPFLAGS) $< > $@.mktmp
215 ifeq ($(buildenv),windows)
216 @sed "s,\($*\)\.o[ :]*,$(build_objdir)/\1.o $@ : ,g" < $@.mktmp > $@
218 @sed 's,\($*\)\.o[ :]*,$(build_objdir)/\1.o $@ : ,g' < $@.mktmp > $@
223 # Make a phony output folder with all redist files
226 cp -R $(gtkredist)/bin ../J-Ben
227 cp -R $(gtkredist)/etc ../J-Ben
228 cp -R $(gtkredist)/lib ../J-Ben
229 cp -R $(gtkredist)/share ../J-Ben
230 # Copy GNU iconv files
231 cp -R $(iconvbase)/bin/libiconv2.dll ../J-Ben/bin
232 # Copy J-Ben binaries and DLLs not in GTK redist folder
233 cp "$(mingwbase)/bin/mingwm10.dll" ../J-Ben/bin
234 cp "$(build_bindir)/$(target)" ../J-Ben/bin
235 cp "$(build_bindir)/kpengine/jben_kpengine.exe" ../J-Ben/bin
236 # Strip J-Ben executables
237 strip ../J-Ben/bin/$(target)
238 strip ../J-Ben/bin/jben_kpengine.exe
239 # Copy remaining J-Ben files (data, readmes, licenses, docs, etc.)
240 cp ../CHANGELOG ../COPYING ../CREDITS ../DEDICATION ../README ../TODO ../J-Ben
241 cp -R ../license ../J-Ben
242 mkdir -p ../J-Ben/kpengine_data ../J-Ben/dicts ../J-Ben/sods
243 cp kpengine/*.unistrok ../J-Ben/kpengine_data
245 cp -R ../doc/html ../J-Ben/doc || true
246 cp ../dicts/* ../J-Ben/dicts
247 cp ../sods/README ../J-Ben/sods
248 @echo J-Ben distribution created in ..\\J-Ben.
250 install : installprep
251 # Zip the output folder into 7z and zip archives
252 mkdir -p ../archives/$(JBEN_VERSION)
253 rm ../archives/$(JBEN_VERSION)/jben-$(JBEN_VERSION)-win-binary.zip || true
254 rm ../archives/$(JBEN_VERSION)/jben-$(JBEN_VERSION)-win-binary.7z || true
255 7z a -tzip ../archives/$(JBEN_VERSION)/jben-$(JBEN_VERSION)-win-binary.zip \
257 7z a -t7z ../archives/$(JBEN_VERSION)/jben-$(JBEN_VERSION)-win-binary.7z \
260 # Msys has issues with programs requiring "/" switches. So, makensis with a /D switch won't fly until I can find a workaround.
262 @echo To create an installer, open a normal command prompt, navigate to this
263 @echo directory, and type the following:
264 @echo makensis /Dversion=$(JBEN_VERSION) installer.nsi
265 @echo \(Afterwards, delete ..\J-Ben.\)
267 # makensis /Dversion=$(JBEN_VERSION) installer.nsi
268 ## Remove the output folder
272 @echo "make uninstall" is not supported on Windows.
275 @echo "make doc" is not supported on Windows.