-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile_SPIburn
61 lines (48 loc) · 1.17 KB
/
Makefile_SPIburn
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
#
# Makefile for Burner
#
BUILD_ID = "`date +%Y%m%d%H`"
CFLAGS = -g3 -O0 -Wall -Wextra -DBUILD_ID=$(BUILD_ID) -DSPI_BURN
LIBS = -lm
CC ?= gcc
ifeq ($(OS),Windows_NT)
ifeq ($(shell uname -o), Msys)
OS_TYPE := MSYS
else ifeq ($(shell uname -o), Cygwin)
OS_TYPE := CYGWIN
endif
endif
# Now set flags or variables based on the detected OS
ifeq ($(OS_TYPE),MSYS)
# Check for MinGW compilers
ifeq ($(shell command -v x86_64-w64-mingw32-gcc 2>/dev/null),)
ifeq ($(shell command -v i386-mingw32-gcc 2>/dev/null),)
$(error Neither x86_64-w64-mingw32-gcc nor i386-mingw32-gcc found)
else
CC = i386-mingw32-gcc
endif
else
CC = x86_64-w64-mingw32-gcc
endif
else ifeq ($(OS_TYPE),CYGWIN)
EXTENSION=.exe
endif
#To cross-compile, check the $CC
ifneq ($(findstring mingw32, $(CC)),)
LIBS += -lws2_32 -lwsock32 -lgdi32 -luser32 -lcfgmgr32 -lsetupapi -lcomctl32
EXTENSION=.exe
endif
OBJS = util.o \
main.o \
platform.o \
spiflash-MXIC.o
.PHONY: all clean
.INTERMEDIATE: $(OBJS)
all: SPI_burn
SPI_burn: $(OBJS)
$(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS)
strip SPI_burn$(EXTENSION)
clean:
rm -f SPI_burn SPI_burn.exe *.o
%.o:%.c
$(CC) $(CFLAGS) -c -o $@ $<