forked from dkfans/peresec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
144 lines (124 loc) · 3.86 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
#******************************************************************************
# PE/DLL Rebuilder of Export Section
#******************************************************************************
# @file Makefile
# A script used by GNU Make to recompile the project.
# @par Purpose:
# Allows to invoke "make all" or similar commands to compile all
# source code files and link them into executable file.
# @par Comment:
# None.
# @author Tomasz Lis
# @date 25 Jan 2009 - 19 Jan 2010
# @par Copying and copyrights:
# 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.
#
#******************************************************************************
ifneq (,$(findstring Windows,$(OS)))
RES = obj/peresec_stdres.res
EXEEXT = .exe
PKGFMT = zip
PKGOS = win
else
RES =
EXEEXT =
PKGFMT = tar.gz
PKGOS = lin
endif
CPP = g++
CC = gcc
WINDRES = windres
DLLTOOL = dlltool
RM = rm -f
MV = mv -f
CP = cp -f
MKDIR = mkdir -p
ECHO = @echo
TAR = tar
ZIP = zip
BIN = bin/peresec$(EXEEXT)
LIBS =
OBJS = \
obj/peresec.o \
$(RES)
GENSRC = obj/ver_defs.h
LINKOBJ = $(OBJS)
LINKLIB =
INCS =
CXXINCS =
# flags to generate dependency files
DEPFLAGS = -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
# code optimization flags
OPTFLAGS = -O3
DBGFLAGS =
# linker flags
LINKFLAGS =
# compiler warning generation flags
WARNFLAGS = -Wall -Wno-sign-compare -Wno-unused-parameter
# disabled warnings: -Wextra -Wtype-limits
CXXFLAGS = $(CXXINCS) -c -fmessage-length=0 $(WARNFLAGS) $(DEPFLAGS) $(OPTFLAGS)
CFLAGS = $(INCS) -c -fmessage-length=0 $(WARNFLAGS) $(DEPFLAGS) $(OPTFLAGS)
LDFLAGS = $(LINKLIB) $(OPTFLAGS) $(DBGFLAGS) $(LINKFLAGS)
# load program version
include version.mk
VER_STRING = $(VER_MAJOR).$(VER_MINOR).$(VER_RELEASE).$(VER_BUILD)
.PHONY: all all-before all-after clean clean-custom package pkg-before zip tar.gz
all: all-before $(BIN) all-after
all-before:
$(MKDIR) obj bin
clean: clean-custom
-${RM} $(OBJS) $(GENSRC) $(BIN) $(LIBS)
-${RM} pkg/*
-$(ECHO) ' '
$(BIN): $(OBJS) $(LIBS)
-$(ECHO) 'Building target: $@'
$(CPP) $(LINKOBJ) -o "$@" $(LDFLAGS)
-$(ECHO) 'Finished building target: $@'
-$(ECHO) ' '
obj/%.o: src/%.cpp $(GENSRC)
-$(ECHO) 'Building file: $<'
$(CPP) $(CXXFLAGS) -o"$@" "$<"
-$(ECHO) 'Finished building: $<'
-$(ECHO) ' '
obj/%.o: src/%.c $(GENSRC)
-$(ECHO) 'Building file: $<'
$(CC) $(CFLAGS) -o"$@" "$<"
-$(ECHO) 'Finished building: $<'
-$(ECHO) ' '
obj/%.res: res/%.rc $(GENSRC)
-$(ECHO) 'Building resource: $<'
$(WINDRES) -i "$<" --input-format=rc -o "$@" -O coff
-$(ECHO) 'Finished building: $<'
-$(ECHO) ' '
obj/ver_defs.h: version.mk Makefile
$(ECHO) \#define VER_MAJOR $(VER_MAJOR) > "$(@D)/tmp"
$(ECHO) \#define VER_MINOR $(VER_MINOR) >> "$(@D)/tmp"
$(ECHO) \#define VER_RELEASE $(VER_RELEASE) >> "$(@D)/tmp"
$(ECHO) \#define VER_BUILD $(VER_BUILD) >> "$(@D)/tmp"
$(ECHO) \#define VER_STRING \"$(VER_STRING)\" >> "$(@D)/tmp"
$(ECHO) \#define PACKAGE_SUFFIX \"$(PACKAGE_SUFFIX)\" >> "$(@D)/tmp"
$(MV) "$(@D)/tmp" "$@"
package: pkg-before $(PKGFMT)
pkg-before:
-${RM} pkg/*
$(MKDIR) pkg
$(CP) bin/* pkg/
$(CP) docs/*_readme.txt pkg/
pkg/%.tar.gz: pkg-before
-$(ECHO) 'Creating package: $<'
cd $(@D); \
$(TAR) --exclude=*.tar.gz --exclude=*.zip -zcf "$(@F)" .
-$(ECHO) 'Finished creating: $<'
-$(ECHO) ' '
tar.gz: pkg/peresec-$(subst .,_,$(VER_STRING))-$(PACKAGE_SUFFIX)-$(PKGOS).tar.gz
pkg/%.zip: pkg-before
-$(ECHO) 'Creating package: $<'
cd $(@D); \
$(ZIP) -x*.tar.gz -x*.zip -9 -r "$(@F)" .
-$(ECHO) 'Finished creating: $<'
-$(ECHO) ' '
zip: pkg/peresec-$(subst .,_,$(VER_STRING))-$(PACKAGE_SUFFIX)-$(PKGOS).zip
#******************************************************************************