Makefile basic
This commit is contained in:
parent
e6a053cac6
commit
a1f531467b
39
Makefile
39
Makefile
|
@ -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}
|
|
||||||
|
|
Loading…
Reference in New Issue