Minimize makefile to only output object files

This commit is contained in:
Alex D. 2021-11-13 17:37:31 +00:00
parent d5e21f6b8e
commit 85e981f29c
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/dynarray.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 = dynarray.c
HDR = dynarray.h