Merge remote-tracking branch 'kleidukos/makefile-rework' into develop

This commit is contained in:
Jordan Bracco 2020-05-13 20:29:43 +02:00
commit 5ca893aab4

View file

@ -3,13 +3,11 @@
CC = gcc CC = gcc
ERL_EI_INCLUDE:=$(shell erl -eval 'io:format("~s", [code:lib_dir(erl_interface, include)])' -s init stop -noshell | head -1) ERL_EI_INCLUDE:=$(shell erl -eval 'io:format("~s", [code:lib_dir(erl_interface, include)])' -s init stop -noshell | head -1)
ERL_EI_LIB:=$(shell erl -eval 'io:format("~s", [code:lib_dir(erl_interface, lib)])' -s init stop -noshell | head -1) ERL_EI_LIB:=$(shell erl -eval 'io:format("~s", [code:lib_dir(erl_interface, lib)])' -s init stop -noshell | head -1)
CFLAGS = -std=c99 -g -Wall -Wextra -Werror -I$(ERL_EI_INCLUDE) CFLAGS = -std=c99 -g -Wall -Werror -I$(ERL_EI_INCLUDE)
LDFLAGS = -L/usr/include/linux/ -L$(ERL_EI_LIB) -lm -lmagic -lei -lpthread LDLIBS = -L$(ERL_EI_LIB) -lpthread -lei -lm -lmagic
HEADER_FILES = src BEAM_FILES = _build/
C_SOURCE_FILES = src/apprentice.c PRIV = priv/
OBJECT_FILES = $(C_SOURCE_FILES:.c=.o) RM = rm -Rf
EXECUTABLE_DIRECTORY = priv
EXECUTABLE = $(EXECUTABLE_DIRECTORY)/apprentice
# Unit test custom magic file # Unit test custom magic file
@ -18,20 +16,9 @@ TEST_DIRECTORY = test
TARGET_MAGIC = $(TEST_DIRECTORY)/elixir.mgc TARGET_MAGIC = $(TEST_DIRECTORY)/elixir.mgc
SOURCE_MAGIC = $(TEST_DIRECTORY)/elixir SOURCE_MAGIC = $(TEST_DIRECTORY)/elixir
# Target priv/apprentice: src/apprentice.c
mkdir -p priv
all: $(EXECUTABLE) $(TARGET_MAGIC) $(CC) $(CFLAGS) $(LDLIBS) $^ -o $@
# Compile
$(EXECUTABLE): $(OBJECT_FILES) $(EXECUTABLE_DIRECTORY)
$(CC) $(OBJECT_FILES) -o $@ $(LDFLAGS)
$(EXECUTABLE_DIRECTORY):
mkdir -p $(EXECUTABLE_DIRECTORY)
.o:
$(CC) $(CFLAGS) $< -o $@
# Test case # Test case
@ -39,4 +26,6 @@ $(TARGET_MAGIC): $(SOURCE_MAGIC)
cd $(TEST_DIRECTORY); $(MAGIC) -C -m elixir cd $(TEST_DIRECTORY); $(MAGIC) -C -m elixir
clean: clean:
rm -f $(EXECUTABLE) $(OBJECT_FILES) $(BEAM_FILES) $(RM) $(PRIV) $(BEAM_FILES)
.PHONY: clean