view cygwin/cygrun/Makefile @ 639:13381cd386fe

Added wrapper for quilt.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Tue, 08 Aug 2017 00:56:23 +0300
parents 41c5dab96724
children
line wrap: on
line source

# Copyright (C) 2008 by Oleksandr Gavenko <gavenkoa@gmail.com>

# To compile this MSVC or MS SDK run 'setenv.cmd' and:
#   cmd> cl /TP /DDEBUG cygrun.c /Fecygrun-cl.exe

SHELL = /bin/sh

# Disable built in pattern rules.
MAKEFLAGS += -r
# Disable built in variables.
MAKEFLAGS += -R
# Disable built in suffix rules.
.SUFFIXES:
# Delete target file if command fails.
.DELETE_ON_ERROR:
# Default target.
.DEFAULT_GOAL = all

ifeq '' '$(prefix)'
  ifneq '' '$(HOME)'
    prefix = $(HOME)/usr
  else
    $(error HOME env var and prefix var are not set!)
  endif
endif

bindir = $(prefix)/bin

host_os = unix
ifneq '' '$(COMSPEC)'
  host_os = windows
endif

UNAME := $(shell uname -s)
ifneq '' '$(filter MINGW%,$(UNAME))'
  host_os_emu = mingw
endif
ifneq '' '$(filter CYGWIN%,$(UNAME))'
  host_os_emu = cygwin
endif

CC = gcc
LD = gcc
# CC=i686-pc-cygwin-gcc-3 -mno-cygwin
# LD=i686-pc-cygwin-gcc-3 -mno-cygwin

DEBUG_CFLAGS := -g -DDEBUG
WARN_CFLAGS := -Wall -pedantic
OPT_CFLAGS := -O2
CFLAGS := -std=gnu99 $(WARN_CFLAGS) $(OPT_CFLAGS)
ifeq 'yes' '$(DEBUG)'
  CFLAGS += $(DEBUG_CFLAGS)
endif
LDFLAGS =
ifeq 'windows' '$(host_os)'
  CFLAGS += -mwindows
endif

EXE_SUFFIX =
ifeq 'windows' '$(host_os)'
  EXE_SUFFIX = .exe
endif

C_FILES = $(wildcard *.c)
O_FILES = $(C_FILES:.c=.o)

APP = cygrun$(EXE_SUFFIX)

.PHONY: all
all: $(APP)

$(APP): $(O_FILES)
	$(LD) $(LDFLAGS) -o $@ $^
ifneq 'yes' '$(DEBUG)'
	strip --strip-all $@
endif

$(O_FILES): %.o: %.c $(MAKEFILE_LIST)
	$(CC) $(CFLAGS) -c -o $@ $<

.PHONY: check
check:

INST_FILES = $(APP) hg.exe bzr.exe python.exe quilt.exe

.PHONY: install
install: $(APP)
	[ -d $(bindir) ] || mkdir -p $(bindir)
	for file in $(INST_FILES); do \
		install -m 755 $(APP) $(bindir)/$$file; \
	done

.PHONY: uninstall
uninstall:
	for file in $(addprefix $(bindir)/,$(INST_FILES)); do \
		if rm $$file; then :; \
		else \
			echo Unable to delete $$file; \
			exit 1; \
		fi; \
	done

.PHONY: distclean
distclean: clean

.PHONY: clean
clean:
	rm -f $(APP) $(O_FILES)

################################################################
# Helper target.

.PHONY: help
help:
	@echo
	@echo DEBUG="$(DEBUG)   - yes/[no]"
	@echo
	@echo Supported targets:
	@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*=  \1=;p;}' $(MAKEFILE_LIST)