make: Add support for mingw

This commit is contained in:
Jan Lindemann 2007-07-13 10:49:58 +00:00 committed by Jan Lindemann
commit 65ba4f3cfd
5 changed files with 47 additions and 9 deletions

View file

@ -11,12 +11,12 @@ VERSION ?= $(shell cat $(TOPDIR)/VERSION)
DIST_VERSION ?= $(shell sed -e "s/-dev//" $(TOPDIR)/VERSION)
HEX_VERSION = $(shell echo $(DIST_VERSION) | \
sed 's/-dev//; s/pre[^\.]*//; s/F[^\.]//; s/[\.-]/ /g' | xargs printf "0x%02x%02x%02x%02x")
DEVELOPMENT ?= $(shell grep -q 'dev' $(TOPDIR)/VERSION && echo true)
DEVELOPMENT ?= $(shell echo $(VERSION) | grep -q 'dev' && echo true)
USE_PROJECT_LIB ?= true
USE_YTOOLS ?= true
REENTRANT ?= true
USE_GFILTER ?= true
OS ?= $(shell sh $(MODDIR)/bin/get_os.sh)
OS ?= $(shell sh $(MODDIR)/devutil/scripts/get_os.sh)
ifneq ($(shell echo $(OS) | cut -d: -f1),suse-9)
SYSCONFIG_FILE ?= /etc/rc.config
@ -34,11 +34,14 @@ CONFIG_FILE ?= $(CONFIG_DIR)/$(PROJECT).conf
export REENTRANT
USE_CFG_XXX_MK ?= true
ifeq ($(USE_CFG_XXX_MK),true)
ifeq ($(DEVELOPMENT),true)
include $(TOPDIR)/make/cfg_dev.mk
else
include $(TOPDIR)/make/cfg_dist.mk
endif
endif
OPTS_PID_FILE ?= $(PIDDIR)/$(PROJECT).pid
@ -50,6 +53,17 @@ ifndef LIBNAME
LIBNAME := $(PROJECT)
endif
TARGET ?= Linux
ifeq ($(TARGET),mingw)
CROSS_TOOL_DIR = /opt/cross-tools
CROSS_TOOL_BIN_PREFIX = $(CROSS_TOOL_DIR)/bin/i386-mingw32-
CC = $(CROSS_TOOL_BIN_PREFIX)gcc
GPP = $(CROSS_TOOL_BIN_PREFIX)g++
LDFLAGS += -Wl,--out-implib
endif
YTOOLS_DIR = $(MODDIR)
WINVERSION = $(shell echo $(VERSION) | sed -e "s/\./_/g")
LOCAL_VERSION = $(shell echo $(VERSION))
@ -73,7 +87,7 @@ FTP_PCKG_DIR = /pub/packages
JANNET_PROJ_DIR = rsync_ssh://ftp.jannet.de:/home/ftp/dat$(FTP_PCKG_DIR)
CONFDIR = $(MODDIR)/../conf
CC = gcc
CC ?= gcc
GCC_VERSION = $(shell gcc -v 2>&1 | grep version | awk '{ print $$3;}')
GCC_MAJOR = $(shell gcc -v 2>&1 | grep version | awk '{ split($$3,a,"."); print a[1];}')
@ -226,14 +240,18 @@ else
# LPPFLAGS += -L/usr/local/gcc3.3/lib
else
ifeq ($(GCC_MAJOR),4) # -PIC is more a thing with AMD64, I think
CPPFLAGS += -fPIC
CFLAGS += -fPIC
ifeq ($(TARGET),Linux)
CPPFLAGS += -fPIC
CFLAGS += -fPIC
endif
endif
endif
endif
ifeq ($(LIBTYPE),shared)
ifneq ($(TARGET),mingw)
LDFLAGS += -rdynamic
endif
endif
# TODO: this shoud be only conditional, but breaks, because not all headers

View file

@ -3,8 +3,6 @@
# contact@jannet.de
# $Id$
EXE ?= $(notdir $(shell pwd))
include $(MODDIR)/make/run.mk
include $(MODDIR)/make/depend.mk

View file

@ -48,7 +48,16 @@ else
include $(TOPDIR)/make/cfg_dist.mk
endif
LDFLAGS += -lytools -ldl -pthread
LDFLAGS += -lytools
ifeq ($(TARGET),Linux)
LDFLAGS += -ldl -pthread
endif
ifeq ($(TARGET),mingw)
CFLAGS += -D_USRDLL -DYTOOLS_EXPORTS
CPPFLAGS += -D_USRDLL -DYTOOLS_EXPORTS
endif
ARCH = @ARCH@
LD_LIB_PATH=$(TOPDIR)/lib
@ -56,6 +65,7 @@ LD_LIB_PATH=$(TOPDIR)/lib
PROJECT_CFLAGS += -gstabs+
PROJECT_CPPFLAGS += -gstabs+
ifneq ($(TARGET),mingw)
ifeq (@ARCH@,x86)
PROJECT_LDFLAGS += $(shell export PKG_CONFIG_PATH=/opt/gnome/lib/pkgconfig; pkg-config --libs glib-2.0)
else
@ -63,3 +73,4 @@ else
PROJECT_LDFLAGS += $(shell export PKG_CONFIG_PATH=/opt/gnome/lib64/pkgconfig; pkg-config --libs glib-2.0)
endif
endif
endif

View file

@ -100,8 +100,10 @@ else
$(EXE) $(EXE_BIN): $(OBJ)
endif
$(CC) $(sort $(OBJ)) $(LDFLAGS) -o $@
$(BUILD_BINDIR)/%: %
mkdir -p $(BUILD_BINDIR)
install -m 755 $@ $(BUILD_BINDIR)
install -m 755 $< $(BUILD_BINDIR)
ifeq ($(USE_PROJECT_LIB),true)
ifeq ($(LIBTYPE),shared)

View file

@ -4,7 +4,11 @@
# $Id$
ifeq ($(EXE),)
ifneq ($(TARGET),mingw)
EXE = $(notdir $(shell pwd))
else
EXE = $(notdir $(shell pwd)).exe
endif
endif
include $(MODDIR)/make/defs.mk
@ -22,7 +26,12 @@ valgrind:
valgrind ./$(EXE) $(EXE_ARGS)
run:
rm -f $(CORE)
ifeq ($(TARGET),mingw)
wine ./$(EXE) $(EXE_ARGS)
else
./$(EXE) $(EXE_ARGS)
endif
stop:
killall ./$(EXE)
kill: