Error: make: *** No rule to make target `makefile'. Stop. using Powershell and Gnuwin32

3.1k views Asked by At

I'm working through a coding tutorial/book called Curious Moon. One of the assignments is to normalize and load data from a CSV file put in a Postgres table. The database name is "enceladus" and the table name is "master_plan". I was told to use make to do this. I can't figure out how to run the Makefile in PowerShell.

I installed GNUWin32 with make.exe on my Windows laptop running Windows 10. I used PowerShell to run make.exe. I did this by running notepad $profile and saved New-Item alias:make -Value 'C:\Program Files (x86)\GnuWin32\bin\make.exe' in the file. I gave it a new alias because I was getting an error message. Now when I'm calling the alias like this:

PS C:\Users\Sabrina> make

I'm getting this error:

make: *** No targets specified and no makefile found. Stop.

I wrote the Makefile in sublime and saved it as a makefile extension. It's in the same folder 'C:\Program Files (x86)\GnuWin32\bin' as make.exe and named Makefile. I tried running it as

PS C:\Users\Sabrina> make -f Makefile

and then I get the error

make: Makefile: No such file or directory

I'm not sure how to get the makefile to open and run.

This is my code in the Makefile:

DB=enceladus
BUILD=${CURDIR}/build.sql
SCRIPTS=${CURDIR}/scripts
CSV='${CURDIR}/data/master_plan.csv'
MASTER=$(SCRIPTS)/import.sql
NORMALIZE = $(SCRIPTS)/normalize.sql
all: normalize
    psql $(DB) -f $(BUILD)
master: 
    @cat $(MASTER) >> $(BUILD)
import: master 
    @echo "COPY import.master_plan FROM $(CSV) WITH DELIMITER ',' HEADER CSV;" >> $(BUILD)
normalize: import
    @cat $(NORMALIZE) >> $(BUILD)
clean:
    @rm -rf $(BUILD)
1

There are 1 answers

4
Ansgar Wiechers On

Makefile is in C:\Program Files (x86)\GnuWin32\bin, but you're current working directory is C:\Users\Sabrina. When running make or make -f Makefile the command is looking for a Makefile in the current working directory, not in the directory where the executable resides.

Put the Makefile into your current working directory and the problem will disappear.

Move-Item 'C:\Program Files (x86)\GnuWin32\bin\Makefile' .
make