0

For a task, I've got a Makefile provided with this content:

# Flag that states that warnings will not lead to compilation errors
FORCE = false

# Compiler
CC      = gcc
# Doc generator
DOC     = doxygen

# Include directories
INCLUDES     =
# Compiler flags
CFLAGS_FORCE = -c -g -ansi -pedantic -Wall -Wextra
CFLAGS       = $(CFLAGS_FORCE) -Werror
# Linker flags
LDFLAGS      =

# Source codes
SOURCE      = ueb01.c
OBJECTS     = $(SOURCE:.c=.o)

# Target name
BINARY      = ueb01

.PHONY: all help clean doc doc

default: all

force: 
    @make FORCE=true

all: $(BINARY)

# Compile a single file
%.o : %.c
    @echo "  - Building $@"
ifeq ($(FORCE),true)
    $(CC) $(CFLAGS_FORCE) $(INCLUDES) -o $@ $<
else
    $(CC) $(CFLAGS) $(INCLUDES) -o $@ $<
endif
    @echo "  ... done"

# Link files to an executable
$(BINARY): $(OBJECTS)
    @echo "  - linking $@"
    $(CC) $(LDFLAGS) $(OBJECTS) -o $(BINARY)
    @echo "  ... done"

# Clean the project
clean:
    @echo "  - delete object all files"
    rm -f $(OBJECTS) $(BINARY) *~ doxygen.log
    rm -rf doc/
    @echo "  ... done"

doc:
    @echo "  - creating documentation"
    $(DOC)
    @echo "  ... done"

# Show help
help:
    @echo "Options:"
    @echo "make all      - create program"
    @echo "make clean    - clean up"
    @echo "make doc      - create documentation"
    @echo "make force    - compile without -Werror (just for 'comfier' development)"

Within same folder as the Makefile, I've got a program.c file that I'd like to execute. The content of that file is not relevant here, because I can't even compile the .c file with the provided Makefile. So when I'm the cmd window and type in make or make all, following lines are being displayed:

MAKE Version 5.4  Copyright (c) 1987, 2010 Embarcadero Technologies, Inc.
Error makefile 45: Command syntax error
Error makefile 46: Command syntax error
Error makefile 47: Command syntax error
Error makefile 48: Command syntax error
Error makefile 49: Command syntax error
Error makefile 50: Command syntax error
*** 6 errors during make ***

The Makefile was provided by my supervisors for the task and works fine as it's supposed to do for my friends but strangely not for me.

I've tried to solve this by installing CMake by Kitware but it gives me the same errors. I'm running on Windows 10 (64 Bit).

Thanks in advance! T.T

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Two-Tu
  • 107
  • 2
  • 10
  • 1
    Are you sure all commands in the `makefile` begin with a tab character? – G.M. Nov 02 '18 at 12:31
  • Yeah, I'm pretty sure. I went into the *Makefile* and manually inserted a tab character into the lines. However, executing ´make´gives me the same errors. I also don't understand why it says that there's a syntax error in line 50 when line 50 is blank. – Two-Tu Nov 02 '18 at 12:34
  • 1
    Littering a lot of commands with `@` prefixes hampers debugging, and should generally be avoided. Once the `Makefile` works, run it with `make -s` if you don't want to see what you are doing. – tripleee Nov 02 '18 at 12:38
  • 1
    Do you have working `gcc` and `doxygen`? Does Embarcadero `make` support the GNU Make extensions you seem to be using? (Their examples look like their syntax for conditionals is `!if`) – tripleee Nov 02 '18 at 12:40
  • On second thoughts, are you using a version of `make` that actually understands that file? From the first line in the error message it's certainly not `GNU Make`. – G.M. Nov 02 '18 at 12:43
  • Thanks for the replies! Actually, it could very much possible that I am using the "wrong version of make". As a scrub, I apologize for this newbie question, but what I am supposed to do if I'd like to install e.g. *gcc*? – Two-Tu Nov 02 '18 at 12:49
  • Change line 19 to be `@$(MAKE) force=TRUE` to avoid picking up the wrong version of make on the `force` rule again. (in fact, get rid of that target altogether -- the use of FORCE as you have it is error prone) – HardcoreHenry Nov 02 '18 at 13:33
  • 1
    [How to install and use "make" in Windows?](/questions/32127524/how-to-install-and-use-make-in-windows/32127632#32127632) – tripleee Nov 02 '18 at 13:40
  • Hey! I have managed to install MinGW and also added the path to it within the Advanced Settings > Systemvariables in Windows, yet it seems like the "Make" from Embarcado is being used for this operation, and not the one from MinGW. – Two-Tu Nov 02 '18 at 13:47
  • @arved: please do not create company name tags. The tag you added has no real use as it does not define a distinct concept or product and was deleted before. – Martijn Pieters Dec 06 '18 at 02:28

0 Answers0