Commit 3a6efbe8 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 35097326
...@@ -9,21 +9,21 @@ INCLUDE_PYTHON=-I$(shell python3 -c "import sysconfig; print(sysconfig.get_path( ...@@ -9,21 +9,21 @@ INCLUDE_PYTHON=-I$(shell python3 -c "import sysconfig; print(sysconfig.get_path(
ifneq ($(FMTLIB_PATH),) ifneq ($(FMTLIB_PATH),)
INCLUDE_FMTLIB = -I$(FMTLIB_PATH)/include 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 RUNPATH_FMTLIB = -Wl,-rpath,$(FMTLIB_PATH)/lib
endif endif
ifeq ($(LIBRARY_FMTLIB),) #ifeq ($(LIBRARY_FMTLIB),)
LIBRARY_FMTLIB = -lfmt # LIBRARY_FMTLIB = -lfmt
endif #endif
ifneq ($(OPENSSL_PATH),) ifneq ($(OPENSSL_PATH),)
INCLUDE_OPENSSL = -I$(OPENSSL_PATH)/include 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 RUNPATH_OPENSSL = -Wl,-rpath,$(OPENSSL_PATH)/lib
endif endif
ifeq ($(LIBRARY_OPENSSL),) #ifeq ($(LIBRARY_OPENSSL),)
LIBRARY_OPENSSL = -lcrypto # LIBRARY_OPENSSL = -lcrypto
endif #endif
INCLUDE_DIRS = $(INCLUDE_PYTHON) $(INCLUDE_FMTLIB) $(INCLUDE_OPENSSL) INCLUDE_DIRS = $(INCLUDE_PYTHON) $(INCLUDE_FMTLIB) $(INCLUDE_OPENSSL)
LIBRARY_DIRS = $(LIBRARY_FMTLIB) $(LIBRARY_OPENSSL) LIBRARY_DIRS = $(LIBRARY_FMTLIB) $(LIBRARY_OPENSSL)
...@@ -35,36 +35,44 @@ RUNPATHS = $(RUNPATH_FMTLIB) $(RUNPATH_OPENSSL) ...@@ -35,36 +35,44 @@ RUNPATHS = $(RUNPATH_FMTLIB) $(RUNPATH_OPENSSL)
#EXE = main #EXE = main
#CXX = g++ #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 #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_SUFFIX := $(shell python3 -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
EXT = $(EXE)$(EXT_SUFFIX) EXT = $(EXE)$(EXT_SUFFIX)
# Build without Python runtime # Build without Python runtime
all: main.cpp#$(EXE) all: metadata-collect-agent
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
%.cpp: %.pyx %.cpp: %.pyx
$(info "[Cython Compiling $^ -> $@]")
@echo "[Cython Compiling $^ -> $@]" @echo "[Cython Compiling $^ -> $@]"
python3 -c "from Cython.Compiler.Main import main; main(command_line=1)" $^ --cplus -3 python3 -c "from Cython.Compiler.Main import main; main(command_line=1)" $^ --cplus -3
@rm -f $(subst .cpp,.h,$@) @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 $^ -> $@]" @echo "[C++ Compiling $^ -> $@]"
$(info LINK.cpp = $(LINK.cpp)) $(info LINK.cpp = $(LINK.cpp))
$(info ^ = $^) $(info ^ = $^)
$(info LOADLIBES = $(LOADLIBES)) $(info LOADLIBES = $(LOADLIBES))
$(info LDLIBS = $(LDLIBS)) $(info LDLIBS = $(LDLIBS))
$(info @ = $@) $(info @ = $@)
$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ $(LINK.cpp) $^ $(INCLUDE_DIRS) $(LOADLIBES) $(LDLIBS) -o $@
.PHONY: all .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