blob: 8d1714281765e8858087a4df88cc36b8b8cf03fb [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
6# Now it is allocated dymanically by the linker by evaluating all DLLs
7# 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)
Bram Moolenaara40c5002005-01-09 21:16:21 +000032DEL = rm
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))
41DEL = rm
42else
43DEL = del
44endif
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000045endif
Bram Moolenaar47cff3a2016-03-07 20:58:50 +010046# Set the default $(WINVER) to make it work with WinXP.
47ifndef WINVER
48WINVER = 0x0501
49endif
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
56DEFFILE = gvimext_ming.def
57OBJ := gvimext.o
58
59DLL := gvimext.dll
60
61.PHONY: all all-before all-after clean clean-custom
62
63all: all-before $(DLL) all-after
64
65$(DLL): $(OBJ) $(RES) $(DEFFILE)
Bram Moolenaarb0d3f872010-12-30 14:50:52 +010066 $(CXX) $(LDFLAGS) $(CXXFLAGS) -s -o $@ \
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000067 -Wl,--enable-auto-image-base \
68 -Wl,--enable-auto-import \
69 -Wl,--whole-archive \
70 $^ \
71 -Wl,--no-whole-archive \
72 $(LIBS)
73
74gvimext.o: gvimext.cpp
Bram Moolenaar47cff3a2016-03-07 20:58:50 +010075 $(CXX) $(CXXFLAGS) -DFEAT_GETTEXT -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) -c $? -o $@
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000076
77$(RES): gvimext_ming.rc
Bram Moolenaarb0d3f872010-12-30 14:50:52 +010078 $(WINDRES) $(WINDRES_FLAGS) --input-format=rc --output-format=coff -DMING $? -o $@
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000079
80clean: clean-custom
Bram Moolenaara40c5002005-01-09 21:16:21 +000081 -$(DEL) $(OBJ) $(RES) $(DLL)