Makefile basic

This commit is contained in:
Christoph J. Scherr 2022-11-26 20:07:41 +01:00
parent e6a053cac6
commit a1f531467b
1 changed files with 18 additions and 21 deletions

View File

@ -1,23 +1,20 @@
# see https://opensource.com/article/18/8/what-how-makefile #SOURCES = $(wildcard *.c)
# Usage: #BINARIES = $(SOURCES:%.c=%)
# make # compile all binary #CFLAGS = -g
# make clean # remove ALL binaries and objects #CC = gcc
#
#all: pre $(BINARIES)
#
#pre:
# @mkdir -p bin huffman/bin huffman/testfiles
#
SOURCES = $(wildcard *.c)
BINARIES = $(SOURCES:%.c=%)
EXECUTABLES= $(addprefix bin/,${BINARIES})
all: pre $(EXECUTABLES)
.PHONY = all clean pre:
@mkdir -p bin
SRCS := $(wildcard *.c) $(EXECUTABLES): $(SOURCES)
BINS := $(SRCS:%.c=%) $(CC) $(CFLAGS) -o $@ $< -lm
all: ${BINS}
%: %.o
@echo "Linking..."
gcc $< -o bin/$@ -lm
%.o: %.c
echo "Creating object..."
gcc -c $< -o obj/
clean:
@echo "Cleaning up..."
rm -rvf *.o ${BINS}