Debian Codegraph @

Makefile.cross_mingw32

raw
1 #!/usr/bin/make -f
2 # -*- Makefile -*-
3 #
4 # This makefile was initially created by Michael Hanke
5 # <[email protected]> to cross compile the nifticlibs for win32 on a
6 # Debian system -- although it should work on most Linux systems with possibly
7 # minor modifications. The whole process should become a lot easier once
8 # CMake 2.6 with cross-compiler toolchain support is released.
9 #
10 # Like the other parts of this package, this code is placed into the public
11 # domain.
12 #
13 # The 'devpak' target generates a DevPak suiteable for Dev-Cpp, see:
14 # http://www.bloodshed.net/devcpp.html
15 #
16 # Requirements:
17 # - cross-compiler environment (on Debian simply: apt-get install mingw32)
18 # - recent CMake (tested with 2.4)
19 # - cross-compiled zlib installed below $mingw_root_path. The easiest way to
20 # achieve this is using the zlib package provided by the gnuwin32 project:
21 # http://gnuwin32.sourceforge.net/
22 #
23 # Usage:
24 # Enter the root of the nifticlibs package and execute
25 #
26 # make -f Makefile.cross_mingw32
27 #
28 # now the generated DevPak should be located in the toplevel directory. This
29 # can be installed using the Package manager of Dev-Cpp under Windows.
30 #
31
32
33 # default settings
34 build_dir = mingw32_cross
35 devpak_dir = mingw32_devpak
36
37 # where all the cross-compiled libs and binaries are installed
38 mingw_root_path = /usr/local/mingw32
39 # where the cross-compiler itself is installed
40 mingw_bin_path = /usr/bin
41 # the common filename prefix of all cross-compiler binaries
42 mingw_bin_prefix = i586-mingw32msvc
43 # don't touch this one, unless you know what you are doing
44 mingw_bin = $(mingw_bin_path)/$(mingw_bin_prefix)
45
46 # extract the most recent version from the README file
47 nifti_version = $$(grep Version README | head -n1 | awk '{ print $$2 }')
48
49 # compile CMake flags.
50 cmake_flags = -DCMAKE_SYSTEM_NAME=Windows \
51 -DCMAKE_AR=$(mingw_bin)-ar \
52 -DCMAKE_RANLIB=$(mingw_bin)-ranlib \
53 -DCMAKE_C_COMPILER=$(mingw_bin)-gcc \
54 -DCMAKE_CXX_COMPILER=$(mingw_bin)-g++ \
55 -DCMAKE_C_FLAGS="-I$(mingw_root_path)/include -L$(mingw_root_path)/lib -DWIN32"
56
57
58 all: devpak
59
60
61 clean:
62 -rm -rf $(build_dir)
63 -rm build-devpak configure-devpak
64
65 distclean: clean
66 -rm -rf $(devpak_dir)
67
68 configure-devpak:
69 if [ ! -d $(build_dir) ]; then mkdir $(build_dir); fi
70 cd $(build_dir) && cmake .. $(cmake_flags) -DCMAKE_INSTALL_PREFIX=/$(devpak_dir)
71 touch $@
72
73 build-devpak: configure-devpak
74 cd $(build_dir) && make VERBOSE=1
75 touch $@
76
77 install-devpak: build-devpak
78 if [ ! -d $(devpak_dir) ]; then mkdir $(devpak_dir); fi
79 cd $(build_dir) && make install DESTDIR=../
80
81 devpak: install-devpak
82 # nifti_tool header is unecessary
83 rm $(devpak_dir)/include/nifti/nifti_tool.h
84
85 # generate devpak info file
86 sed -e s/__full_version__/$(nifti_version)/g \
87 -e s/__major_version__/$(nifti_version)/g \
88 < packaging/DevPackage.template > $(devpak_dir)/nifticlib.DevPackage
89
90 # include license and readme
91 cp LICENSE README $(devpak_dir)
92
93 # compress
94 cd $(devpak_dir) && tar cvjf ../nifticlib-$(nifti_version).DevPak *