4 # Copyright (C) 2006 Laurent Bessard
6 # This file is part of canfestival, a library implementing the canopen
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifneq ($(KERNELRELEASE),)
25 # Kbuild part of Makefile
26 obj-m := libcanfestival_$(TARGET).o
27 libcanfestival_$(TARGET)-objs := $(OBJS)
33 PROG_CFLAGS = SUB_PROG_CFLAGS
35 ARCH_NAME = SUB_ARCH_NAME
38 CAN_DRIVER = SUB_CAN_DRIVER
39 TIMERS_DRIVER = SUB_TIMERS_DRIVER
40 ENABLE_DLL_DRIVERS = SUB_ENABLE_DLL_DRIVERS
41 BINUTILS_PREFIX = SUB_BINUTILS_PREFIX
43 INCLUDES = -I../../include -I../../include/$(TARGET) -I../../include/$(TIMERS_DRIVER)
47 # add timers driver if any
48 ifneq ($(TIMERS_DRIVER),timers_)
49 OBJS += ../$(TIMERS_DRIVER)/$(TIMERS_DRIVER).o
52 SRC_HFILES = ../../include/$(TARGET)/applicfg.h ../../include/$(TARGET)/canfestival.h
54 TARGET_HFILES = $(PREFIX)/include/$(TARGET)/applicfg.h $(PREFIX)/include/$(TARGET)/canfestival.h
58 ifeq ($(TIMERS_DRIVER), timers_kernel)
59 OBJS := $(shell echo $(OBJS) | sed "s:$(TARGET)_::g")
60 EXTRA_CFLAGS := $(shell echo $(INCLUDES) | sed "s:-I:-I$(src)/:g")
61 EXTRA_CFLAGS += $(PROG_CFLAGS)
62 KERNELDIR := SUB_KERNELDIR
67 driver: libcanfestival_$(TARGET)
69 libcanfestival_$(TARGET):
70 @echo Building [libcanfestival_$(TARGET).o]
71 $(MAKE) -C $(KERNELDIR) M=$(shell pwd) modules
74 $(MAKE) -C $(KERNELDIR) M=$(shell pwd) clean
81 CFLAGS = SUB_OPT_CFLAGS
86 $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
88 #../$(TIMERS_DRIVER)/$(TIMERS_DRIVER).o:
89 # $(MAKE) -C ../$(TIMERS_DRIVER) driver
91 #../$(CAN_DRIVER)/$(CAN_DRIVER).o:
92 # $(MAKE) -C ../$(CAN_DRIVER) driver
94 libcanfestival_$(TARGET).a: $(OBJS)
95 @echo Building [libcanfestival_$(TARGET).a]
96 $(BINUTILS_PREFIX)ar rc $@ $(OBJS)
97 $(BINUTILS_PREFIX)ranlib $@
99 install: libcanfestival_$(TARGET).a
100 mkdir -p $(PREFIX)/lib/
101 mkdir -p $(PREFIX)/include/canfestival
102 cp libcanfestival_$(TARGET).a $(PREFIX)/lib/
103 cp $(SRC_HFILES) $(PREFIX)/include/canfestival
106 rm -f $(PREFIX)/lib/libcanfestival_$(TARGET).a
107 rm -f $(TARGET_HFILES)
111 rm -f libcanfestival_$(TARGET).a