On 16/01/2020 13.20, Mihir Luthra wrote: > I was trying to add some code to a new directory in macports-base/src/ dir > such > that I can use it in both porttrace.tcl(as a tcl cmd) and darwintrace.c. > > Basically it is a library that needs to be dynamically generated(because it > uses > `__attribute__((constructor))`) > > I see 2 choices: > > 1) To generate .o files in the new directory and use those in > darwintracelib1.0 > and pextlib1.0. As both darwintrace and pextlib are ultimately dynamic > libraries, it should work I suppose. > > 2) To create a separate dylib file which I am not sure how to handle linking > to > both darwintrace code and pextlib. Like what are the standard lib storage > locations for macports src? Should I simply add it to tcl package path and > link > it in Makefiles of both darwintracelib and pextlib? > > What would be the right way to do this? Also, is there any reference on how to > conform to macports Makefile structure?
Without taking a closer look, I think there is only one other file that is shared between darwintrace and pextlib. Unfortunately, there is no good solution to this in the current structure. What it currently does is to copy the *.c file around during compilation, but I think this is a really horrible workaround. I think the better option would be to have a new subdirectory for a library with the shared code that is then linked (statically) into both darwintrace and pextlib. Rainer
