1# Project: gvimext
2# Generates gvimext.dll with gcc.
3# Can be used for Cygwin and MingW (MingW ignores -mno-cygwin)
4#
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
20ifeq ($(CROSS),yes)
21DEL = rm
22ifeq ($(MINGWOLD),yes)
23CXXFLAGS := -O2 -mno-cygwin -fvtable-thunks
24else
25CXXFLAGS := -O2 -mno-cygwin
26endif
27else
28CXXFLAGS := -O2 -mno-cygwin
29ifneq (sh.exe, $(SHELL))
30DEL = rm
31else
32DEL = del
33endif
34endif
35CXX := $(CROSS_COMPILE)g++
36WINDRES := $(CROSS_COMPILE)windres
37LIBS :=  -luuid
38RES  := gvimext.res
39DEFFILE = gvimext_ming.def
40OBJ  := gvimext.o
41
42DLL  := gvimext.dll
43
44.PHONY: all all-before all-after clean clean-custom
45
46all: all-before $(DLL) all-after
47
48$(DLL): $(OBJ) $(RES) $(DEFFILE)
49	$(CXX) -shared $(CXXFLAGS) -s -o $@ \
50		-Wl,--enable-auto-image-base \
51		-Wl,--enable-auto-import \
52		-Wl,--whole-archive \
53			$^ \
54		-Wl,--no-whole-archive \
55			$(LIBS)
56
57gvimext.o: gvimext.cpp
58	$(CXX) $(CXXFLAGS) -DFEAT_GETTEXT -c $? -o $@
59
60$(RES): gvimext_ming.rc
61	$(WINDRES) --input-format=rc --output-format=coff -DMING $? -o $@
62
63clean: clean-custom
64	-$(DEL)  $(OBJ) $(RES) $(DLL)
65
66