chore: added makefile

main
Jef Roosens 2023-01-18 11:29:16 +01:00
parent f50bc4a3c4
commit 4d72e60515
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
5 changed files with 45 additions and 2 deletions

2
.gitignore vendored 100644
View File

@ -0,0 +1,2 @@
build/
compile_commands.json

41
Makefile 100644
View File

@ -0,0 +1,41 @@
LIB_FILENAME ?= libvieter.a
BUILD_DIR ?= build
SRC_DIR ?= src
INC_DIRS ?= include
SRCS != find '$(SRC_DIR)' -iname '*.c'
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(SRCS:%=$(BUILD_DIR)/%.d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
# -MMD: generate a .d file for every source file. This file can be imported by
# make and makes make aware that a header file has been changed, ensuring an
# object file is also recompiled if only a header is changed.
# -MP: generate a dummy target for every header file (according to the docs it
# prevents some errors when removing header files)
CFLAGS ?= $(INC_FLAGS) -O3 -MMD -MP -Wall -Werror -Wextra
.PHONY: all
all: vieter
# =====COMPILATION=====
.PHONY: vieter
vieter: $(BUILD_DIR)/$(LIB_FILENAME)
$(BUILD_DIR)/$(LIB_FILENAME): $(OBJS)
ar -rcs $@ $(OBJS)
$(BUILD_DIR)/%.c.o: %.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
# Make make aware of the .d files
-include $(DEPS)

View File

@ -1,4 +1,4 @@
#include "expression.h"
#include "vieter_cron.h"
#include <time.h>
const uint8_t month_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

View File

@ -1,4 +1,4 @@
#include "expression.h"
#include "vieter_cron.h"
// This prefix is needed to properly compile
const uint8_t parse_month_days[] = {31, 28, 31, 30, 31, 30,