Makefile in windows

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hi team

First time writing Makefile here in Windows environment. How can I put a backslash in the following code:
Bash:
# under windows this one output: .\src/main.c
_SOURCE_FILES     := $(wildcard $(FOLDER_SOURCE)/*.c)

# this one won't work
# trying to be like this: .\src\main.c
_SOURCE_FILES     := $(wildcard $(FOLDER_SOURCE)\*.c)
This is my full makefile (so far):
Bash:
CC         := gcc
FLAGS     := -Wall -std=c99

# name of the final program
TARGET_EXEC    := final_program

# source files folder
FOLDER_SOURCE     := .\src

# header files folder
FOLDER_INCLUDE     := .\src

# object files folder
FOLDER_OBJECT     := .\obj

# output files folder
FOLDER_BIN         := .\bin

# under windows this one output: .\src/main.c
_SOURCE_FILES     := $(wildcard $(FOLDER_SOURCE)/*.c)

# this one won't work
# tryint to be like this: .\src\main.c
# _SOURCE_FILES     := $(wildcard $(FOLDER_SOURCE)\*.c)

# replace forward slash with back slash
#SOURCE_FILES     := $(subst /,\,$(_SOURCE_FILES))

$(TARGET_EXEC):
    @echo $(_SOURCE_FILES)
# @echo $(SOURCE_FILES)


.DELETE_ON_ERROR:
 

dl324

Joined Mar 30, 2015
16,844
Try using backslash to escape the backslash (e.g. .\\bin).

Most Unix based utilities running on Windows will treat / or \ as the directory delimiter.
 
Top