SURPRISE Build System Update
This commit is contained in:
parent
966b90056e
commit
d883445bd1
41
Makefile
41
Makefile
@ -1,27 +1,36 @@
|
|||||||
include chad.mk
|
include config.mk
|
||||||
DEBUG:=1
|
|
||||||
CFLAGS:=-std=c99 -O2 $(if ${DEBUG}, ${CHAD_DEBUG},'')
|
SRC.dir:=source
|
||||||
CPPFLAGS:=-D_FORTIFY_SOURCE=2
|
OBJ.dir:=obj
|
||||||
|
|
||||||
SRC.dir:=source/
|
|
||||||
SRC:=$(shell find ${SRC.dir} -iname '*.c')
|
SRC:=$(shell find ${SRC.dir} -iname '*.c')
|
||||||
HDR:=$(shell find ${SRC.dir} -iname '*.h')
|
HDR:=$(shell find ${SRC.dir} -iname '*.h')
|
||||||
OBJ:=$(subst .c,.o,${SRC})
|
OBJ:=$(SRC:.c=.o)
|
||||||
|
|
||||||
OUT:=hl
|
VPATH=${SRC.dir} ${OBJ.dir}
|
||||||
OUTARGS:=${OUT} < source/main.c
|
|
||||||
|
|
||||||
main: ${OBJ} ${HDR}
|
${OBJ.dir}/%.o: ${SRC.dir}/%.c
|
||||||
${LINK.c} ${OBJ} -o hl
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
${COMPILE.c} $< -o $@
|
${COMPILE.c} $< -o $@
|
||||||
|
|
||||||
install:
|
${TARGET}: ${OBJ} | ${HDR}
|
||||||
cp hl /usr/bin/hl
|
${LINK.c} $+ -o $@
|
||||||
|
|
||||||
|
${SRC} ${HDR}:
|
||||||
|
|
||||||
|
${PREFIX} ${OBJ.dir}:
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
install: ${PREFIX}
|
||||||
|
install -v -g ${USER} -o ${USER} -m 744 ${TARGET} ${PREFIX}/bin/
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
-rm ${PREFIX}/bin/${TARGET}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm ${OBJ}
|
-rm ${OBJ} ${TARGET}
|
||||||
-rm ${OUT}
|
|
||||||
|
|
||||||
test: chad_test
|
test: chad_test
|
||||||
|
|
||||||
|
.PHONY: test clean install
|
||||||
|
|
||||||
|
.DEFAULT_GOAL:=${TARGET}
|
||||||
|
22
chad.mk
22
chad.mk
@ -1,22 +0,0 @@
|
|||||||
# Make script for Chad projects
|
|
||||||
# This script depends on the following variables
|
|
||||||
# - OUT : output program name
|
|
||||||
# - OUTARGS : default flags to fork ${OUT} with
|
|
||||||
|
|
||||||
#
|
|
||||||
CHAD_DEBUG:=-Og -ggdb -pg -fno-inline
|
|
||||||
|
|
||||||
# Programs to check warnings for as defined by the Chad standard
|
|
||||||
GCC:=gcc
|
|
||||||
GCC.warnings:=-Wall -Wextra -Wpedantic -Wvla -Wshadow -Wundef
|
|
||||||
CLANG:=clang
|
|
||||||
CLANG.warnings:=-Weverything
|
|
||||||
VALGRIND:=valgrind
|
|
||||||
VALGRIND.flags:=--track-origins=yes --leak-check=full --show-leak-kinds=all
|
|
||||||
|
|
||||||
chad_test:
|
|
||||||
${GCC} ${GCC.warnings} ${SRC} -o ${OUT}
|
|
||||||
${CLANG} ${GCC.warnings} ${SRC} -o ${OUT}
|
|
||||||
${VALGRIND} ${VALGRIND.flags} ${OUT} ${OUTARGS}
|
|
||||||
|
|
||||||
.DEFAULT_GOAL:=main
|
|
36
config.mk
Normal file
36
config.mk
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Make script for Chad projects
|
||||||
|
# This script depends on the following variables
|
||||||
|
# - TARGET : output program name
|
||||||
|
# - ARGS : default flags to fork ${OUT} with
|
||||||
|
|
||||||
|
PREFIX:=/usr/bin
|
||||||
|
|
||||||
|
CFLAGS:=-std=c99
|
||||||
|
CPPFLAGS:=-D_GNU_SOURCE -D_FORTIFY_SOURCE=2
|
||||||
|
|
||||||
|
DEBUG=1
|
||||||
|
|
||||||
|
ifeq (${DEBUG},1)
|
||||||
|
CFLAGS += -Og -ggdb -pg -fno-inline
|
||||||
|
else
|
||||||
|
CFLAGS += -O2 -flto=auto
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Programs to check warnings for as defined by the chad standard
|
||||||
|
|
||||||
|
GCC:=gcc
|
||||||
|
GCC.warnings:=-Wall -Wextra -Wpedantic -Wvla -Wshadow -Wundef
|
||||||
|
|
||||||
|
CLANG:=clang
|
||||||
|
CLANG.warnings:=-Weverything
|
||||||
|
|
||||||
|
VALGRIND:=valgrind
|
||||||
|
VALGRIND.flags:=--track-origins=yes --leak-check=full --show-leak-kinds=all
|
||||||
|
|
||||||
|
TARGET:=hl
|
||||||
|
ARGS:=${TARGET} < source/main.c
|
||||||
|
|
||||||
|
chad_test:
|
||||||
|
${GCC} ${GCC.warnings} ${SRC} -o ${TARGET}
|
||||||
|
${CLANG} ${GCC.warnings} ${SRC} -o ${TARGET}
|
||||||
|
${VALGRIND} ${VALGRIND.flags} ${TARGET} ${ARGS}
|
@ -1,3 +1,4 @@
|
|||||||
|
#if 0
|
||||||
// Listen, this is still prototype, it's not code-merged with other stuff...
|
// Listen, this is still prototype, it's not code-merged with other stuff...
|
||||||
// Once I prototype out more stuff, this will use chad.h and hl.h...
|
// Once I prototype out more stuff, this will use chad.h and hl.h...
|
||||||
// So, this file can run on its' own when compiled, gonna rewrite later.
|
// So, this file can run on its' own when compiled, gonna rewrite later.
|
||||||
@ -244,3 +245,4 @@ int main(int argc,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
//register
|
//register
|
||||||
//putchar()
|
//putchar()
|
||||||
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -52,7 +53,8 @@ int main(int argc,
|
|||||||
buffer = realloc(buffer, ++chunks * ALLOCATION_CHUNK);
|
buffer = realloc(buffer, ++chunks * ALLOCATION_CHUNK);
|
||||||
}
|
}
|
||||||
buffer[buffer_size] = '\0';
|
buffer[buffer_size] = '\0';
|
||||||
read(STDIN_FILENO, &buffer[buffer_size], sizeof (*buffer));
|
/* TODO handle me */
|
||||||
|
assert(read(STDIN_FILENO, &buffer[buffer_size], sizeof (*buffer)) != -1);
|
||||||
++buffer_size;
|
++buffer_size;
|
||||||
} while (buffer[buffer_size - 1]);
|
} while (buffer[buffer_size - 1]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user