-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
103 lines (79 loc) · 1.5 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
MKDIR=mkdir -p
RM=rm
CC=cc
ECHO=echo
OBJS=\
$(OBJDIR)/p1load.o \
$(OBJDIR)/port.o \
$(OBJDIR)/ploader.o \
$(OBJDIR)/packet.o
EEPROM_OBJS=\
$(OBJDIR)/eeprom.o \
$(OBJDIR)/port.o \
$(OBJDIR)/ploader.o \
$(OBJDIR)/packet.o
OS?=macosx
VERSION := $(shell git describe --tags --long 2>/dev/null)
ifeq ($(VERSION),)
VERSION := '0.0.0'
endif
CFLAGS += -D'VERSION="$(VERSION)"'
ifeq ($(OS),linux)
CFLAGS+=-DLINUX
EXT=
OSINT=osint_linux.o
LIBS=
endif
ifeq ($(OS),raspberrypi)
OS=linux
CFLAGS+=-DLINUX -DRASPBERRY_PI
EXT=
OSINT=osint_linux.o
LIBS=
OSINT+=gpio_sysfs.o
endif
ifeq ($(OS),msys)
CFLAGS+=-DMINGW
EXT=.exe
OSINT=osint_mingw.o enumcom.o
LIBS=-lsetupapi
endif
ifeq ($(OS),macosx)
CFLAGS+=-DMACOSX
EXT=
OSINT=osint_linux.o
LIBS=
endif
ifeq ($(OS),)
$(error OS not set)
endif
SRCDIR=.
OBJDIR=obj/$(OS)
BINDIR=bin/$(OS)
TARGET=$(BINDIR)/p1load$(EXT)
EEPROM_TARGET=$(BINDIR)/eeprom$(EXT)
HDRS=\
ploader.h
OBJS+=$(foreach x, $(OSINT), $(OBJDIR)/$(x))
EEPROM_OBJS+=$(foreach x, $(OSINT), $(OBJDIR)/$(x))
CFLAGS+=-Wall
LDFLAGS=$(CFLAGS)
.PHONY: default
default: $(TARGET) # $(EEPROM_TARGET)
DIRS=$(OBJDIR) $(BINDIR)
$(TARGET): $(BINDIR) $(OBJDIR) $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
$(EEPROM_TARGET): $(BINDIR) $(OBJDIR) $(EEPROM_OBJS)
$(CC) $(LDFLAGS) -o $@ $(EEPROM_OBJS) $(LIBS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(HDRS) $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
$(DIRS):
$(MKDIR) $@
.PHONY: clean
clean:
$(RM) -f -r $(OBJDIR)
$(RM) -f -r $(BINDIR)
.PHONY: clean-all
clean-all:
$(RM) -f -r obj
$(RM) -f -r bin