-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
189 lines (169 loc) · 4.31 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#/* vim:set ts=2 nowrap: ****************************************************
#
# qutselect - A simple Qt-based GUI frontend for remote terminals
# Copyright (C) 2009-2015 Jens Maus <mail@jens-maus.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#
#**************************************************************************/
#
# Top-level makefile for creating the proper 'build' directory tree
# and running the proper cmake command within
#
# Example:
#
# # to explicitly compile for Windows-64bit
# > make OS=w64
#
# # to compile for Linux-64bit but without debugging
# > make OS=l32 DEBUG=
#
#############################################
# find out the HOST operating system
# on which this makefile is run
HOST ?= $(shell uname)
CPU ?= $(shell uname -m)
# if no host is identifed (no uname tool)
# we assume a Linux-64bit build
ifeq ($(HOST),)
HOST = Linux
endif
# identify CPU
ifeq ($(CPU), x86_64)
HOST := $(HOST)64
else
ifeq ($(CPU), i686)
HOST := $(HOST)32
endif
endif
#############################################
# now we find out the target OS for
# which we are going to compile in case
# the caller didn't yet define OS himself
ifndef (OS)
ifeq ($(HOST), Linux64)
OS = l64
else
ifeq ($(HOST), Linux32)
OS = l32
else
ifeq ($(HOST), Windows64)
OS = w64
else
ifeq ($(HOST), Windows32)
OS = w32
else
ifeq ($(HOST), Darwin64)
OS = m64
else
ifeq ($(HOST), Darwin32)
OS = m32
endif
endif
endif
endif
endif
endif
endif
#############################################
# define common commands we use in this
# makefile. Please note that each of them
# might be overridden on the commandline.
# common commands
MAKE = make
CMAKE = cmake
RM = rm -f
RMDIR = rm -rf
MKDIR = mkdir -p
# Common Directories
PREFIX = ./
BUILDDIR = $(PREFIX)build-$(OS)
MXEDIR = /usr/local/mxe
#############################################
# lets identify if we are going to cross
# compile and if so we add some options to
# the cmake call
ifeq ($(OS), w64)
##############################
# Windows 64-bit static
ifneq ($(HOST), Windows64)
TARGET_PATH = $(MXEDIR)/usr/x86_64-w64-mingw32.shared
endif
endif
ifeq ($(OS), w64s)
##############################
# Windows 64-bit static
ifneq ($(HOST), Windows64)
TARGET_PATH = $(MXEDIR)/usr/x86_64-w64-mingw32.static
endif
endif
ifeq ($(OS), w32)
##############################
# Windows 32-bit static
ifneq ($(HOST), Windows64)
TARGET_PATH = $(MXEDIR)/usr/i686-w64-mingw32.shared
endif
endif
ifeq ($(OS), w32s)
##############################
# Windows 32-bit static
ifneq ($(HOST), Windows64)
TARGET_PATH = $(MXEDIR)/usr/i686-w64-mingw32.static
endif
endif
# depending on TARGET_PATH we enable cross compiling
# for cmake or not
ifneq ($(TARGET_PATH),)
CMAKE_OPTIONS := -DCMAKE_TOOLCHAIN_FILE=$(TARGET_PATH)/share/cmake/mxe-conf.cmake -DCROSS_OS=$(OS)
endif
###################
# main target
.PHONY: all
all: $(BUILDDIR) $(BUILDDIR)/Makefile build
# make the object directories
.NOTPARALLEL: $(BUILDDIR)
$(BUILDDIR):
@echo " MKDIR $@"
@$(MKDIR) $(BUILDDIR)
.NOTPARALLEL: $(BUILDDIR)/Makefile
$(BUILDDIR)/Makefile:
@echo " CMAKE $@"
@(cd $(BUILDDIR) ; $(CMAKE) $(CMAKE_OPTIONS) ..)
.PHONY: build
.NOTPARALLEL: build
build:
@echo " MAKE $(BUILDDIR)"
@$(MAKE) -C $(BUILDDIR)
.PHONY: install
.NOTPARALLEL: install
install:
@echo " INSTALL $(BUILDDIR)"
@$(MAKE) -C $(BUILDDIR) install
# cleanup target
.PHONY: clean
clean:
@echo " CLEAN"
@$(MAKE) -C $(BUILDDIR) clean
.PHONY: cleanall
cleanall:
@echo " CLEANALL"
@$(RMDIR) $(BUILDDIR)/*
# clean all stuff, including our autotools
.PHONY: distclean
distclean:
@echo " DISTCLEAN"
@$(RMDIR) $(PREFIX)build-*