]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - build/Makefile.lib.inc
Makefile: Generate dependencies for gio_names.txt
[pes-rpp/rpp-lib.git] / build / Makefile.lib.inc
1 # Copyright (C) 2013-2015 Czech Technical University in Prague
2 #
3 # Authors:
4 #     - Michal Sojka <sojkam1@fel.cvut.cz>
5 #
6 # This document contains proprietary information belonging to Czech
7 # Technical University in Prague. Passing on and copying of this
8 # document, and communication of its contents is not permitted
9 # without prior written authorization.
10 #
11 # Rules for compiling rpp-lib.lib.
12
13 makefile_lib_inc_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
14
15 all:: $(makefile_lib_inc_dir)/../rpp-lib.lib
16
17 include ../Makefile.config
18
19 # Check that Makefile.config defined values of all defined
20 # TARGET_HAS_* variables and no more.
21 target_has_list = DMM SPI
22 $(foreach name,$(target_has_list),$(if $(filter TARGET_HAS_$(name),$(.VARIABLES)),,\
23         $(error TARGET_HAS_$(name) not defined in Makefile.config)))
24 target_has_extra = $(filter-out $(target_has_list:%=TARGET_HAS_%),$(filter TARGET_HAS_%,$(.VARIABLES)))
25 $(if $(target_has_extra),\
26         $(error Makefile.config contains supefluous variables: $(target_has_extra)))
27 $(foreach name,$(target_has_list),$(if $(or $(filter y,$(TARGET_HAS_$(name))),$(filter n,$(TARGET_HAS_$(name)))),,\
28         $(error TARGET_HAS_$(name) must be 'y' or 'n')))
29
30 include $(makefile_lib_inc_dir)/../Makefile.var
31 include $(makefile_lib_inc_dir)/../common.mk
32 include $(makefile_lib_inc_dir)/Makefile.rules
33
34 ifeq ($(rpp_lib_DEBUG),1)
35 RPP_CFLAGS += -g -O0
36 else
37 RPP_CFLAGS += -O2 -DNDEBUG
38 endif
39
40 rpp_lib_c_OBJS   = $(addsuffix .obj,$(basename $(filter %.c,   $(rpp_lib_SOURCES))))
41 rpp_lib_asm_OBJS = $(addsuffix .obj,$(basename $(filter %.asm, $(rpp_lib_SOURCES))))
42 rpp_lib_OBJS = $(rpp_lib_c_OBJS) $(rpp_lib_asm_OBJS)
43 rpp_lib_DEPS = $(rpp_lib_OBJS:%=%.dep) rpp/src/gio_names.txt.dep
44
45 rpp-lib.lib: $(rpp_lib_OBJS) #../rpp/TMS570LS313xFlashLnk.cmd
46         $(AR) r $@ $^
47
48 $(makefile_lib_inc_dir)/../rpp-lib.lib: rpp-lib.lib rpp/src/gio_names.txt
49         $(call cp,$<,$@)
50         $(call cp,$(call pathconv,../Makefile.config),$(dir $@))
51         $(call cp,$(call pathconv,rpp/src/gio_names.txt),$(makefile_lib_inc_dir))
52
53 -include $(rpp_lib_DEPS)
54
55 $(rpp_lib_c_OBJS): %.obj: $(makefile_lib_inc_dir)/../%.c
56         $(call mkdir,$(dir $@))
57         $(RPP_COMPILE_CMD)
58
59 $(rpp_lib_asm_OBJS): %.obj: $(makefile_lib_inc_dir)/../%.asm
60         $(call mkdir,$(dir $@))
61         $(RPP_COMPILE_CMD)
62
63 rpp/src/gio_names.txt: %: $(makefile_lib_inc_dir)/../%.tmpl
64         $(call mkdir,$(dir $@))
65         $(RPP_PREPROC_CMD)
66
67 # Work around TI compiler bug in dependency generation - it always
68 # adds .obj even if the output file lacks this extension.
69 rpp/src/gio_names.txt: rpp/src/gio_names.txt.obj
70 rpp/src/gio_names.txt.obj:
71         $(call mkdir,$(dir $@))
72         echo xxx > $(call pathconv,$@)
73
74 .PHONY: all clean $(makefile_lib_inc_dir)/../rpp-lib.lib
75
76 clean::
77         $(call rm,$(rpp_lib_OBJS) $(rpp_lib_DEPS) rpp-lib.lib)