Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 1 | # Project: gvimext |
| 2 | # Generates gvimext.dll with gcc. |
Bram Moolenaar | abfa9ef | 2016-01-15 22:34:45 +0100 | [diff] [blame] | 3 | # To be used with MingW and Cygwin. |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 4 | # |
| 5 | # Originally, the DLL base address was fixed: -Wl,--image-base=0x1C000000 |
dundargoc | c57b5bc | 2022-11-02 13:30:51 +0000 | [diff] [blame] | 6 | # Now it is allocated dynamically by the linker by evaluating all DLLs |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 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 |
| 11 | CROSS = 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 |
| 18 | MINGWOLD = no |
| 19 | |
Bram Moolenaar | b0d3f87 | 2010-12-30 14:50:52 +0100 | [diff] [blame] | 20 | # Link against the shared versions of libgcc/libstdc++ by default. Set |
| 21 | # STATIC_STDCPLUS to "yes" to link against static versions instead. |
| 22 | STATIC_STDCPLUS=no |
| 23 | #STATIC_STDCPLUS=yes |
| 24 | |
| 25 | # Note: -static-libstdc++ is not available until gcc 4.5.x. |
| 26 | LDFLAGS += -shared |
| 27 | ifeq (yes, $(STATIC_STDCPLUS)) |
| 28 | LDFLAGS += -static-libgcc -static-libstdc++ |
| 29 | endif |
| 30 | |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 31 | ifeq ($(CROSS),yes) |
Ken Takata | 325420e | 2024-07-26 19:02:11 +0200 | [diff] [blame] | 32 | DEL = rm -f |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 33 | ifeq ($(MINGWOLD),yes) |
Bram Moolenaar | 2369e35 | 2011-09-30 16:56:02 +0200 | [diff] [blame] | 34 | CXXFLAGS := -O2 -fvtable-thunks |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 35 | else |
Bram Moolenaar | 2369e35 | 2011-09-30 16:56:02 +0200 | [diff] [blame] | 36 | CXXFLAGS := -O2 |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 37 | endif |
| 38 | else |
Bram Moolenaar | 2369e35 | 2011-09-30 16:56:02 +0200 | [diff] [blame] | 39 | CXXFLAGS := -O2 |
Bram Moolenaar | a40c500 | 2005-01-09 21:16:21 +0000 | [diff] [blame] | 40 | ifneq (sh.exe, $(SHELL)) |
Ken Takata | 325420e | 2024-07-26 19:02:11 +0200 | [diff] [blame] | 41 | DEL = rm -f |
Bram Moolenaar | a40c500 | 2005-01-09 21:16:21 +0000 | [diff] [blame] | 42 | else |
| 43 | DEL = del |
| 44 | endif |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 45 | endif |
K.Takata | 1271572 | 2023-05-25 16:43:27 +0100 | [diff] [blame] | 46 | # Set the default $(WINVER) to make it work with Windows 7. |
Bram Moolenaar | 47cff3a | 2016-03-07 20:58:50 +0100 | [diff] [blame] | 47 | ifndef WINVER |
K.Takata | 1271572 | 2023-05-25 16:43:27 +0100 | [diff] [blame] | 48 | WINVER = 0x0601 |
Bram Moolenaar | 47cff3a | 2016-03-07 20:58:50 +0100 | [diff] [blame] | 49 | endif |
Bram Moolenaar | 48f80c2 | 2010-02-24 15:08:27 +0100 | [diff] [blame] | 50 | CXX := $(CROSS_COMPILE)g++ |
Bram Moolenaar | b0d3f87 | 2010-12-30 14:50:52 +0100 | [diff] [blame] | 51 | WINDRES := $(CROSS_COMPILE)windres |
Bram Moolenaar | 5c829bf | 2021-01-25 19:18:02 +0100 | [diff] [blame] | 52 | # this used to have --preprocessor, but it's no longer supported |
| 53 | WINDRES_FLAGS = |
Bram Moolenaar | 9c60161 | 2015-05-06 06:51:50 +0200 | [diff] [blame] | 54 | LIBS := -luuid -lgdi32 |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 55 | RES := gvimext.res |
Yegappan Lakshmanan | 1630bd9 | 2022-06-14 12:30:25 +0100 | [diff] [blame] | 56 | ifeq ($(findstring clang++,$(CXX)),) |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 57 | DEFFILE = gvimext_ming.def |
Yegappan Lakshmanan | 1630bd9 | 2022-06-14 12:30:25 +0100 | [diff] [blame] | 58 | endif |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 59 | OBJ := gvimext.o |
| 60 | |
| 61 | DLL := gvimext.dll |
| 62 | |
| 63 | .PHONY: all all-before all-after clean clean-custom |
| 64 | |
| 65 | all: all-before $(DLL) all-after |
| 66 | |
| 67 | $(DLL): $(OBJ) $(RES) $(DEFFILE) |
Bram Moolenaar | b0d3f87 | 2010-12-30 14:50:52 +0100 | [diff] [blame] | 68 | $(CXX) $(LDFLAGS) $(CXXFLAGS) -s -o $@ \ |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 69 | -Wl,--enable-auto-image-base \ |
| 70 | -Wl,--enable-auto-import \ |
| 71 | -Wl,--whole-archive \ |
| 72 | $^ \ |
| 73 | -Wl,--no-whole-archive \ |
| 74 | $(LIBS) |
| 75 | |
| 76 | gvimext.o: gvimext.cpp |
Bram Moolenaar | 47cff3a | 2016-03-07 20:58:50 +0100 | [diff] [blame] | 77 | $(CXX) $(CXXFLAGS) -DFEAT_GETTEXT -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) -c $? -o $@ |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 78 | |
| 79 | $(RES): gvimext_ming.rc |
Bram Moolenaar | b0d3f87 | 2010-12-30 14:50:52 +0100 | [diff] [blame] | 80 | $(WINDRES) $(WINDRES_FLAGS) --input-format=rc --output-format=coff -DMING $? -o $@ |
Bram Moolenaar | f4b8e57 | 2004-06-24 15:53:16 +0000 | [diff] [blame] | 81 | |
| 82 | clean: clean-custom |
Bram Moolenaar | a40c500 | 2005-01-09 21:16:21 +0000 | [diff] [blame] | 83 | -$(DEL) $(OBJ) $(RES) $(DLL) |