forked from vdudouyt/stm8flash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (56 loc) · 1.81 KB
/
Makefile
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
# stm8flash makefile
#
# Multiplatform support
# - Linux (x86, Raspian)
# - MacOS (Darwin)
# - Windows (e.g. mingw-w64-x86 with libusb1.0)
PLATFORM=$(shell uname -s)
# Pass RELEASE=anything to build without debug symbols
ifneq (,$(strip $(RELEASE)))
BASE_CFLAGS := -O1
else
BASE_CFLAGS := -g -O0
endif
# Pass LIBUSB_QUIET=anything to Make to silence debug output from libusb.
ifneq (,$(strip $(LIBUSB_QUIET)))
BASE_CFLAGS += -DSTM8FLASH_LIBUSB_QUIET
endif
BASE_CFLAGS += --std=gnu99 --pedantic -Wall
ifeq ($(PLATFORM),Linux)
LIBS = `pkg-config --libs libusb-1.0`
LIBUSB_CFLAGS = `pkg-config --cflags libusb-1.0`
else ifeq ($(PLATFORM),Darwin)
LIBS = $(shell pkg-config --libs libusb-1.0)
LIBUSB_CFLAGS = $(shell pkg-config --cflags libusb-1.0)
#MacOSSDK=$(shell xcrun --show-sdk-path)
#BASE_CFLAGS += -I$(MacOSSDK)/usr/include/ -I$(MacOSSDK)/usr/include/sys -I$(MacOSSDK)/usr/include/machine
else ifeq ($(PLATFORM),FreeBSD)
LIBS = `pkg-config --libs libusb-1.0`
LIBUSB_CFLAGS = `pkg-config --cflags libusb-1.0`
else
# Generic case is Windows
LIBS = -lusb-1.0
LIBUSB_CFLAGS =
CC ?= GCC
BIN_SUFFIX =.exe
endif
# Respect user-supplied cflags, if any - just put ours in front.
override CFLAGS := $(BASE_CFLAGS) $(LIBUSB_CFLAGS) $(CFLAGS)
# Check if install DESTDIR is undefined
ifndef DESTDIR
DESTDIR=/usr/local
endif
BIN =stm8flash
OBJECTS =stlink.o stlinkv2.o espstlink.o main.o byte_utils.o ihex.o srec.o stm8.o libespstlink.o
.PHONY: all clean install
$(BIN)$(BIN_SUFFIX): $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) $(LIBS) -o $(BIN)$(BIN_SUFFIX)
all: $(BIN)$(BIN_SUFFIX)
$(OBJECTS): $(wildcard *.h)
libespstlink.so: libespstlink.c libespstlink.h
$(CC) -shared $(CFLAGS) -fPIC $< -o $@
clean:
-rm -f $(OBJECTS) $(BIN)$(BIN_SUFFIX)
install:
mkdir -p $(DESTDIR)/bin/
cp $(BIN)$(BIN_SUFFIX) $(DESTDIR)/bin/