Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile fixups (Cygwin vs. Windows vs. Linux) #37

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# cobbled together really fast
CC = gcc
# Assume Linux/UNIX by default, detect native Windows vs. Cygwin/MSYS2.
# For Clang: CC=clang make

# no matter how hard I try, I can't get make to accept that I'm on windows.
ifneq ($(shell echo),)
DOTEXE=.exe
BINARY=asm6f
RM=rm -f

ifeq ($(OS),Windows_NT)
BINARY=asm6f.exe
RM=del /Q /F
ifeq ($(OSTYPE),cygwin)
RM=rm -f
else ifdef MSYSTEM
RM=rm -f
endif
endif

.PHONY: all clean
CFLAGS=-O2 -Wall -Werror -Wextra -Wformat=2 -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-equal -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wunreachable-code -Wwrite-strings

.PHONY: all safe clean

all: safe

safe:
$(CC) -Wall asm6f.c -o asm6f
safe: asm6f.c
$(CC) $(CFLAGS) -o $(BINARY) $^

# sorry to linux people for forcing .exe but I can't get this makefile to determine
# that I'm really on windows
clean:
$(RM) asm6f$(DOTEXE) *.exe
$(RM) $(BINARY)