Note that there are some explanatory texts on larger screens.

plurals
  1. POmakefile with .s files beside .c files
    text
    copied!<p>I have a baremetal project which includes .s files beside .c files. I wonder how can i write a makefile, where i sepparate compiling of .s files from .c files. Files are located in a subfolders (source, include, startup) of a program. I was going for something like this. Is this good? How can i link the objects into exe then?</p> <pre><code>SHELL := /bin/bash ROOT := $(shell pwd) VPATH := $(ROOT)/source:/$(ROOT)/startup:$(ROOT)/include EXE := exe OBJECTS_GCC := $(patsubst %.c,%.o,$(wildcard *.c)) OBJECTS_AS := $(patsubst %.s,%.o,$(wildcard *.s)) AS := arm-none-eabi-as -mcpu=arm926ej-s -Wall GCC := arm-none-eabi-gcc -mcpu=arm926ej-s -Wall LD := arm-none-eabi-ld -T test.ld -o $(EXE) all: $(EXE) $(EXE): startups sources startups: $(OBJECTS_AS) $(AS) $(OBJECTS_AS) sources: $(OBJECTS_GCC) $(GCC) $(OBJECTS_GCC) </code></pre> <p>I am having hard times finding any example at all which includes .s files alongside .c files. </p> <p>Regards.</p> <hr> <p>Here is the latest version of makefile, where header.h isnt found: </p> <pre><code>SHELL := /bin/bash ROOT := $(shell pwd) INC := $(ROOT)/inc SRC := $(ROOT)/src STR := $(ROOT)/str EXE := exe AS := arm-none-eabi-as -mcpu=arm926ej-s -c -Wall -I $(INC) -I$(SRC) -I $(STR) GCC := arm-none-eabi-gcc -mcpu=arm926ej-s -c -Wall -I $(INC) -I$(SRC) -I $(STR) LDSCRIPT := test.ld LD := arm-none-eabi-ld -T $(LDSCRIPT) HEADERS := $(notdir $(wildcard $(INC)/*.h)) SOURCES_GCC := $(notdir $(wildcard $(SRC)/*.c)) SOURCES_AS := $(notdir $(wildcard $(STR)/*.s)) OBJECTS_GCC := $(SOURCES_GCC:.c=.o) OBJECTS_AS := $(SOURCES_AS:.s=.o) VPATH := $(STR):$(SRC):$(INC) all : $(EXE) @echo konec postopka: izvrsljiv program po imenu $(EXE) se nahaja v mapi $(ROOT) $(EXE) : $(OBJECTS_AS) $(OBJECTS_GCC) @echo objekti so: $(OBJECTS_AS) $(OBJECTS_GCC) @echo headerji so: $(HEADERS) @echo linkanje objektov v izvrsljiv program... $(LD) -o $@ $^ %.o : %.s %.h @echo prevajanje ASSEMBLY izvornih datotek... $(AS) -o $@ $&lt; %.o : %.c %.h @echo prevajanje C izvornih datotek... $(GCC) -o $@ $&lt; .PHONY : clean clean : @echo brisanje objektov rm *.o @echo brisanje izvrsljivega programa rm $(EXE) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload