Commit 21b10826 authored by Ophélie Gagnard's avatar Ophélie Gagnard

[Buildout partially WORKS] installation/metadata-collect-agent/Makefile:...

[Buildout partially WORKS] installation/metadata-collect-agent/Makefile: Reorganize the Makefile to make it work with more standard parameters.
parent b299c47c
......@@ -9,21 +9,21 @@ INCLUDE_PYTHON=-I$(shell python3 -c "import sysconfig; print(sysconfig.get_path(
ifneq ($(FMTLIB_PATH),)
INCLUDE_FMTLIB = -I$(FMTLIB_PATH)/include
LIBRARY_FMTLIB = -lfmt -L$(FMTLIB_PATH)/lib
LIBRARY_FMTLIB = -L$(FMTLIB_PATH)/lib
RUNPATH_FMTLIB = -Wl,-rpath,$(FMTLIB_PATH)/lib
endif
ifeq ($(LIBRARY_FMTLIB),)
LIBRARY_FMTLIB = -lfmt
endif
#ifeq ($(LIBRARY_FMTLIB),)
# LIBRARY_FMTLIB = -lfmt
#endif
ifneq ($(OPENSSL_PATH),)
INCLUDE_OPENSSL = -I$(OPENSSL_PATH)/include
LIBRARY_OPENSSL = -lcrypto -L$(OPENSSL_PATH)/lib
LIBRARY_OPENSSL = -L$(OPENSSL_PATH)/lib
RUNPATH_OPENSSL = -Wl,-rpath,$(OPENSSL_PATH)/lib
endif
ifeq ($(LIBRARY_OPENSSL),)
LIBRARY_OPENSSL = -lcrypto
endif
#ifeq ($(LIBRARY_OPENSSL),)
# LIBRARY_OPENSSL = -lcrypto
#endif
INCLUDE_DIRS = $(INCLUDE_PYTHON) $(INCLUDE_FMTLIB) $(INCLUDE_OPENSSL)
LIBRARY_DIRS = $(LIBRARY_FMTLIB) $(LIBRARY_OPENSSL)
......@@ -35,36 +35,44 @@ RUNPATHS = $(RUNPATH_FMTLIB) $(RUNPATH_OPENSSL)
#EXE = main
#CXX = g++
#CPPFLAGS = -O2 -g -Wno-unused-result -Wsign-compare -pthread $(INCLUDE_DIRS)
#CPPFLAGS = -O2 -g -Wno-unused-result -Wsign-compare -pthread $(INCLUDE_DIRS) $(LDLIBS) $(LIBRARY_DIRS) $(RUNPATHS)
CPPFLAGS = -pthread
#LDFLAGS += -Wl,--unresolved-symbols=ignore-all
#LDLIBS = -lcrypto -lfmt
LDFLAGS = $(LIBRARY_DIRS) $(RUNPATHS)
LDLIBS = -lcrypto -lfmt
EXT_SUFFIX := $(shell python3 -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
EXT = $(EXE)$(EXT_SUFFIX)
# Build without Python runtime
all: main.cpp#$(EXE)
mkdir -p logs
# Error expected here, writing a C program using the error messages
-g++ -O2 -g -Wno-unused-result -Wsign-compare -pthread $(INCLUDE_DIRS) $(LDLIBS) $(LIBRARY_DIRS) $(RUNPATHS) main.cpp -o main 2> logs/link_errors
./parse_link_errors.py < logs/link_errors
make fake_python.o
g++ -O2 -g -Wno-unused-result -Wsign-compare -pthread $(INCLUDE_DIRS) $(LDLIBS) $(LIBRARY_DIRS) $(RUNPATHS) main.cpp fake_python.o -o metadata-collect-agent
#-ln -f ../../metadata-collect-agent metadata-collect-agent
#-ln -f metadata-collect-agent ../../dracut.module/90metadata-collect/metadata-collect-agent
#-ln -f metadata-collect-agent ../../debian.package.unsafe/unsafe-boot-metadata-collect-agent/sbin/metadata-collect-agent
all: metadata-collect-agent
%.cpp: %.pyx
$(info "[Cython Compiling $^ -> $@]")
@echo "[Cython Compiling $^ -> $@]"
python3 -c "from Cython.Compiler.Main import main; main(command_line=1)" $^ --cplus -3
@rm -f $(subst .cpp,.h,$@)
%: %.cpp
fake_python.c: main.cpp
$(info "[Generating fake_python.c]")
@echo "[Generating fake_python.c]"
mkdir -p logs
#-g++ -O2 -g -Wno-unused-result -Wsign-compare -pthread $(INCLUDE_DIRS) main.cpp -o main 2> logs/link_errors
-$(LINK.cpp) $^ $(INCLUDE_DIRS) $(LOADLIBES) $(LDLIBS) -o $@ 2> logs/link_errors
./parse_link_errors.py < logs/link_errors
fake_python.o: fake_python.c
$(info @echo "[Generating fake_python.o]")
@echo "[Generating fake_python.o]"
gcc -c fake_python.c -o fake_python.o
metadata-collect-agent: main.cpp fake_python.o
$(info "[C++ Compiling $^ -> $@]")
@echo "[C++ Compiling $^ -> $@]"
$(info LINK.cpp = $(LINK.cpp))
$(info ^ = $^)
$(info LOADLIBES = $(LOADLIBES))
$(info LDLIBS = $(LDLIBS))
$(info @ = $@)
$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@
$(LINK.cpp) $^ $(INCLUDE_DIRS) $(LOADLIBES) $(LDLIBS) -o $@
.PHONY: all
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment