UseInMake - npackd/npackd GitHub Wiki

Using Npackd in GNU Make build scripts

Npackd can be easily integrated with GNU Make. It is recommended to choose the shell by setting the SHELL variable:

SHELL:=cmd.exe

The call to the built-in shell function below stores the location of the GCC package in the Make variable named MINGW.

MINGW=$(shell "$(NPACKD_CL)\npackdcl.exe" "path" "--package=mingw-w64-i686-sjlj-posix" "--versions=[4.9.2, 4.9.2]")

Note that the usage of unbalanced parenthesis is more complicated in Make. In the following example the variable RPAREN is defined in order to avoid putting the right parenthesis itself.

RPAREN=)
AI=$(shell "$(NPACKD_CL)\npackdcl.exe" "path" "--package=com.advancedinstaller.AdvancedInstallerFreeware" "--versions=[10, 20$(RPAREN)")

Once you have the location in a variable, you can use it in commands to have a reproducible build environment.

# rem note how && directly follows \bin. Otherwise the path would contain a space
compile: 
	set path=$(MINGW)\bin&&set quazip_path=$(QUAZIP)&& cd $(WHERE)\.. && "$(QT)\qtbase\bin\qmake.exe" ..\..\src\wpmcpp.pro -r -spec win32-g++ CONFIG+=$(CONFIG)

If you need different packages for different build options, you could use the if directive:

ifeq (32,$(findstring 32,$(PROFILE)))
MINGW=$(shell "$(NPACKD_CL)\npackdcl.exe" "path" "--package=mingw-w64-i686-sjlj-posix" "--versions=[4.9.2, 4.9.2]")
else
MINGW=$(shell "$(NPACKD_CL)\npackdcl.exe" "path" "--package=mingw-w64-x86_64-seh-posix" "--versions=[4.9.2, 4.9.2]")
endif