# # Makefile for Cygwin. This builds a DLL that depends on Cygwin DLL; # for DLLs independent of Cygwin DLL, use Makefile.nocygwin instead. # CC = gcc DEBUG = -g -O2 # The -mrtd flag tells the compiler to use the PASCAL or "stdcall" calling # convention required by VBA/Excel/etc. CFLAGS = -mrtd $(DEBUG) AS = as DLLTOOL = dlltool DLLWRAP = dllwrap # # Various targets to build. # DLL_NAME = cdll.dll DLL_EXP_DEF = cdll.def all: $(DLL_NAME) # # sources, objects, etc. # SRCS = $(wildcard *.c) OBJS := $(OBJS:.c=.o) # # DLL related variables. These are used when building the DLL. See later. # # any special flags that you need to pass to the F77 compiler when building # the DLL. (lots of software need _DLL defined). DLL_CFLAGS = -DBUILDING_DLL=1 # This is where you pass linker flags, such as library search path, alternate # entry point, etc. The -s flag strips the final DLL. The alternate entry # point is needed since this DLL will be loaded by a non-cygwin application. DLL_LDFLAGS = -s --entry __cygwin_noncygwin_dll_entry@12 # any extra libraries that your DLL may depend on. DLL_LDLIBS = # # your sources etc that go into the DLL. # DLL_SRCS = cdll.c DLL_OBJS = cdll.o ### # # Making DLL # ### # # Note that we let dllwrap create both the DEF and IMPORT library in # one shot. No need to run dlltool anymore. # DLLWRAP_FLAGS = --export-all --output-def $(DLL_EXP_DEF) \ --driver-name $(CC) $(DLL_NAME) $(DLL_EXP_DEF): $(DLL_OBJS) $(DLLWRAP) $(DLLWRAP_FLAGS) -o $(DLL_NAME) \ $(DLL_OBJS) $(DLL_LDFLAGS) $(DLL_LDLIBS) # # dependencies. # cdll.o: cdll.c # # default rules for building DLL objects. Note that client programs (ie., # the ones that *use* the DLL) have to be compiled without the DLL_CFLAGS # flags. # .c.o: $(CC) -c $(CPPFLAGS) $(DLL_CFLAGS) $(CFLAGS) -o $@ $< clean: -rm -f $(OBJS) $(DLL_OBJS) $(DLL_NAME) $(DLL_EXP_DEF)