Minor cleanup
[Rockbox.git] / tools / make.inc
blob8e125c834ec64a613a14ae4cf62250a43b3c3b89
1 # -*- Makefile -*-
3 ifndef V
4 SILENT=@
5 endif
6 PRINTS=$(SILENT)$(call info,$(1))
8 $(OBJDIR)/%.o: %.c
9         $(SILENT)mkdir -p $(dir $@)
10         $(call PRINTS,CC $<)$(CC) $(CFLAGS) -c $< -o $@
12 $(OBJDIR)/%.o: %.S
13         $(SILENT)mkdir -p $(dir $@)
14         $(call PRINTS,CC $<)$(CC) $(CFLAGS) -c $< -o $@
16 # The echo stuff last in the dep update shell magic is to prevent any compiler
17 # errors/warnings to cause an error code to get returned and thus stop the
18 # build
20 # This script checks for the presence of $(BUILDDIR)/lang.h and if it doesn't
21 # alreay exist, it is created. This is because lots of files include this
22 # *generated* file and if it doesn't exist when we generate the deps it is no
23 # good. There's a -MG compiler option to cover for this case, but it doesn't
24 # play nicely into this as it then adds a dependency to the lang.h file
25 # without the proper path.
27 $(DEPFILE): $(SOURCES)
28         $(SILENT)mkdir -p $(dir $(DEPFILE))
29         $(SILENT)rm -f $(DEPFILE)
30         $(SILENT)(for each in $(SOURCES) x; do \
31             if test "$$each" = "credits.c"; then \
32                 del="$$del$(BUILDDIR)/credits.raw"; \
33                 touch $(BUILDDIR)/credits.raw; \
34             fi; \
35             if test "x" != "$$each"; then \
36                 obj=`echo $$each | sed -e 's/\.[cS]/.o/'`; \
37                 $(CC) -MG -MM -MT "$(OBJDIR)/$$obj" $(CFLAGS) $$each 2>/dev/null; \
38             fi; \
39             if test -n "$$del"; then \
40                 rm $$del; \
41                 del=""; \
42             fi \
43         done | sed -e "s:[^[:space:]]*lang.h:$(OBJDIR)/lang.o:" > $(DEPFILE); \
44         echo "oo" > /dev/null )
46 tags:
47         $(SILENT)(for d in $(DIRS); do \
48             etags -o $(OBJDIR)/TAGS -a $$d/*.[ch]; \
49         done)