|
| 1 | +############################################################################ |
| 2 | +# apps/examples/elf/main/Makefile |
| 3 | +# |
| 4 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 5 | +# contributor license agreements. See the NOTICE file distributed with |
| 6 | +# this work for additional information regarding copyright ownership. The |
| 7 | +# ASF licenses this file to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance with the |
| 9 | +# License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | +# License for the specific language governing permissions and limitations |
| 15 | +# under the License. |
| 16 | +# |
| 17 | +############################################################################ |
| 18 | + |
| 19 | +include $(APPDIR)/Make.defs |
| 20 | + |
| 21 | +# Module example built-in application info |
| 22 | + |
| 23 | +PROGNAME = elf |
| 24 | +PRIORITY = SCHED_PRIORITY_DEFAULT |
| 25 | +STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE) |
| 26 | +MODULE = $(CONFIG_EXAMPLES_ELF) |
| 27 | + |
| 28 | +MAINSRC = elf_main.c |
| 29 | + |
| 30 | +SYMTABSRC = test_symtab.c |
| 31 | +SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT)) |
| 32 | + |
| 33 | + |
| 34 | +ifneq ($(CONFIG_BUILD_FLAT),y) |
| 35 | + PASS1_SYMTAB = $(TOPDIR)/pass1/mod_symtab.c |
| 36 | + MODLUE_NAME = tests |
| 37 | +endif |
| 38 | + |
| 39 | +$(SYMTABSRC): |
| 40 | + $(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) g_elf >$@.tmp |
| 41 | + $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) |
| 42 | + |
| 43 | + |
| 44 | +$(SYMTABOBJ): %$(OBJEXT): %.c |
| 45 | + $(call COMPILE, $<, $@, -fno-lto -fno-builtin) |
| 46 | + |
| 47 | +ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) |
| 48 | + |
| 49 | +ROMFSIMG = elf_romfs.img |
| 50 | +ROMFSSRC = elf_romfs.c |
| 51 | +ROMFSOBJ = $(ROMFSSRC:.c=$(OBJEXT)) |
| 52 | + |
| 53 | +$(ROMFSIMG): |
| 54 | + $(Q) genromfs -d $(BINDIR) -f $@ |
| 55 | + |
| 56 | +$(ROMFSSRC): $(ROMFSIMG) |
| 57 | + $(Q) (echo "#include <nuttx/compiler.h>" >$@ && \ |
| 58 | + xxd -i $(ROMFSIMG) | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@) |
| 59 | + |
| 60 | +$(ROMFSOBJ): %$(OBJEXT): %.c |
| 61 | + $(call COMPILE, $<, $@, -fno-lto -fno-builtin) |
| 62 | + |
| 63 | +else ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y) |
| 64 | + NXTOOLDIR = $(TOPDIR)/tools |
| 65 | + GENCROMFSSRC = gencromfs.c |
| 66 | + GENCROMFSEXE = gencromfs$(HOSTEXEEXT) |
| 67 | + |
| 68 | + FSIMG_SRC = cromfs.c |
| 69 | + FSIMG_OBJ = $(FSIMG_SRC:.c=$(OBJEXT)) |
| 70 | + |
| 71 | +$(NXTOOLDIR)/$(GENCROMFSEXE): $(NXTOOLDIR)/$(GENCROMFSSRC) |
| 72 | + $(Q) $(MAKE) -C $(NXTOOLDIR) -f Makefile.host $(GENCROMFSEXE) |
| 73 | + |
| 74 | +# Create the cromfs.c file from the populated cromfs directory |
| 75 | + |
| 76 | +$(FSIMG_SRC):$(NXTOOLDIR)/$(GENCROMFSEXE) |
| 77 | + $(Q) $(NXTOOLDIR)/$(GENCROMFSEXE) $(BINDIR) $@.tmp |
| 78 | + $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@) |
| 79 | + |
| 80 | +$(FSIMG_OBJ): %$(OBJEXT): %.c |
| 81 | + $(call COMPILE, $<, $@, -fno-lto -fno-builtin) |
| 82 | + |
| 83 | +endif |
| 84 | + |
| 85 | +# Copy the symbol table into the kernel pass1/ build directory |
| 86 | + |
| 87 | +ifneq ($(CONFIG_BUILD_FLAT),y) |
| 88 | +$(PASS1_SYMTAB): $(SYMTABSRC) |
| 89 | + $(Q) install -m 0644 $(SYMTABSRC) $(PASS1_SYMTAB) |
| 90 | + $(Q) mv $(BINDIR)$(DELIM)$(MODLUE_NAME) . |
| 91 | +endif |
| 92 | + |
| 93 | +postinstall:: $(ROMFSOBJ) $(SYMTABOBJ) $(FSIMG_OBJ) $(PASS1_SYMTAB) |
| 94 | + $(call ARLOCK, $(call CONVERT_PATH,$(BIN)), $^) |
| 95 | + |
| 96 | +distclean:: |
| 97 | + $(Q) $(call DELFILE, $(SYMTABSRC) $(SYMTABOBJ) $(ROMFSSRC) $(ROMFSIMG) $(ROMFSOBJ) $(MODLUE_NAME)) |
| 98 | + |
| 99 | + |
| 100 | +include $(APPDIR)/Application.mk |
0 commit comments