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
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)
CFLAGS = -std=c99 -g -Wall -Wextra -Werror -I$(ERL_EI_INCLUDE)
LDFLAGS = -L/usr/include/linux/ -L$(ERL_EI_LIB) -lm -lmagic -lei -lpthread
HEADER_FILES = src
C_SOURCE_FILES = src/apprentice.c
OBJECT_FILES = $(C_SOURCE_FILES:.c=.o)
EXECUTABLE_DIRECTORY = priv
EXECUTABLE = $(EXECUTABLE_DIRECTORY)/apprentice
CFLAGS = -std=c99 -g -Wall -Werror -I$(ERL_EI_INCLUDE)
LDLIBS = -L$(ERL_EI_LIB) -lpthread -lei -lm -lmagic
BEAM_FILES = _build/
PRIV = priv/
RM = rm -Rf
# Unit test custom magic file
@ -18,20 +16,9 @@ TEST_DIRECTORY = test
TARGET_MAGIC = $(TEST_DIRECTORY)/elixir.mgc
SOURCE_MAGIC = $(TEST_DIRECTORY)/elixir
# Target
all: $(EXECUTABLE) $(TARGET_MAGIC)
# Compile
$(EXECUTABLE): $(OBJECT_FILES) $(EXECUTABLE_DIRECTORY)
$(CC) $(OBJECT_FILES) -o $@ $(LDFLAGS)
$(EXECUTABLE_DIRECTORY):
mkdir -p $(EXECUTABLE_DIRECTORY)
.o:
$(CC) $(CFLAGS) $< -o $@
priv/apprentice: src/apprentice.c
mkdir -p priv
$(CC) $(CFLAGS) $(LDLIBS) $^ -o $@
# Test case
@ -39,4 +26,6 @@ $(TARGET_MAGIC): $(SOURCE_MAGIC)
cd $(TEST_DIRECTORY); $(MAGIC) -C -m elixir
clean:
rm -f $(EXECUTABLE) $(OBJECT_FILES) $(BEAM_FILES)
$(RM) $(PRIV) $(BEAM_FILES)
.PHONY: clean