Run configure in gyp file

With gyp actions and 'target_type': none it might look like this:

   {
        'target_name': 'FTGL',
        'type': 'none',
        'dependencies': ['FreeType'],
        'actions': [
            {
                'action_name': 'build_ftgl',
                'message': 'Building FTGL...',
                'inputs': ['ftgl/src/FTGL/ftgl.h'],
                'outputs': ['ftgl/src/.libs/libftgl.a'],
                'action': ['eval', 'cd ftgl && ./configure --with-pic && make -C src'],
            },
        ],
  }

Note: using eval in the action allows to run multiple commands


You can execute arbitrary commands within gyp using command line expansion. However as you noted, this isn't reliable if you want to be cross-platform.

Typically if you want it to be cross-platform, you will need to "gyp-ify" your dependency. This means creating a separate gyp file that is included as a dependency gyp in your main binding.gyp. This can take some time because you have to list all of the source files that are to be compiled and you have to also add any necessary library-specific compilation flags (e.g. if a library makes use of compile-time defines like -Dfoo).

You might also consider making the dependency dynamic instead of bundling the source for the library you're wrapping and just dynamically linking with the library. This is much easier since you don't have to "gyp-ify" the library and you just have to add a few things like libraries: ['-lfoo'] to your binding.gyp.