forked from lorf/csr-spi-ftdi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.mingw
75 lines (57 loc) · 1.88 KB
/
Makefile.mingw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Use mingw32
#TOOLCHAIN ?= i586-mingw32msvc-
# Use mingw-w64
TOOLCHAIN ?= i686-w64-mingw32-
LIBFTDI ?= ./libftdi1
LIBUSB ?= ./libusb
# Print scr-spi-ftdi statistics before exit
CPPFLAGS += -DSPI_STATS
# Enable LEDs
CPPFLAGS += -DENABLE_LEDS
# Fixes compilation on Debian/Ubuntu with mingw-w64 < 3.0.
# See: http://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/[email protected]/
#CPPFLAGS += -DCOMPAT_MINGW_MS_VSNPRINTF
CPPFLAGS += -DCOMPAT_TIMER_MACROS
# Compile with debugging
#CFLAGS += -g -fno-inline
#LDFLAGS += -g -fno-inline
# Compile without debugging
LDFLAGS += -s
CXX = $(TOOLCHAIN)g++
CC = $(TOOLCHAIN)gcc
LD = $(TOOLCHAIN)gcc
VERSION := $(shell cat VERSION)
GIT_REVISION := $(shell git log -1 --format=%h 2>/dev/null)
CPPFLAGS += -DVERSION=\"$(VERSION)\" -DGIT_REVISION=\"$(GIT_REVISION)\"
CFLAGS += -m32 -Wall
CXXFLAGS += -fno-exceptions
LDFLAGS += -shared -m32 -O2 -static
CPPFLAGS += -I$(LIBFTDI)/include/libftdi1
LDFLAGS += -L$(LIBFTDI)/lib
LDLIBS += -lftdi1
CPPFLAGS += -I$(LIBUSB)/include
LDFLAGS += -L$(LIBUSB)/MinGW32/static
LDLIBS += -lusb-1.0
MAKEFILE = $(firstword $(MAKEFILE_LIST))
LIBDIR = lib-win32
OBJDIR = obj-win32
LIBNAME = usbspi.dll
LIBRARY_DEF = usbspi.dll.def
all: $(LIBDIR)/$(LIBNAME)
$(OBJDIR)/basics.o: spi.h spifns.h logging.h dllmain.h compat.h
$(OBJDIR)/spi.o: spi.h compat.h logging.h
$(OBJDIR)/logging.o: logging.h compat.h
$(LIBDIR)/$(LIBNAME): $(OBJDIR)/$(LIBNAME)
mkdir -p $(LIBDIR)
cp -p $< $@
$(OBJDIR)/$(LIBNAME): $(OBJDIR)/dllmain.o $(OBJDIR)/logging.o $(OBJDIR)/basics.o $(OBJDIR)/spi.o $(OBJDIR)/compat.o $(LIBRARY_DEF)
mkdir -p $(OBJDIR)
$(LD) $(LDFLAGS) $^ -o $@ $(LDLIBS) -Wl,--out-implib,[email protected]
$(OBJDIR)/%.o: %.c
mkdir -p $(OBJDIR)
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(OBJDIR)/%.o: %.cpp
mkdir -p $(OBJDIR)
$(CXX) -c $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -o $@ $<
clean:
rm -fr $(LIBDIR) $(OBJDIR)