1 # J-Ben Makefile for Linux and Windows
2 # Note: Windows builds expect MinGW, GNUWin32 CoreUtils, and NSIS
3 # binaries in your path!
5 ### User-editable options ###
6 # PLATFORM: either windows or gtk20
8 # BUILD: either release, debug, or profile
10 # JBEN_VERSION: Used for labeling release packages
14 ifeq ($(PLATFORM
),windows
)
15 # CHANGE THESE 4 VARIABLES
18 boostbase
= C
:/dev
/boost_1_34_1
19 wxbase
= C
:/dev
/wxMSW-2.8
.7
20 wxbuildflags
= -DWXUSINGDLL
-DwxUSE_UNICODE
21 stlportbase
= C
:/dev
/STLport-5.1
.5
22 iconvbase
= C
:/dev
/libiconv
23 mkdircmd
= C
:/progra~
1/gnuwin32
/bin
/mkdir
-p
24 # NOTE: wxWidgets is assumed to be built with wxUSINGDLL and wxUSE_UNICODE.
25 # Also, I'm currently using a release build of wxWidgets regardless of
26 # whether a debug or release build is chosen. I may change this later.
28 # The following variables probably should NOT be changed.
29 wxplatformflags
= -D__GNUWIN32__
-D__WXMSW__
30 # STLPort specifies -pthreads - does -mthreads work fine for this???
31 wincxxflags
= -pipe
-mthreads
32 winlinkflags
= -mwindows
34 wxinclude
= $(wxbase
)/include
35 wxcontribinc
= $(wxbase
)/contrib
/include
36 wxlibinc
= $(wxbase
)/lib
/gcc_dll
/mswu
38 wxliblink
= $(wxbase
)/lib
/gcc_dll
39 SharedCXXFLAGS
= $(wincxxflags
)
41 ifeq ($(BUILD
),release
)
47 SharedCPPFLAGS
= $(winextraflags
) -I
$(stlportbase
)/stlport
$(wxbuildflags
) \
48 $(wxplatformflags
) -I
$(wxinclude
) -I
$(wxcontribinc
) -I
$(wxlibinc
) \
49 -I
$(boostbase
) -I
$(mingwbase
)/include -I
$(iconvbase
)/include
50 libs
= -L
$(stlportbase
)/lib
-L
$(wxliblink
) -L
$(mingwbase
)/lib \
51 -L
$(iconvbase
)/lib
-lwxmsw28u_html
-lwxmsw28u_core
-lwxbase28u \
52 $(winlinkflags
) -liconv
-lstlport
.5.1.dll
55 ##################################
56 # DO NOT EDIT BEYOND THIS POINT! #
57 ##################################
62 INSTALL_PROGRAM
= $(INSTALL
)
63 INSTALL_DATA
= $(INSTALL
) -m
644
64 # From GNU Make manual, section 14.4: Variables for Installation Directories
66 exec_prefix = $(prefix)
67 bindir = $(exec_prefix)/bin
68 datarootdir
= $(prefix)/share
69 datadir = $(datarootdir
)
70 docdir
= $(datarootdir
)/doc
/jben
71 # I don't have a man page written yet, but I'll define the vars anyway.
72 mandir = $(datarootdir
)/man
73 man1dir = $(mandir)/man1
76 build_depdir
= dep
/$(PLATFORM
)/$(BUILD
)
77 build_objdir
= obj
/$(PLATFORM
)/$(BUILD
)
78 build_bindir
= bin
/$(PLATFORM
)/$(BUILD
)
81 # Get flags/libs for GTK builds
82 ifeq ($(PLATFORM
),gtk20
)
84 SharedCXXFLAGS
= `wx-config --cxxflags` `pkg-config --cflags gtk+-2.0 libxml-2.0`
85 SharedCPPFLAGS
= `wx-config --cppflags` -DJB_DATADIR
=\"$(datadir)/jben
\" \
86 -DDOCDIR
=\"$(docdir
)/doc
\" -DLICENSEDIR
=\"$(docdir
)/license
\"
87 libs
= `wx-config --libs` `pkg-config --libs gtk+-2.0 libxml-2.0`
93 ifeq ($(BUILD
),release
)
94 CXXFLAGS
= -Wall
-O2
$(SharedCXXFLAGS
)
95 CPPFLAGS
= $(SharedCPPFLAGS
)
98 CXXFLAGS
= -Wall
-g
$(SharedCXXFLAGS
)
99 CPPFLAGS
= -DDEBUG
$(SharedCPPFLAGS
)
101 ifeq ($(BUILD
),profile
)
102 # Profiling mode: DEBUG flags, plus -pg, but without -DDEBUG
103 CXXFLAGS
= -Wall
-g
$(SharedCXXFLAGS
) -pg
104 CPPFLAGS
= $(SharedCPPFLAGS
)
107 sources
= $(shell ls
-t
*.
cpp) # Compile most recently edited files first.
109 # Build object configuration
110 ifeq ($(PLATFORM
),windows
)
111 objects
= $(sources
:%.
cpp=$(build_objdir
)/%.o
) $(build_objdir
)/jben.res
114 objects
= $(sources
:%.
cpp=$(build_objdir
)/%.o
)
118 # Select build environment type
123 ifeq ($(PLATFORM
),windows
)
133 all: $(build_bindir
)/$(target
) kpengine
134 ifeq ($(PLATFORM
),windows
)
135 @echo J-Ben was built successfully.
138 @echo
"J-Ben was built successfully."
139 @echo
"To install, use \"make install\" with the same options used to compile the"
143 .PHONY
: kpengine
clean cleandep cleanall
install uninstall
145 $(build_bindir
)/$(target
) : $(objects
)
146 $(mkdircmd
) $(build_bindir
)
147 $(CXX
) -o
$(build_bindir
)/$(target
) $(objects
) $(libs
) $(CXXFLAGS
)
150 $(build_objdir
)/jben.res
:
151 $(mkdircmd
) $(build_objdir
)
152 windres.exe
-i jben.rc
-J rc
-o
$(build_objdir
)/jben.res
-O coff
-I
$(wxinclude
) -I
$(wxlibinc
) -I
$(mingwbase
)/include
155 cd kanjipad
&& $(MAKE
) BUILD
=$(BUILD
) PLATFORM
=$(PLATFORM
) && cd ..
158 cd kanjipad
&& make
clean && cd ..
159 rm -rfv bin obj jben.res
164 cleanall
: clean cleandep
166 $(build_objdir
)/%.o
: %.
cpp
167 $(mkdircmd
) $(build_objdir
)
168 # Working Linux build command
169 # $(CXX) $(CPPFLAGS) -c -o $@ $(@F:%.o=%.cpp) $(CXXFLAGS)
170 # Testing Windows build command
171 $(CXX
) $(CXXFLAGS
) $(CPPFLAGS
) -c
-o
$@
$(@F
:%.o
=%.
cpp)
173 # Object dependency tracking
174 include $(sources
:%.
cpp=$(build_depdir
)/%.d
)
175 $(build_depdir
)/%.d
: %.
cpp
176 @echo Recreating
$@...
177 @
$(mkdircmd
) $(build_depdir
)
178 @
$(CXX
) -MM
$(CPPFLAGS
) $< > $@.mktmp
179 ifeq ($(buildenv
),windows
)
180 @sed
"s,\($*\)\.o[ :]*,$(build_objdir)/\1.o $@ : ,g" < $@.mktmp
> $@
182 @sed
's,\($*\)\.o[ :]*,$(build_objdir)/\1.o $@ : ,g' < $@.mktmp
> $@
187 ifeq ($(PLATFORM
),windows
)
188 # On Windows, "make install" makes the J-Ben NSIS installer.
189 # Step 1: Prep the output directory
191 cp
"$(stlportbase)/bin/libstlport.5.1.dll" J-Ben
192 cp
"$(mingwbase)/bin/mingwm10.dll" J-Ben
193 cp
"$(wxliblink)/wxbase28u_gcc_vultaire.net.dll" J-Ben
194 cp
"$(wxliblink)/wxmsw28u_core_gcc_vultaire.net.dll" J-Ben
195 cp
"$(wxliblink)/wxmsw28u_html_gcc_vultaire.net.dll" J-Ben
196 cp
"$(iconvbase)/bin/libcharset1.dll" J-Ben
197 cp
"$(iconvbase)/bin/libiconv2.dll" J-Ben
199 cp CHANGELOG.txt J-Ben
200 cp
"$(build_bindir)/$(target)" J-Ben
201 cp
"kanjipad/$(build_bindir)/jben_kpengine.exe" J-Ben
203 $(mkdircmd
) J-Ben
/kpengine_data J-Ben
/dicts J-Ben
/sods
204 cp kanjipad
/*.unistrok J-Ben
/kpengine_data
205 cp dicts
/edict2 dicts
/kanjidic dicts
/radkfile \
206 dicts
/kradfile dicts
/README.txt J-Ben
/dicts
207 cp sods
/README.txt J-Ben
/sods
208 @echo J-Ben distribution created in .\J-Ben.
209 # Step 2: Run NSIS script
210 makensis
/Dversion
=$(JBEN_VERSION
) installer.nsi
211 # Step 3: Zip the output folder into 7z and zip archives
212 7z a
-tzip jben-
$(JBEN_VERSION
)-win-binary.zip J-Ben
213 7z a
-t7z jben-
$(JBEN_VERSION
)-win-binary
.7z J-Ben
214 # Step 4: Remove the output folder
217 $(INSTALL
) -d
$(bindir) $(datadir)/jben
/dicts
$(datadir)/jben
/sods \
219 $(INSTALL_PROGRAM
) $(build_bindir
)/$(target
) $(bindir)
220 $(INSTALL_DATA
) dicts
/* $(datadir)/jben
/dicts
221 $(INSTALL_DATA
) sods
/README.txt
$(datadir)/jben
/sods
222 $(INSTALL_DATA
) license
/* $(docdir
)/license
223 # Install man page: $(INSTALL_DATA) <manpage> $(man1dir)
225 && $(MAKE
) BUILD
=$(BUILD
) PLATFORM
=$(PLATFORM
) install \
228 @echo
"J-Ben was installed successfully."
232 ifeq ($(PLATFORM
),windows
)
233 @echo
"make uninstall" is not supported on Windows.
236 && $(MAKE
) BUILD
=$(BUILD
) PLATFORM
=$(PLATFORM
) uninstall \
238 rm -fv
$(bindir)/$(target
)
239 rm -fv
$(datadir)/jben
/dicts
/*
240 rm -fv
$(datadir)/jben
/sods
/README.txt
241 rm -fv
$(docdir
)/license
/*
242 # rm -fv $(man1dir)/<manpage>
243 rmdir
-p
$(datadir)/jben
/dicts || true
244 rmdir
-p
$(datadir)/jben
/sods || true
245 rmdir
-p
$(docdir
)/license || true
247 @echo
"J-Ben was uninstalled successfully."