1

overwiew

I want to use nmake on windows however got stuck with ifeq not being supported to achieve something I am trying to get. OS detecting makefile

workaround

To workaround the ifeq incompatibility, I decided to use $(OS) attribute.

include platf/$(OS)_make
  • windows it is supposed to include platf/Windows_NT_make
  • other platforms where $(OS) returns "", so uses file platf/_make

Directory layout

|   Makefile
+---platf
|       Makefile.linux
|       Makefile.macos
|       Makefile.win
|       Windows_NT_make
|       _make

problem

  • _make, I have the same routine from OS detecting makefile and include Makefile for linux, or mac etc
  • Windows_NT_make includes Makefile.win

This works like charm, except windows again.

#1 If the file platf/Windows_NT_make IS present, it complains with

makefile(4) : fatal error U1052: file 'platf/$(OS)_make' not found

#2 If the file platf/Windows_NT_make IS NOT present, it complains with

makefile(4) : fatal error U1052: file 'platf/Windows_NT_make' not found

Question

So, if nmake is able to decide what would be the value of $(OS) is (seen from #2), why it complains with #1

Community
  • 1
  • 1
Firat
  • 133
  • 1
  • 2
  • 8

1 Answers1

0

The problem is the slash character that delineates the platf directory from the Makefile name. It needs to be "/" for unix family and "\" for Windows.

You need to know which OS to correctly form the name. This can be solved in a couple of ways:

  1. Not using a subdirectory
  2. Doing a separate CD so names are local

I solve the problem by having one makefile and using a portable script file to determine the OS and edit the Makefile (using sed) appropriately. With one script and one makefile I can move across all systems.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129