2015-01-26 23:06:40 -05:00
|
|
|
MKDIR=mkdir -p
|
|
|
|
RM=rm
|
|
|
|
CC=cc
|
|
|
|
ECHO=echo
|
|
|
|
|
2015-02-01 12:37:55 -05:00
|
|
|
CFLAGS=-Wall
|
|
|
|
|
2015-01-26 23:06:40 -05:00
|
|
|
OBJS=\
|
|
|
|
$(OBJDIR)/p1load.o \
|
2015-02-19 22:00:12 -05:00
|
|
|
$(OBJDIR)/port.o \
|
|
|
|
$(OBJDIR)/ploader.o \
|
|
|
|
$(OBJDIR)/packet.o
|
|
|
|
|
|
|
|
EEPROM_OBJS=\
|
|
|
|
$(OBJDIR)/eeprom.o \
|
|
|
|
$(OBJDIR)/port.o \
|
|
|
|
$(OBJDIR)/ploader.o \
|
|
|
|
$(OBJDIR)/packet.o
|
2015-01-26 23:06:40 -05:00
|
|
|
|
|
|
|
OS?=macosx
|
|
|
|
|
2015-02-08 14:30:29 -05:00
|
|
|
VERSION := $(shell git describe --tags --long 2>/dev/null)
|
|
|
|
ifeq ($(VERSION),)
|
|
|
|
VERSION := '0.0.0'
|
|
|
|
endif
|
|
|
|
|
|
|
|
CFLAGS += -D'VERSION="$(VERSION)"'
|
|
|
|
|
2015-01-26 23:06:40 -05:00
|
|
|
ifeq ($(OS),linux)
|
|
|
|
CFLAGS+=-DLINUX
|
|
|
|
EXT=
|
2015-02-20 07:42:58 -05:00
|
|
|
OSINT=osint_linux.o
|
2015-01-26 23:06:40 -05:00
|
|
|
LIBS=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(OS),raspberrypi)
|
|
|
|
OS=linux
|
|
|
|
CFLAGS+=-DLINUX -DRASPBERRY_PI
|
|
|
|
EXT=
|
2015-02-19 22:00:12 -05:00
|
|
|
OSINT=osint_linux.o
|
2015-01-26 23:06:40 -05:00
|
|
|
LIBS=
|
2015-02-19 22:00:12 -05:00
|
|
|
OSINT+=gpio_sysfs.o
|
2015-01-26 23:06:40 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(OS),msys)
|
2015-02-02 10:34:29 -05:00
|
|
|
CFLAGS+=-DMINGW
|
2015-01-26 23:06:40 -05:00
|
|
|
EXT=.exe
|
2015-02-19 22:00:12 -05:00
|
|
|
OSINT=osint_mingw.o enumcom.o
|
2015-01-26 23:06:40 -05:00
|
|
|
LIBS=-lsetupapi
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(OS),macosx)
|
|
|
|
CFLAGS+=-DMACOSX
|
|
|
|
EXT=
|
2015-02-19 22:00:12 -05:00
|
|
|
OSINT=osint_linux.o
|
2015-01-26 23:06:40 -05:00
|
|
|
LIBS=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(OS),)
|
|
|
|
$(error OS not set)
|
|
|
|
endif
|
|
|
|
|
|
|
|
SRCDIR=.
|
|
|
|
OBJDIR=obj/$(OS)
|
|
|
|
BINDIR=bin/$(OS)
|
|
|
|
|
|
|
|
TARGET=$(BINDIR)/p1load$(EXT)
|
|
|
|
|
2015-02-19 22:00:12 -05:00
|
|
|
EEPROM_TARGET=$(BINDIR)/eeprom$(EXT)
|
|
|
|
|
2015-01-26 23:06:40 -05:00
|
|
|
HDRS=\
|
|
|
|
ploader.h
|
|
|
|
|
2015-02-19 22:00:12 -05:00
|
|
|
OBJS+=$(foreach x, $(OSINT), $(OBJDIR)/$(x))
|
|
|
|
EEPROM_OBJS+=$(foreach x, $(OSINT), $(OBJDIR)/$(x))
|
2015-01-26 23:06:40 -05:00
|
|
|
|
|
|
|
CFLAGS+=-Wall
|
|
|
|
LDFLAGS=$(CFLAGS)
|
|
|
|
|
|
|
|
.PHONY: default
|
2015-02-19 22:00:12 -05:00
|
|
|
default: $(TARGET) $(EEPROM_TARGET)
|
2015-01-26 23:06:40 -05:00
|
|
|
|
|
|
|
DIRS=$(OBJDIR) $(BINDIR)
|
|
|
|
|
|
|
|
$(TARGET): $(BINDIR) $(OBJDIR) $(OBJS)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
|
|
|
|
|
2015-02-19 22:00:12 -05:00
|
|
|
$(EEPROM_TARGET): $(BINDIR) $(OBJDIR) $(EEPROM_OBJS)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(EEPROM_OBJS) $(LIBS)
|
|
|
|
|
2015-01-26 23:06:40 -05:00
|
|
|
$(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
|