-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile.gmk
110 lines (92 loc) · 2.72 KB
/
Makefile.gmk
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
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Compile native Windows binary using mingw64
# make -f Makefile.gmk
#
# To compile from Cygwin environment
# make -f Makefile.gmk USE_MINGW_PACKAGE_PREFIX=1
#
# the following packages need to be installed:
#
# mingw64-x86_64-binutils,
# mingw64-x86_64-gcc-core,
# mingw64-x86_64-headers,
# mingw64-x86_64-runtime
#
ifdef USE_MINGW_PACKAGE_PREFIX
CC = x86_64-w64-mingw32-gcc
RC = x86_64-w64-mingw32-windres
RL = x86_64-w64-mingw32-strip
else
CC = gcc
RC = windres
RL = strip
endif
LN = $(CC)
SRCDIR = .
PROJECT = svcbatch
TARGET = $(PROJECT).exe
WORKTOP = $(SRCDIR)/build
ifdef DEBUG_BUILD
WORKDIR = $(WORKTOP)/dbg.gcc
else
WORKDIR = $(WORKTOP)/rel.gcc
endif
POUTPUT = $(WORKDIR)/$(TARGET)
WINVER = 0x0601
ifdef DEBUG_BUILD
CFLAGS = -D_DEBUG -DDEBUG
RFLAGS = -D DEBUG -D _DEBUG
RL = @true
else
CFLAGS = -DNDEBUG
RFLAGS = -D NDEBUG
endif
CFLAGS += -D_WIN32_WINNT=$(WINVER) -DWINVER=$(WINVER) -DWIN32_LEAN_AND_MEAN \
-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE \
-DUNICODE -D_UNICODE
LNOPTS = -m64 -O2 -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-stringop-overflow -municode -mconsole
RCOPTS = -l 0x409 -F pe-x86-64 -O coff
RFLAGS += -D _WIN32_WINNT=$(WINVER) -D WINVER=$(WINVER)
CLOPTS = $(LNOPTS) -c
LDLIBS = -lkernel32 -ladvapi32 -lbcrypt
RLOPTS = --strip-unneeded
ifdef VERSION_SFX
CFLAGS += -DVERSION_SFX=$(VERSION_SFX)
RFLAGS += -D VERSION_SFX=$(VERSION_SFX)
endif
ifdef DEBUG_TRACE
CFLAGS += -DDEBUG_TRACE
endif
OBJECTS = \
$(WORKDIR)/$(PROJECT).o \
$(WORKDIR)/$(PROJECT).res
all : $(WORKDIR) $(POUTPUT)
@:
$(WORKDIR):
@mkdir -p $@
$(WORKDIR)/%.o: $(SRCDIR)/%.c $(SRCDIR)/%.h
$(CC) $(CLOPTS) -o $@ $(CFLAGS) $<
$(WORKDIR)/%.res: $(SRCDIR)/%.rc $(SRCDIR)/%.h
$(RC) $(RCOPTS) -o $@ $(RFLAGS) $<
$(POUTPUT): $(WORKDIR) $(OBJECTS)
$(LN) $(LNOPTS) -o $@ $(OBJECTS) $(LDLIBS)
$(RL) $(RLOPTS) $@
clean:
@rm -rf $(WORKDIR)
distclean:
@rm -rf $(WORKTOP)
.PHONY: all clean distclean