blob: 06ec7b6dc517d2bb82490fab48f71b69dcf6afff [file] [log] [blame]
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00001# Project: gvimext
2# Generates gvimext.dll with gcc.
Bram Moolenaarabfa9ef2016-01-15 22:34:45 +01003# To be used with MingW and Cygwin.
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004#
5# Originally, the DLL base address was fixed: -Wl,--image-base=0x1C000000
dundargocc57b5bc2022-11-02 13:30:51 +00006# Now it is allocated dynamically by the linker by evaluating all DLLs
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00007# already loaded in memory. The binary image contains as well information
8# for automatic pseudo-rebasing, if needed by the system. ALV 2004-02-29
9
10# If cross-compiling set this to yes, else set it to no
11CROSS = no
12#CROSS = yes
13# For the old MinGW 2.95 (the one you get e.g. with debian woody)
14# set the following variable to yes and check if the executables are
15# really named that way.
16# If you have a newer MinGW or you are using cygwin set it to no and
17# check also the executables
18MINGWOLD = no
19
Bram Moolenaarb0d3f872010-12-30 14:50:52 +010020# Link against the shared versions of libgcc/libstdc++ by default. Set
21# STATIC_STDCPLUS to "yes" to link against static versions instead.
22STATIC_STDCPLUS=no
23#STATIC_STDCPLUS=yes
24
25# Note: -static-libstdc++ is not available until gcc 4.5.x.
26LDFLAGS += -shared
27ifeq (yes, $(STATIC_STDCPLUS))
28LDFLAGS += -static-libgcc -static-libstdc++
29endif
30
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000031ifeq ($(CROSS),yes)
Ken Takata325420e2024-07-26 19:02:11 +020032DEL = rm -f
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000033ifeq ($(MINGWOLD),yes)
Bram Moolenaar2369e352011-09-30 16:56:02 +020034CXXFLAGS := -O2 -fvtable-thunks
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000035else
Bram Moolenaar2369e352011-09-30 16:56:02 +020036CXXFLAGS := -O2
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000037endif
38else
Bram Moolenaar2369e352011-09-30 16:56:02 +020039CXXFLAGS := -O2
Bram Moolenaara40c5002005-01-09 21:16:21 +000040ifneq (sh.exe, $(SHELL))
Ken Takata325420e2024-07-26 19:02:11 +020041DEL = rm -f
Bram Moolenaara40c5002005-01-09 21:16:21 +000042else
43DEL = del
44endif
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000045endif
K.Takata12715722023-05-25 16:43:27 +010046# Set the default $(WINVER) to make it work with Windows 7.
Bram Moolenaar47cff3a2016-03-07 20:58:50 +010047ifndef WINVER
K.Takata12715722023-05-25 16:43:27 +010048WINVER = 0x0601
Bram Moolenaar47cff3a2016-03-07 20:58:50 +010049endif
Bram Moolenaar48f80c22010-02-24 15:08:27 +010050CXX := $(CROSS_COMPILE)g++
Bram Moolenaarb0d3f872010-12-30 14:50:52 +010051WINDRES := $(CROSS_COMPILE)windres
Bram Moolenaar5c829bf2021-01-25 19:18:02 +010052# this used to have --preprocessor, but it's no longer supported
53WINDRES_FLAGS =
Bram Moolenaar9c601612015-05-06 06:51:50 +020054LIBS := -luuid -lgdi32
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000055RES := gvimext.res
Yegappan Lakshmanan1630bd92022-06-14 12:30:25 +010056ifeq ($(findstring clang++,$(CXX)),)
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000057DEFFILE = gvimext_ming.def
Yegappan Lakshmanan1630bd92022-06-14 12:30:25 +010058endif
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000059OBJ := gvimext.o
60
61DLL := gvimext.dll
62
63.PHONY: all all-before all-after clean clean-custom
64
65all: all-before $(DLL) all-after
66
67$(DLL): $(OBJ) $(RES) $(DEFFILE)
Bram Moolenaarb0d3f872010-12-30 14:50:52 +010068 $(CXX) $(LDFLAGS) $(CXXFLAGS) -s -o $@ \
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000069 -Wl,--enable-auto-image-base \
70 -Wl,--enable-auto-import \
71 -Wl,--whole-archive \
72 $^ \
73 -Wl,--no-whole-archive \
74 $(LIBS)
75
76gvimext.o: gvimext.cpp
Bram Moolenaar47cff3a2016-03-07 20:58:50 +010077 $(CXX) $(CXXFLAGS) -DFEAT_GETTEXT -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) -c $? -o $@
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000078
79$(RES): gvimext_ming.rc
Bram Moolenaarb0d3f872010-12-30 14:50:52 +010080 $(WINDRES) $(WINDRES_FLAGS) --input-format=rc --output-format=coff -DMING $? -o $@
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000081
82clean: clean-custom
Bram Moolenaara40c5002005-01-09 21:16:21 +000083 -$(DEL) $(OBJ) $(RES) $(DLL)