-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.mingw
123 lines (89 loc) · 3.02 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
# 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 ´ld´ comes with
# wrong (Linux) standard library search paths)
LD = g++
#Define the dlltool
DLLTOOL = dlltool
#Define the resource compiler
RC = windres
# Define the copy command
CP = cp
# Define the mkdir command
MD = mkdir
# Define additional libraries needed:
# libstdc++ is included by default with MinGW, however for
# WIN32 based builds, LibRawLite needs the winsock libraries.
LIBRARIES = -lwsock32 -lws2_32
# Define some additional symboles only needed for WIN32 based builds:
WIN32_CFLAGS = $(LIB_TYPE_FLAGS) -DOPJ_STATIC
WIN32_CXXFLAGS = $(WIN32_CFLAGS) -DLIBRAW_NODLL -DLIBRAW_LIBRARY_BUILD
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 $(WIN32_CFLAGS)
CFLAGS += $(INCLUDE)
CXXFLAGS ?= -O3 -fexceptions -Wno-ctor-dtor-privacy -DNDEBUG $(WIN32_CXXFLAGS) -DNO_LCMS
CXXFLAGS += $(INCLUDE)
RCFLAGS ?= -DNDEBUG
LDFLAGS = -s -shared -static -Wl,-soname,$(SOLIBNAME)
DLLTOOLFLAGS = --add-stdcall-underscore
TARGET = FreeImage
STATICLIB = $(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) core $(DISTDIR)/*.* $(MODULES) $(RESOURCE) $(STATICLIB) $(SHAREDLIB) $(IMPORTLIB) $(EXPORTLIB)