blob: 86307facae72bdd10864510de1e13ca235619ce1 [file] [log] [blame]
TARGET := adk2tool
BUILDDIR := build-$(TARGET)
# compiler flags, default libs to link against
COMPILEFLAGS := -g -O2
CFLAGS :=
CPPFLAGS :=
ASMFLAGS :=
LDFLAGS :=
LDLIBS :=
UNAME := $(shell uname -s)
ARCH := $(shell uname -m)
SERIAL:=win32
# switch any platform specific stuff here
# ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
# ...
# endif
ifeq ($(UNAME),Darwin)
COMPILEFLAGS += -arch i386
LDFLAGS += -arch i386
SERIAL:=posix
endif
ifeq ($(UNAME),Linux)
COMPILEFLAGS += -m32
LDFLAGS += -m32
SERIAL:=posix
endif
CFLAGS += $(COMPILEFLAGS)
CPPFLAGS += $(COMPILEFLAGS)
ASMFLAGS += $(COMPILEFLAGS)
OBJS := adk2tool.o serial-$(SERIAL).o
OBJS := $(addprefix $(BUILDDIR)/,$(OBJS))
DEPS := $(OBJS:.o=.d)
$(BUILDDIR)/$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS)
clean:
rm -f $(OBJS) $(DEPS) $(TARGET)
spotless:
rm -rf build-*
# makes sure the target dir exists
MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi
$(BUILDDIR)/%.o: %.c
@$(MKDIR)
@echo compiling $<
@$(CC) $(CFLAGS) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
$(BUILDDIR)/%.o: %.cpp
@$(MKDIR)
@echo compiling $<
@$(CC) $(CPPFLAGS) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
$(BUILDDIR)/%.o: %.S
@$(MKDIR)
@echo compiling $<
@$(CC) $(ASMFLAGS) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
ifeq ($(filter $(MAKECMDGOALS), clean), )
-include $(DEPS)
endif