From b79b9971471256bfb4bde919cd89ae164744eaba Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 16 Apr 2020 15:10:39 +0200 Subject: Learning BSD make --- .gitignore | 4 +++- Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- src/jo_main.c | 8 ++++++++ src/jo_main.h | 6 ++++++ src/jo_printf.c | 8 ++++++++ src/jo_printf.h | 6 ++++++ 6 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 src/jo_main.c create mode 100644 src/jo_main.h create mode 100644 src/jo_printf.c create mode 100644 src/jo_printf.h diff --git a/.gitignore b/.gitignore index 0ceb8f3..8f17a84 100644 --- a/.gitignore +++ b/.gitignore @@ -125,4 +125,6 @@ flycheck_*.el # End of https://www.gitignore.io/api/c,linux,emacs,assembler -*.core \ No newline at end of file +*.core +.depend +*.tmp \ No newline at end of file diff --git a/Makefile b/Makefile index 92d1631..982a772 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,61 @@ default: all - +SHELL := /bin/sh # ============================================ DIRS ============================================== # -SRCS_DIR = src/ -OBJS_DIR = obj/ -ASRCS_DIR = asm/ -AOBJS_DIR = asmobj/ +SRCS_DIR = src +ASRCS_DIR = asm +# ------------------------------------------------------------------------------------------------ # +OBJS_DIR = obj +AOBJS_DIR = asmobj # =========================================== FILES ============================================== # - +SRCS = ${SRCS_DIR}/jo_main.c +SRCS += ${SRCS_DIR}/jo_printf.c # ========================================== COMPILER ============================================ # CC = clang +# ------------------------------------------------------------------------------------------------ # CFLAGS = -std=c89 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror CFLAGS += -pedantic # CFLAGS += -O2 -pipe +# ------------------------------------------------------------------------------------------------ # +NAME = lowbat # ========================================== ASSEMBLER =========================================== # ASM = nasm ASMFLAGS = -f ASMARCH = elf64_fbsd +# ============================================ UNIX ============================================== # +RM = rm -rf +MKDIR = mkdir +CP = cp +MV = mv +AWK = awk -F +SED = sed # ============================================ RULES ============================================= # -all: - ${CC} +# .include "./.depend" + +depend: + pwd + ${CC} -I${SRCS_DIR}/ -E -MM ${SRCS} > .depend + +config: + ${MKDIR} ${OBJS_DIR} + ${SED} 's/^/${OBJS_DIR}\//' .depend > .depend.tmp + ${MV} .depend.tmp .depend + +all: depend config + +clean: + ${RM} ${OBJS_DIR} + ${RM} ${AOBJS_DIR} + ${RM} ${NAME}.core + ${RM} .depend + ${RM} .depend.tmp + +fclean: clean + ${RM} ${NAME} + +re: fclean all + +.PHONY: all clean fclean re depend config diff --git a/src/jo_main.c b/src/jo_main.c new file mode 100644 index 0000000..ee3c400 --- /dev/null +++ b/src/jo_main.c @@ -0,0 +1,8 @@ +#include + +int +main(void) +{ + jo_printf(); + return (0); +} diff --git a/src/jo_main.h b/src/jo_main.h new file mode 100644 index 0000000..3a3359c --- /dev/null +++ b/src/jo_main.h @@ -0,0 +1,6 @@ +#ifndef JO_MAIN_H +#define JO_MAIN_H + +#include + +#endif diff --git a/src/jo_printf.c b/src/jo_printf.c new file mode 100644 index 0000000..facdaa1 --- /dev/null +++ b/src/jo_printf.c @@ -0,0 +1,8 @@ +#include +#include + +void +jo_printf(void) +{ + printf("Hey!\n"); +} diff --git a/src/jo_printf.h b/src/jo_printf.h new file mode 100644 index 0000000..60fdc99 --- /dev/null +++ b/src/jo_printf.h @@ -0,0 +1,6 @@ +#ifndef JO_PRINTF_H +#define JO_PRINTF_H + +void jo_printf(void); + +#endif -- cgit v1.2.3