make yocto compatible

This commit is contained in:
Simon From Jakosen 2024-08-07 10:10:18 +02:00
parent 596937a04a
commit ee26652f4e
2 changed files with 3 additions and 14 deletions

View File

@ -1,13 +1,7 @@
EXECUTABLE = helloworld-c-make EXECUTABLE = helloworld-c-make
INSTALL_PREFIX = /usr/local
CFLAGS = -std=c17 -Wall -Wextra -pedantic -pedantic-errors -O2 CFLAGS = -std=c17 -Wall -Wextra -pedantic -pedantic-errors -O2
LFLAGS =
LD=gcc
CC=gcc
SOURCE_FILES = \ SOURCE_FILES = \
src/main.c src/main.c
@ -18,11 +12,8 @@ HEADER_FILES = $(shell find src/ -name *.h)
all: build/$(EXECUTABLE) build/compile_flags.txt all: build/$(EXECUTABLE) build/compile_flags.txt
install: build/$(EXECUTABLE)
cp build/$(EXECUTABLE) $(INSTALL_PREFIX)/bin/$(EXECUTABLE)
build/$(EXECUTABLE): $(OBJECT_FILES) build/$(EXECUTABLE): $(OBJECT_FILES)
$(LD) -o $@ $(LFLAGS) $^ $(CC) -o $@ $(LDFLAGS) $^
build/%.o: src/%.c $(HEADER_FILES) build-folder build/%.o: src/%.c $(HEADER_FILES) build-folder
$(CC) -c -o $@ $(CFLAGS) $< $(CC) -c -o $@ $(CFLAGS) $<
@ -31,7 +22,7 @@ build-folder:
mkdir -p build/ mkdir -p build/
clean: clean:
$(RM) build/ rm -rf build/
build/compile_flags.txt: build/compile_flags.txt:
echo -xc $(CFLAGS) \ echo -xc $(CFLAGS) \

View File

@ -9,9 +9,7 @@ make
``` ```
make make
sudo make install sudo cp build/helloworld-c-make /usr/local/bin/
# or
sudo make INSTALL_PREFIX=/usr/local install
helloworld-c-make helloworld-c-make
``` ```