Makefile : How to install a project with a file pkg-config

1k views Asked by At

I am trying to make a clean install of my c++ project :

  • exports the .h inside an include/ dir
  • compile a .dylib (macos) or .so (ubuntu) inside a lib/ dir

Now the question is : How do I write/export a pkg-config .pc file, with the makefile, that will correspond to my project. In Mac OS and Linux, so I can just call

LDFLAGS=$(shell pkg-config --libs my_project) 
CPPFLAGS=$(shell pkg-config --cflags my_project)

In other makefiles, to get the flags to include.

This is what I done so far (macos):

install : $(OBJS)
  mkdir -p $(INSTALL_LIB_DIR)
  $(CXX) -dynamiclib $^ $(CPPFLAGS) $(LDFLAGS) -o $(INSTALL_LIB_DIR)/lib$(ENGINE_LIB_NAME).dylib
  mkdir -p include
  cp src/*.h include/
  cp src/*.tpp include/
  mv include $(INSTALL_DIR)
  rm -rf include
  rm -rf lib

uninstall:
  @echo "Removing dir " $(INSTALL_DIR)
  rm -r $(INSTALL_DIR)

Thank you very much. If it can't be done, I will look into doing that with cmake instead...

0

There are 0 answers