Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

addprefix command not recognized in makefile using nmake.exe windows

all: prd.exe

CC=cl
CFLAGS=-O2 -I../src -I. /W4
LDFLAGS = /Zi
LIBSRC = $(addprefix ../lib/, \
        open.c malloc.c \
     ) \
     $(addprefix ../src/, \
        main.c \
      ) \
      helper.c

LIBOBJS = $(LIBSRC:.c=.o)

prd.exe: ../src/main.obj
$(CC) $(LDFLAGS) -Fe$@ *.o

../src/main.obj: ../src/main.c
$(CC) $(CFLAGS) $(LIBOBJS) -c $< -Fo $@ 

.c.o:
$(CC) $(CFLAGS) $(LIBOBJS) -c $< -Fo $@ 

.c.i:
$(CC) $(CFLAGS) $(LIBOBJS) -C -E $< > $@

clean:
del /s /f /q ..\lib\*.o ..\src\*.o *.o *.exe *.pdb

distclean: clean

I get this error

fatal error U1000: syntax error : ')' missing in macro invocation at line 6

Am i missing something here? nmake does recognize addprefix, right?

like image 989
Capricorn Avatar asked Oct 22 '22 15:10

Capricorn


1 Answers

No, addprefix is a GNU make extension. You have a GNUmakefile that requires GNU make (gmake) to process.

Alternatively, you could rewrite the GNU makefile to not use GNU extensions. In your case this should be easy:

LIBSRC = $(addprefix ../lib/, \
        open.c malloc.c \
     ) \
     $(addprefix ../src/, \
        main.c \
      ) \
      helper.c

becomes

LIBSRC = ../lib/open.c ../lib/malloc.c ../src/main.c helper.c
like image 64
Jens Avatar answered Oct 27 '22 00:10

Jens