xfel/Makefile

79 lines
1.8 KiB
Makefile
Raw Normal View History

2021-05-25 16:56:02 +08:00
#
# Makefile for module.
#
2021-06-09 10:47:31 +08:00
CROSS ?=
2021-05-25 16:56:02 +08:00
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 := `pkg-config --libs libusb-1.0`
INCDIRS := -I . `pkg-config --cflags libusb-1.0`
SRCDIRS := . chips
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))
2021-06-09 10:47:31 +08:00
CPPOBJS := $(patsubst %, %, $(CPPFILES:.cpp=.o))
2021-05-25 16:56:02 +08:00
OBJS := $(SOBJS) $(COBJS) $(CPPOBJS)
OBJDIRS := $(patsubst %, %, $(SRCDIRS))
NAME := xfel
VPATH := $(OBJDIRS)
2021-06-09 09:08:15 +08:00
.PHONY: all install clean
2021-05-25 16:56:02 +08:00
all : $(NAME)
$(NAME) : $(OBJS)
@echo [LD] Linking $@
@$(CC) $(LDFLAGS) $(LIBDIRS) -Wl,--cref,-Map=$@.map $^ -o $@ $(LIBS)
$(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 $@
2021-06-09 09:08:15 +08:00
install:
2021-06-09 11:05:08 +08:00
install -Dm0755 xfel /usr/bin
install -Dm0644 99-xfel.rules /etc/udev/rules.d
install -Dm0644 LICENSE /usr/share/licenses/xfel
2021-06-09 09:08:15 +08:00
2021-05-25 16:56:02 +08:00
clean:
@$(RM) $(DEPS) $(OBJS) $(NAME).map $(NAME) *~