aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-16 15:10:39 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-16 15:10:39 +0200
commitb79b9971471256bfb4bde919cd89ae164744eaba (patch)
tree1346befacd6f1c9a594149cd3f4738f299f84d7d
parentChange (diff)
downloadlowbat-bsd-b79b9971471256bfb4bde919cd89ae164744eaba.tar.gz
lowbat-bsd-b79b9971471256bfb4bde919cd89ae164744eaba.tar.bz2
lowbat-bsd-b79b9971471256bfb4bde919cd89ae164744eaba.tar.xz
lowbat-bsd-b79b9971471256bfb4bde919cd89ae164744eaba.tar.zst
lowbat-bsd-b79b9971471256bfb4bde919cd89ae164744eaba.zip
Learning BSD make
-rw-r--r--.gitignore4
-rw-r--r--Makefile52
-rw-r--r--src/jo_main.c8
-rw-r--r--src/jo_main.h6
-rw-r--r--src/jo_printf.c8
-rw-r--r--src/jo_printf.h6
6 files changed, 75 insertions, 9 deletions
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 <jo_main.h>
+
+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 <jo_printf.h>
+
+#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 <stdio.h>
+#include <jo_printf.h>
+
+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