| 1 |
nigel |
39 |
# dll.mk - auxilary Makefile to easy build dll's for mingw32 target |
| 2 |
|
|
# ver. 0.6 of 1999-03-25 |
| 3 |
|
|
# |
| 4 |
|
|
# Homepage of this makefile - http://www.is.lg.ua/~paul/devel/ |
| 5 |
|
|
# Homepage of original mingw32 project - |
| 6 |
|
|
# http://www.fu.is.saga-u.ac.jp/~colin/gcc.html |
| 7 |
|
|
# |
| 8 |
|
|
# How to use: |
| 9 |
|
|
# This makefile can: |
| 10 |
|
|
# 1. Create automatical .def file from list of objects |
| 11 |
|
|
# 2. Create .dll from objects and .def file, either automatical, or your |
| 12 |
|
|
# hand-written (maybe) file, which must have same basename as dll |
| 13 |
|
|
# WARNING! There MUST be object, which name match dll's name. Make sux. |
| 14 |
|
|
# 3. Create import library from .def (as for .dll, only its name required, |
| 15 |
|
|
# not dll itself) |
| 16 |
|
|
# By convention implibs for dll have .dll.a suffix, e.g. libstuff.dll.a |
| 17 |
|
|
# Why not just libstuff.a? 'Cos that's name for static lib, ok? |
| 18 |
|
|
# Process divided into 3 phases because: |
| 19 |
|
|
# 1. Pre-existent .def possible |
| 20 |
|
|
# 2. Generating implib is enough time-consuming |
| 21 |
|
|
# |
| 22 |
|
|
# Variables: |
| 23 |
|
|
# DLL_LDLIBS - libs for linking dll |
| 24 |
|
|
# DLL_LDFLAGS - flags for linking dll |
| 25 |
|
|
# |
| 26 |
|
|
# By using $(DLL_SUFFIX) instead of 'dll', e.g. stuff.$(DLL_SUFFIX) |
| 27 |
|
|
# you may help porting makefiles to other platforms |
| 28 |
|
|
# |
| 29 |
|
|
# Put this file in your make's include path (e.g. main include dir, for |
| 30 |
|
|
# more information see include section in make doc). Put in the beginning |
| 31 |
|
|
# of your own Makefile line "include dll.mk". Specify dependences, e.g.: |
| 32 |
|
|
# |
| 33 |
|
|
# Do all stuff in one step |
| 34 |
|
|
# libstuff.dll.a: $(OBJECTS) stuff.def |
| 35 |
|
|
# stuff.def: $(OBJECTS) |
| 36 |
|
|
# |
| 37 |
|
|
# Steps separated, pre-provided .def, link with user32 |
| 38 |
|
|
# |
| 39 |
|
|
# DLL_LDLIBS=-luser32 |
| 40 |
|
|
# stuff.dll: $(OBJECTS) |
| 41 |
|
|
# libstuff.dll.a: $(OBJECTS) |
| 42 |
|
|
|
| 43 |
|
|
|
| 44 |
|
|
DLLWRAP=dllwrap |
| 45 |
|
|
DLLTOOL=dlltool |
| 46 |
|
|
|
| 47 |
|
|
DLL_SUFFIX=dll |
| 48 |
|
|
|
| 49 |
|
|
.SUFFIXES: .o .$(DLL_SUFFIX) |
| 50 |
|
|
|
| 51 |
|
|
_%.def: %.o |
| 52 |
|
|
$(DLLTOOL) --export-all --output-def $@ $^ |
| 53 |
|
|
|
| 54 |
|
|
%.$(DLL_SUFFIX): %.o |
| 55 |
|
|
$(DLLWRAP) --dllname $(notdir $@) --driver-name $(CC) --def $*.def -o $@ $(filter %.o,$^) $(DLL_LDFLAGS) $(DLL_LDLIBS) |
| 56 |
|
|
|
| 57 |
|
|
lib%.$(DLL_SUFFIX).a:%.def |
| 58 |
|
|
$(DLLTOOL) --dllname $(notdir $*.dll) --def $< --output-lib $@ |
| 59 |
|
|
|
| 60 |
|
|
# End |