Minimize makefile to only output object files

This commit is contained in:
Alex D. 2021-11-13 17:38:17 +00:00
parent 9855146f8b
commit 525d0140de
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
5 changed files with 26 additions and 57 deletions

View File

@ -1,65 +1,18 @@
include config.mk
include sources.mk
ifeq (${CC},clang)
CFLAGS =\
-std=c99\
-Weverything\
-Wno-padded\
-Wno-disabled-macro-expansion\
-pedantic
ifeq (${DEBUG},1)
CFLAGS += -g
else
CFLAGS += -O2 -Werror
endif
else ifeq (${CC},gcc)
CFLAGS =\
-std=c99\
-Wall\
-Wextra\
-Wformat-overflow=2\
-Wformat-security\
-Winit-self\
-Wstrict-overflow=2\
-Wstringop-overflow=2\
-Walloc-zero\
-Wduplicated-branches\
-Wduplicated-cond\
-Wtrampolines\
-Wfloat-equal\
-Wshadow\
-Wunsafe-loop-optimizations\
-Wparentheses\
-pedantic
ifeq (${DEBUG},1)
CFLAGS += -g
else
CFLAGS += -O2 -Werror
endif
endif
CFLAGS += ${EXTRA_CFLAGS}
OBJ = ${SRC:.c=.o}
all: ${OBJ}
all: ${OBJ} ${BIN}
%.o: %.c
${CC} -c ${CFLAGS} -o $@ $<
${CC} -o $@ -c ${CFLAGS} $<
clean:
rm -f ${OBJ}
rm -f ${OBJ} ${BIN}
install: all
mkdir -p "${DESTDIR}${PREFIX}/lib/corelibs"
cp -f ${OBJ} "${DESTDIR}${PREFIX}/lib/corelibs"
mkdir -p "${DESTDIR}${PREFIX}/include/corelibs"
cp -f ${HDR} "${DESTDIR}${PREFIX}/include/corelibs"
ifneq (${BIN},)
${BIN}: ${OBJ}
${CC} -o "$@" ${LDFLAGS} $?
endif
.PHONY: all clean install
.PHONY: all clean

View File

@ -1,3 +1,21 @@
SRC = src/llist.c
BIN =
PREFIX = /usr/local
CC = clang
DEBUG = 1
LDFLAGS =\
-static
CFLAGS =\
-std=c99\
-Weverything\
-Wno-padded\
-Wno-disabled-macro-expansion\
-pedantic
ifeq (${DEBUG},1)
CFLAGS += -g
else
CFLAGS += -O2 -Werror
endif

View File

@ -1,2 +0,0 @@
SRC = llist.c
HDR = llist.h