Initial templates

This commit is contained in:
Alex D. 2021-11-21 17:06:20 +00:00
commit a72e2868b9
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
4 changed files with 121 additions and 0 deletions

18
c/Makefile Normal file
View File

@ -0,0 +1,18 @@
include config.mk
OBJ = ${SRC:.c=.o}
all: ${OBJ} ${BIN}
%.o: %.c
${CC} -o $@ -c ${CFLAGS} $<
clean:
rm -f ${OBJ} ${BIN}
ifneq (${BIN},)
${BIN}: ${OBJ}
${CC} -o "$@" ${LDFLAGS} $^
endif
.PHONY: all clean

43
c/config.mk Normal file
View File

@ -0,0 +1,43 @@
# Defaults
CXX = clang
DEBUG = 1
STATIC = 0
LDFLAGS =
CXXFLAGS =\
-std=c99\
-Weverything\
-Wno-padded\
-Wno-disabled-macro-expansion\
-pedantic
# Sources / Results
SRC =\
src/project/main.c
LIBDIR =
LIB =\
c
INCDIR =\
src/project/
BIN = project
# Conditionals / Appends
LDFLAGS +=\
$(addprefix -L,${LIBDIR})\
$(addprefix -l,${LIB})
CXXFLAGS +=\
$(addprefix -I,${INCDIR})
ifeq (${DEBUG},1)
CXXFLAGS += -g
else
CXXFLAGS += -O2 -Werror
endif
ifeq (${STATIC},1)
LDFLAGS += -static
endif

18
cxx/Makefile Normal file
View File

@ -0,0 +1,18 @@
include config.mk
OBJ = ${SRC:.cpp=.o}
all: ${OBJ} ${BIN}
%.o: %.cpp
${CXX} -o $@ -c ${CXXFLAGS} $<
clean:
rm -f ${OBJ} ${BIN}
ifneq (${BIN},)
${BIN}: ${OBJ}
${CXX} -o "$@" ${LDFLAGS} $^
endif
.PHONY: all clean

42
cxx/config.mk Normal file
View File

@ -0,0 +1,42 @@
# Defaults
CXX = clang++
DEBUG = 1
STATIC = 0
LDFLAGS =
CXXFLAGS =\
-Weverything\
-Wno-padded\
-Wno-disabled-macro-expansion\
-pedantic
# Sources / Results
SRC =\
src/project/main.cpp
LIBDIR =
LIB =\
stdc++
INCDIR =\
src/project/
BIN = project
# Conditionals / Appends
LDFLAGS +=\
$(addprefix -L,${LIBDIR})\
$(addprefix -l,${LIB})
CXXFLAGS +=\
$(addprefix -I,${INCDIR})
ifeq (${DEBUG},1)
CXXFLAGS += -g
else
CXXFLAGS += -O2 -Werror
endif
ifeq (${STATIC},1)
LDFLAGS += -static
endif