0

I'm very new to Makefiles and I try to migrate this Makefile written for Linux (make) to a windows environment (nmake). I did not write this file so obviously I'm also trying to figure out the meaning of those lines.

Any chance you'd help me with the "translation" ?

DIR = src


BIN_PATH_DEST = /usr/local/bin
LIB_PATH_DEST = /usr/local/libs

CFLAGS = -DDISPLAY_TIME -DWRITE_TXT_FILES -DDISPLAY_BOUNDINGBOX

libs/libenvis3D_co.a:
    cd $(DIR); make CFLAGS="$(CFLAGS)" ../libs/libenvis3D_co.a

bin/geobox_envis3D_co: main3D_co.c libs/libenvis3D_co.a
    gcc -Wall $(CFLAGS) main3D_co.c libs/libenvis3D_co.a -lm -llapack -o bin/geobox_envis3D_co

install3D_co: bin/geobox_envis3D_co
    cd $(DIR); make CFLAGS="$(CFLAGS)" ../libs/libenvis3D_co.a
    make bin/geobox_envis3D_co
    cp bin/geobox_envis3D_co $(BIN_PATH_DEST)

clean:
    cd $(DIR); make clean

I also tried to download and use GNU make as described in this page : How to run a makefile in Windows? but I'm being throw the error :

C:\users\...>make -f Makefile
cd src; make CFLAGS="-DDISPLAY_TIME -DWRITE_TXT_FILES -DDISPLAY_BOUNDINGBOX" ../libs/libenvis3D_co.a
Le chemin d’accès spécifié est introuvable. (path to file not found).
make: *** [libs/libenvis3D_co.a] Erreur 1

Thanks for your input and help !

LaTouwne
  • 144
  • 1
  • 5
  • `nmake` is not an implementation of POSIX make. It's a fairly different, incompatible tool that has a similar name. – MadScientist Mar 26 '21 at 14:17
  • Agreed, that's why I'm trying to translate it to be nmake compatible, or GNU make compatible, which I expected to work better tbh – LaTouwne Mar 26 '21 at 14:34
  • That is not a standalone makefile. It relies on another one residing in subdirectory `src`. It also assumes compilation with gcc, which would be unusual on Windows (but not out of the question). There is a variety of other reasons why a Makefile intended for a POSIX environment might not work in Windows, even with GNU `make`. These are consequences of differences between the two environments and the specifics of the makefile(s), not attributable to `make` itself. – John Bollinger Mar 26 '21 at 15:39
  • 1
    It's not enough to use a compatible make. Makefiles are just tools that run other commands. You also have to port the commands make runs. Linux (and MacOS) are POSIX systems and use a POSIX shell, and make runs its commands in a POSIX shell. Windows doesn't have a POSIX shell (by default), it has command.com which is not compatible. So, make commands that rely on POSIX shell syntax, like `cd src; make ...` won't work on Windows unless you either rewrite them for command.com or else install a POSIX shell and get make to use it instead. – MadScientist Mar 26 '21 at 16:02
  • consider using `Msys2` environment – igagis Mar 31 '21 at 00:39

0 Answers0