-
Notifications
You must be signed in to change notification settings - Fork 50
/
Makefile.mingw
136 lines (99 loc) · 3.49 KB
/
Makefile.mingw
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
# MinGW makefile for FreeImage
# This file can be generated by ./gensrclist.sh
include Makefile.srcs
# General configuration variables.
DESTDIR ?= $(SystemRoot)
INSTALLDIR ?= $(DESTDIR)/system32
DISTDIR ?= Dist
SRCDIR ?= Source
HEADER = FreeImage.h
RCFILE = FreeImage.rc
# Uncomment this variable to make a static library. This may
# also be specified as an environment variable and can hold
# any of STATIC and SHARED and must be in uppercase letters.
# Default: SHARED
#FREEIMAGE_LIBRARY_TYPE = STATIC
# Redefine the compiler (CC defaults to ´cc´ for MinGW's make,
# however there's only ´gcc´ available with MinGW).
CC = gcc
# Redefine the linker (we use ´g++´ for linking, since MinGW's
# command ´ld´ comes with wrong (Linux) standard library search
# paths).
LD = g++
#Define the ´dlltool´ command.
DLLTOOL = dlltool
#Define the resource compiler.
RC = windres
# Define the ´copy´ command.
CP = cp
# Define the ´mkdir´ command.
MD = mkdir
# Define the ´remove´ command.
RM = rm
# Define additional libraries needed.
# libstdc++ is included by default with MinGW, however for
# WIN32 based builds, LibRawLite needs the winsock libraries.
LIBRARIES = -lws2_32
# Define some additional symboles needed for WIN32 based builds.
WIN32_CFLAGS = -DWINVER=0x0500 $(LIB_TYPE_FLAGS) -DOPJ_STATIC
WIN32_CXXFLAGS = $(WIN32_CFLAGS) -DLIBRAW_NODLL
# Workaround for LibRawLite, which does not include C++ header
# file stdexcept, which is casually included with MSVC but not
# with MinGW. This can be removed after LibRawLite got control
# over its includes again.
WIN32_CXXFLAGS += -include stdexcept
# Define DLL image header information flags for the linker.
WIN32_LDFLAGS = -Wl,--subsystem,windows:5.0,--major-os-version,5
WIN32_STATIC_FLAGS = -DFREEIMAGE_LIB
WIN32_SHARED_FLAGS = -DFREEIMAGE_EXPORTS
MODULES = $(SRCS:.c=.o)
MODULES := $(MODULES:.cpp=.o)
RESOURCE = $(RCFILE:.rc=.coff)
CFLAGS ?= -O3 -fexceptions -DNDEBUG -DDISABLE_PERF_MEASUREMENT $(WIN32_CFLAGS)
CFLAGS += $(INCLUDE)
CXXFLAGS ?= -O3 -fexceptions -Wno-ctor-dtor-privacy -DNDEBUG $(WIN32_CXXFLAGS)
CXXFLAGS += $(INCLUDE)
RCFLAGS ?= -DNDEBUG
LDFLAGS ?= -s -shared -static -Wl,-soname,$(SOLIBNAME) $(WIN32_LDFLAGS)
DLLTOOLFLAGS ?= --add-stdcall-underscore
TARGET = FreeImage
STATICLIB = lib$(TARGET).a
SHAREDLIB = $(TARGET).dll
IMPORTLIB = $(TARGET).lib
EXPORTLIB = $(TARGET).exp
SOLIBNAME = $(SHAREDLIB).$(VER_MAJOR)
DISTSHARED = $(addprefix $(DISTDIR)/, $(SHAREDLIB) $(IMPORTLIB) $(HEADER))
DISTSTATIC = $(addprefix $(DISTDIR)/, $(STATICLIB) $(HEADER))
# The FreeImage library type defaults to SHARED.
FREEIMAGE_LIBRARY_TYPE ?= SHARED
TARGETLIB = $($(FREEIMAGE_LIBRARY_TYPE)LIB)
TARGETDIST = $(DIST$(FREEIMAGE_LIBRARY_TYPE))
LIB_TYPE_FLAGS = $(WIN32_$(FREEIMAGE_LIBRARY_TYPE)_FLAGS)
default: all
all: mkdist
rebuild: clean all
mkdist: FreeImage $(TARGETDIST)
FreeImage: $(TARGETLIB)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
%.coff: %.rc
$(RC) $(RCFLAGS) -o $@ $<
$(DISTDIR)/%: %
$(CP) $< $@
$(DISTDIR)/%: $(SRCDIR)/%
$(CP) $< $@
$(STATICLIB): $(MODULES)
$(AR) rs $@ $(MODULES)
$(IMPORTLIB) $(EXPORTLIB): $(MODULES)
$(DLLTOOL) -e $(EXPORTLIB) -l $(IMPORTLIB) -D $(SHAREDLIB) $(DLLTOOLFLAGS) $(MODULES)
$(SHAREDLIB): $(EXPORTLIB) $(RESOURCE)
$(LD) $(LDFLAGS) -o $@ $(EXPORTLIB) $(MODULES) $(RESOURCE) $(LIBRARIES)
$(DISTDIR):
$(MD) $(DISTDIR)
$(TARGETDIST): $(DISTDIR)
install:
$(CP) $(SHAREDLIB) $(INSTALLDIR)
clean:
$(RM) -f core $(DISTDIR)/*.* $(MODULES) $(RESOURCE) $(STATICLIB) $(SHAREDLIB) $(IMPORTLIB) $(EXPORTLIB)