mirror of
https://github.com/xboot/xrock.git
synced 2024-11-23 09:53:29 +08:00
71 lines
1.7 KiB
Makefile
71 lines
1.7 KiB
Makefile
#
|
|
# Top makefile
|
|
#
|
|
|
|
CROSS ?= x86_64-w64-mingw32-
|
|
|
|
AS := $(CROSS)gcc -x assembler-with-cpp
|
|
CC := $(CROSS)gcc
|
|
CXX := $(CROSS)g++
|
|
LD := $(CROSS)ld
|
|
AR := $(CROSS)ar
|
|
OC := $(CROSS)objcopy
|
|
OD := $(CROSS)objdump
|
|
RM := rm -fr
|
|
|
|
ASFLAGS := -g -ggdb -Wall -O3
|
|
CFLAGS := -g -ggdb -Wall -O3
|
|
CXXFLAGS := -g -ggdb -Wall -O3
|
|
LDFLAGS :=
|
|
ARFLAGS := -rcs
|
|
OCFLAGS := -v -O binary
|
|
ODFLAGS :=
|
|
MCFLAGS :=
|
|
|
|
LIBDIRS :=
|
|
LIBS := -L/usr/x86_64-w64-mingw32/lib -lusb-1.0
|
|
|
|
INCDIRS := -I . -I /usr/x86_64-w64-mingw32/include/libusb-1.0
|
|
SRCDIRS := .
|
|
|
|
SFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.S))
|
|
CFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.c))
|
|
CPPFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.cpp))
|
|
|
|
SDEPS := $(patsubst %, %, $(SFILES:.S=.o.d))
|
|
CDEPS := $(patsubst %, %, $(CFILES:.c=.o.d))
|
|
CPPDEPS := $(patsubst %, %, $(CPPFILES:.cpp=.o.d))
|
|
DEPS := $(SDEPS) $(CDEPS) $(CPPDEPS)
|
|
|
|
SOBJS := $(patsubst %, %, $(SFILES:.S=.o))
|
|
COBJS := $(patsubst %, %, $(CFILES:.c=.o))
|
|
CPPOBJS := $(patsubst %, %, $(CPPFILES:.cpp=.o))
|
|
OBJS := $(SOBJS) $(COBJS) $(CPPOBJS)
|
|
|
|
OBJDIRS := $(patsubst %, %, $(SRCDIRS))
|
|
NAME := xrock
|
|
VPATH := $(OBJDIRS)
|
|
|
|
.PHONY: all clean
|
|
|
|
all : $(NAME)
|
|
|
|
$(NAME) : $(OBJS)
|
|
@echo [LD] Linking $@
|
|
@$(CC) $(LDFLAGS) $(LIBDIRS) $^ -o $@ $(LIBS) -static
|
|
|
|
$(SOBJS) : %.o : %.S
|
|
@echo [AS] $<
|
|
@$(AS) $(ASFLAGS) -MD -MP -MF $@.d $(INCDIRS) -c $< -o $@
|
|
|
|
$(COBJS) : %.o : %.c
|
|
@echo [CC] $<
|
|
@$(CC) $(CFLAGS) -MD -MP -MF $@.d $(INCDIRS) -c $< -o $@
|
|
|
|
$(CPPOBJS) : %.o : %.cpp
|
|
@echo [CXX] $<
|
|
@$(CXX) $(CXXFLAGS) -MD -MP -MF $@.d $(INCDIRS) -c $< -o $@
|
|
|
|
clean:
|
|
@$(RM) $(DEPS) $(OBJS) $(NAME).exe $(NAME) *~
|