This example is a hello package written in C that has a shared library and a makefile. The makefile simplifies the build instructions because it takes care of installing the files. However, the makefile will still need to get location information from GPT in order to install the files correctly. The normal way to do this is by passing in shell variables when make is invoked.
Here is the makefile. It includes the normal makefile targets for building and installing C code:
INSTALL_LOCATION=/usr/local .c.o : cc -I . -c $< all: hello-world-c hello-world-c: hello-world.o libhello_world.so cc -o $@ hello-world.o -L. -lhello_world libhello_world.so: libhello_world.c libhello_world.h cc -o $@ -shared libhello_world.c install: hello-world-install hello-world-install: mkdir -p $(INSTALL_LOCATION)/bin cp hello-world-c $(INSTALL_LOCATION)/bin chmod 755 $(INSTALL_LOCATION)/bin/hello-world-c mkdir -p $(INSTALL_LOCATION)/lib cp libhello_world.so $(INSTALL_LOCATION)/lib mkdir -p $(INSTALL_LOCATION)/include cp libhello_world.h $(INSTALL_LOCATION)/include clean: rm -f *.o hello-world-c libhello_world.so
The installation location is stored in the shell variable $INSTALL_LOCATION. The variable is set via a GPT macro with the following build instructions:
<Build_Instructions> <Build_Step>make INSTALL_LOCATION=INSTALLDIR_GPTMACRO</Build_Step> <Build_Step>make install INSTALL_LOCATION=INSTALLDIR_GPTMACRO</Build_Step> </Build_Instructions>
The complete set of files for this package can be found here.